Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Apr 2021 13:30:11 GMT
From:      Alex Richardson <arichardson@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: d612bd6d0d5d - stable/13 - libarchive: Make test_read_append_filter_wrong_program pass again
Message-ID:  <202104101330.13ADUBPh005593@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by arichardson:

URL: https://cgit.FreeBSD.org/src/commit/?id=d612bd6d0d5dc5bc8e6ac10aec845e2ae2fe933b

commit d612bd6d0d5dc5bc8e6ac10aec845e2ae2fe933b
Author:     Alex Richardson <arichardson@FreeBSD.org>
AuthorDate: 2021-04-07 10:35:10 +0000
Commit:     Alex Richardson <arichardson@FreeBSD.org>
CommitDate: 2021-04-10 13:01:05 +0000

    libarchive: Make test_read_append_filter_wrong_program pass again
    
    libarchive: Apply upstream commit a1b7bf8013fb7a11a486794247daae592db6f5ae
    
    This fixes the failing test_read_append_filter_wrong_program test in CI
    which has been failing since 01-Dec-2020.
    
    Commit message from https://github.com/libarchive/libarchive/commit/a1b7bf8013fb7a11a486794247daae592db6f5ae
    
        Silence stderr in test_read_append_filter_program
    
        When the FreeBSD testsuite runs the libarchive tests it checks that stderr
        is empty. Since #1382 this is no longer the case. This change restores
        the behaviour of silencing bunzip2 stderr but doesn't bring back the
        output text check.
    
        Partially reverts 2e7aa5d9
    
    MFC after:      3 days
    Differential Revision: https://reviews.freebsd.org/D29036
    
    (cherry picked from commit 2bca8aa7a79ad2b6683e8f5a5c373de81c5baca2)
---
 .../libarchive/test/test_read_set_format.c         | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/contrib/libarchive/libarchive/test/test_read_set_format.c b/contrib/libarchive/libarchive/test/test_read_set_format.c
index f357bada82c3..c760de0056d3 100644
--- a/contrib/libarchive/libarchive/test/test_read_set_format.c
+++ b/contrib/libarchive/libarchive/test/test_read_set_format.c
@@ -201,6 +201,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.
@@ -210,6 +215,14 @@ 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);
+  assert((fd = dup(fileno(stderr))) != -1);
+  fp = freopen("stderr1", "w", stderr);
+#endif
+
   assert((a = archive_read_new()) != NULL);
   assertA(0 == archive_read_set_format(a, ARCHIVE_FORMAT_TAR));
   assertEqualIntA(a, ARCHIVE_OK,
@@ -219,4 +232,15 @@ DEFINE_TEST(test_read_append_filter_wrong_program)
   assertA(archive_read_next_header(a, &ae) < (ARCHIVE_WARN));
   assertEqualIntA(a, ARCHIVE_WARN, archive_read_close(a));
   assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+
+#if !defined(_WIN32) || defined(__CYGWIN__)
+  /* restore stderr */
+  if (fp != NULL) {
+    fflush(stderr);
+    dup2(fd, fileno(stderr));
+    clearerr(stderr);
+    (void)fsetpos(stderr, &pos);
+  }
+  close(fd);
+#endif
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104101330.13ADUBPh005593>