]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Do not try to redirect stderr on Windows
authorTim Kientzle <kientzle@acm.org>
Sun, 23 Oct 2016 23:24:00 +0000 (16:24 -0700)
committerTim Kientzle <kientzle@acm.org>
Sun, 23 Oct 2016 23:24:00 +0000 (16:24 -0700)
libarchive/test/test_read_set_format.c

index 2ebc873d737948957a06d5f37282b02a75ca7a6f..6ca043d4a895eac2cb9eec38d1a5d2296536a9b8 100644 (file)
@@ -200,9 +200,11 @@ DEFINE_TEST(test_read_append_filter_wrong_program)
 {
   struct archive_entry *ae;
   struct archive *a;
+#if !defined(_WIN32) || defined(__CYGWIN__)
   FILE * fp;
   int fd;
   fpos_t pos;
+#endif
 
   /*
    * If we have "bunzip2 -q", try using that.
@@ -212,11 +214,13 @@ DEFINE_TEST(test_read_append_filter_wrong_program)
     return;
   }
 
+#if !defined(_WIN32) || defined(__CYGWIN__)
   /* bunzip2 will write to stderr, redirect it to a file */
   fflush(stderr);
   fgetpos(stderr, &pos);
   fd = dup(fileno(stderr));
   fp = freopen("stderr1", "w", stderr); 
+#endif
 
   assert((a = archive_read_new()) != NULL);
   assertA(0 == archive_read_set_format(a, ARCHIVE_FORMAT_TAR));
@@ -228,7 +232,8 @@ DEFINE_TEST(test_read_append_filter_wrong_program)
   assertEqualIntA(a, ARCHIVE_WARN, archive_read_close(a));
   assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
-  /* restore stderr */
+#if !defined(_WIN32) || defined(__CYGWIN__)
+  /* restore stderr and verify results */
   if (fp != NULL) {
     fflush(stderr);
     dup2(fd, fileno(stderr));
@@ -236,6 +241,6 @@ DEFINE_TEST(test_read_append_filter_wrong_program)
     clearerr(stderr);
     fsetpos(stderr, &pos);
   }
-
   assertTextFileContents("bunzip2: (stdin) is not a bzip2 file.\n", "stderr1");
+#endif
 }