unit-tests: Skip fmemopen() based printf() tests if not available
authorMartin Willi <martin@revosec.ch>
Tue, 15 Oct 2013 16:15:29 +0000 (18:15 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 6 Nov 2013 09:31:01 +0000 (10:31 +0100)
src/libstrongswan/tests/suites/test_printf.c

index 6c15fbe..8558cca 100644 (file)
@@ -20,7 +20,6 @@
 
 static void verify(char *expected, char *format, ...)
 {
-       FILE *mem;
        char buf[128];
        va_list args;
 
@@ -29,12 +28,18 @@ static void verify(char *expected, char *format, ...)
        ck_assert_str_eq(expected, buf);
        va_end(args);
 
-       mem = fmemopen(buf, sizeof(buf), "w");
-       va_start(args, format);
-       vfprintf(mem, format, args);
-       va_end(args);
-       fclose(mem);
-       ck_assert_str_eq(expected, buf);
+#ifdef HAVE_FMEMOPEN
+       {
+               FILE *mem;
+
+               mem = fmemopen(buf, sizeof(buf), "w");
+               va_start(args, format);
+               vfprintf(mem, format, args);
+               va_end(args);
+               fclose(mem);
+               ck_assert_str_eq(expected, buf);
+       }
+#endif /* HAVE_FMEMOPEN */
 }
 
 START_TEST(test_printf_strings)