From: Tim Kientzle Date: Sat, 10 Apr 2010 21:32:39 +0000 (-0400) Subject: Refine the -C test a bit. X-Git-Tag: v3.0.0a~1125 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=80c6f65977d83d68715abfcd03a53c85e954061c;p=thirdparty%2Flibarchive.git Refine the -C test a bit. SVN-Revision: 2223 --- diff --git a/tar/test/test_option_C_upper.c b/tar/test/test_option_C_upper.c index 8b4dfd0f3..ffc65e588 100644 --- a/tar/test/test_option_C_upper.c +++ b/tar/test/test_option_C_upper.c @@ -70,8 +70,9 @@ DEFINE_TEST(test_option_C_upper) */ assertMakeDir("test3", 0755); assertChdir("test3"); - r = systemf("%s -cf archive.tar -C ../XXX file1 -C ../d2 file2", testprog); + r = systemf("%s -cf archive.tar -C ../XXX file1 -C ../d2 file2 2>write.err", testprog); assert(r != 0); + assertNonEmptyFile("write.err"); assertEqualInt(0, systemf("%s -xf archive.tar >test.out 2>test.err", testprog)); assertFileNotExists("file1"); @@ -95,9 +96,8 @@ DEFINE_TEST(test_option_C_upper) assertEmptyFile("test.err"); assertChdir(".."); - /* - * Test 5: Unnecessary -C ignored + * Test 5: Unnecessary -C ignored even if directory named doesn't exist */ assertMakeDir("test5", 0755); assertChdir("test5"); @@ -110,4 +110,19 @@ DEFINE_TEST(test_option_C_upper) assertEmptyFile("test.out"); assertEmptyFile("test.err"); assertChdir(".."); + + /* + * Test 6: Necessary -C not ignored if directory doesn't exist + */ + assertMakeDir("test6", 0755); + assertChdir("test6"); + r = systemf("%s -cf archive.tar -C XXX -C ../d1 file1 2>write.err", + testprog, testworkdir); + assert(r != 0); + assertNonEmptyFile("write.err"); + assertEqualInt(0, + systemf("%s -xf archive.tar >test.out 2>test.err", testprog)); + assertEmptyFile("test.out"); + assertEmptyFile("test.err"); + assertChdir(".."); }