From: Graham Percival Date: Fri, 27 Dec 2024 20:38:03 +0000 (-0800) Subject: Fix remaining TODOs in test_stdio.c (#2444) X-Git-Tag: v3.7.8~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=287b153444bad194bc15c929933f12e96e92a6bc;p=thirdparty%2Flibarchive.git Fix remaining TODOs in test_stdio.c (#2444) (cherry picked from commit 0acaa2994a6c230fc9d83684c151417c9c1e19d1) --- diff --git a/tar/test/test_stdio.c b/tar/test/test_stdio.c index 8bb08ca45..95f6f8db9 100644 --- a/tar/test/test_stdio.c +++ b/tar/test/test_stdio.c @@ -22,6 +22,12 @@ static const char *xvf_err = "x f\n" "x l\n"; +/* + * This string should appear in the verbose listing regardless of platform, + * locale, username, or groupname. + */ +const char * tvf_contains = "l link to f"; + DEFINE_TEST(test_stdio) { FILE *filelist; @@ -69,9 +75,13 @@ DEFINE_TEST(test_stdio) r = systemf("%s cvf - f l >cvf-.out 2>cvf-.err", testprog); assertEqualInt(r, 0); failure("cvf - should write archive to stdout"); - /* TODO: Verify cvf-.out has archive. */ failure("cvf - should write file list to stderr (SUSv2)"); assertEqualFile("cvf.err", "cvf-.err"); + /* Check that stdout from 'cvf -' was a valid archive. */ + r = systemf("%s tf cvf-.out >cvf-tf.out 2>cvf-tf.err", testprog); + assertEqualInt(r, 0); + assertEmptyFile("cvf-tf.err"); + assertTextFileContents(tf_out, "cvf-tf.out"); /* 'tf' should generate file list on stdout, empty stderr. */ r = systemf("%s tf archive >tf.out 2>tf.err", testprog); @@ -85,7 +95,10 @@ DEFINE_TEST(test_stdio) assertEqualInt(r, 0); assertEmptyFile("tvf.err"); failure("'tv' mode should write results to stdout"); - /* TODO: Verify tvf.out has file list. */ + /* Check that it contains a string only found in the verbose listing. */ + p = slurpfile(&s, "%s", "tvf.out"); + assert(strstr(p, tvf_contains) != NULL); + free(p); /* 'tvf -' uses stdin, file list on stdout, empty stderr. */ r = systemf("%s tvf - < archive >tvf-.out 2>tvf-.err", testprog);