From 80c6f65977d83d68715abfcd03a53c85e954061c Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sat, 10 Apr 2010 17:32:39 -0400 Subject: [PATCH] Refine the -C test a bit. SVN-Revision: 2223 --- tar/test/test_option_C_upper.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) 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(".."); } -- 2.47.3