diff options
Diffstat (limited to 'usr.bin/tar/test/test_patterns.c')
-rw-r--r-- | usr.bin/tar/test/test_patterns.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/usr.bin/tar/test/test_patterns.c b/usr.bin/tar/test/test_patterns.c index 575e8a4..4707dac 100644 --- a/usr.bin/tar/test/test_patterns.c +++ b/usr.bin/tar/test/test_patterns.c @@ -30,6 +30,7 @@ DEFINE_TEST(test_patterns) int fd, r; const char *reffile2 = "test_patterns_2.tgz"; const char *reffile2_out = "test_patterns_2.tgz.out"; + const char *reffile3 = "test_patterns_3.tgz"; /* * Test basic command-line pattern handling. @@ -63,6 +64,37 @@ DEFINE_TEST(test_patterns) assertEmptyFile("tar2a.err"); /* - * + * Test 3 archive has some entries starting with '/' and some not. */ + extract_reference_file(reffile3); + + /* Test 3a: Pattern tmp/foo/bar should not match /tmp/foo/bar */ + r = systemf("%s xf %s tmp/foo/bar > tar3a.out 2> tar3a.err", + testprog, reffile3); + assert(r != 0); + assertEmptyFile("tar3a.out"); + + /* Test 3b: Pattern /tmp/foo/baz should not match tmp/foo/baz */ + assertNonEmptyFile("tar3a.err"); + /* Again, with the '/' */ + r = systemf("%s xf %s /tmp/foo/baz > tar3b.out 2> tar3b.err", + testprog, reffile3); + assert(r != 0); + assertEmptyFile("tar3b.out"); + assertNonEmptyFile("tar3b.err"); + + /* Test 3c: ./tmp/foo/bar should not match /tmp/foo/bar */ + r = systemf("%s xf %s ./tmp/foo/bar > tar3c.out 2> tar3c.err", + testprog, reffile3); + assert(r != 0); + assertEmptyFile("tar3c.out"); + assertNonEmptyFile("tar3c.err"); + + /* Test 3d: ./tmp/foo/baz should match tmp/foo/baz */ + r = systemf("%s xf %s ./tmp/foo/baz > tar3d.out 2> tar3d.err", + testprog, reffile3); + assertEqualInt(r, 0); + assertEmptyFile("tar3d.out"); + assertEmptyFile("tar3d.err"); + assertEqualInt(0, access("tmp/foo/baz/bar", F_OK)); } |