1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2003-2014 Tim Kientzle 5 * All rights reserved. 6 */ 7 #include "test.h" 8 9 DEFINE_TEST(test_leading_slash) 10 { 11 const char *reffile = "test_leading_slash.tar"; 12 char *errfile; 13 size_t errfile_size; 14 const char *expected_errmsg = "Removing leading '/' from member names"; 15 16 extract_reference_file(reffile); 17 assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err", testprog, reffile)); 18 assertFileExists("foo/file"); 19 assertTextFileContents("foo\x0a", "foo/file"); 20 assertTextFileContents("foo\x0a", "foo/hardlink"); 21 assertIsHardlink("foo/file", "foo/hardlink"); 22 assertEmptyFile("test.out"); 23 24 /* Verify the error output contains the expected text somewhere in it */ 25 if (assertFileExists("test.err")) { 26 errfile = slurpfile(&errfile_size, "test.err"); 27 assert(strstr(errfile, expected_errmsg) != NULL); 28 free(errfile); 29 } 30 } 31 32