#define LIMIT_USTAR 100
static void
-verify_tree(size_t limit)
+verify_tree(size_t limit, const char *format)
{
char name1[260];
char name2[260];
/* Verify a file named "f/abcdef..." */
snprintf(name1, sizeof(name1), "f/%s", filenames[i]);
if (i <= limit) {
+ failure("Verifying %s", format);
assertFileExists(name1);
assertFileContents(name1, (int)strlen(name1), name1);
}
snprintf(name2, sizeof(name2), "l/%s", filenames[i]);
if (i + 2 <= limit) {
/* Verify hardlink "l/abcdef..." */
+ failure("Verifying %s", format);
assertIsHardlink(name1, name2);
/* Verify hardlink "m/abcdef..." */
name2[0] = 'm';
/* Verify symlink "s/abcdef..." */
snprintf(name1, sizeof(name1), "s/%s", filenames[i]);
snprintf(name2, sizeof(name2), "../f/%s", filenames[i]);
- if (strlen(name2) <= limit)
+ if (strlen(name2) <= limit) {
+ failure("Verifying %s", format);
assertIsSymlink(name1, name2, 0);
+ }
}
/* Verify dir "d/abcdef...". */
snprintf(name1, sizeof(name1), "d/%s", filenames[i]);
if (i + 1 <= limit) { /* +1 for trailing slash */
+ failure("Verifying %s", format);
if (assertIsDir(name1, -1)) {
/* TODO: opendir/readdir this
* directory and make sure
char dir[2];
dir[0] = *dp; dir[1] = '\0';
d = opendir(dir);
- failure("Unable to open dir '%s'", dir);
+ failure("Unable to open dir '%s' for testing %s", dir, format);
if (!assert(d != NULL))
continue;
while ((de = readdir(d)) != NULL) {
}
static void
-copy_basic(void)
+copy_basic(const char *extra_args, const char *name)
{
int r;
/* NOTE: for proper operation on cygwin-1.5 and windows, the
- * length of the name of the directory below, "plain", must be
+ * length of the name of the directory below must be
* less than or equal to the length of the name of the original
* directory, "original" This restriction derives from the
* extremely limited pathname lengths on those platforms.
*/
- assertMakeDir("plain", 0775);
- assertEqualInt(0, chdir("plain"));
+ assertMakeDir(name, 0775);
+ assertEqualInt(0, chdir(name));
/*
* Use the tar program to create an archive.
*/
- r = systemf("%s cf archive -C ../original f d l m s >pack.out 2>pack.err",
- testprog);
- failure("Error invoking \"%s cf\"", testprog);
+ r = systemf("%s cf archive %s -C ../original f d l m s >pack.out 2>pack.err",
+ testprog, extra_args);
+ failure("Error invoking \"%s cf archive %s\"", testprog, extra_args);
assertEqualInt(r, 0);
/* Verify that nothing went to stdout or stderr. */
assertEmptyFile("unpack.err");
assertEmptyFile("unpack.out");
- verify_tree(LIMIT_NONE);
+ verify_tree(LIMIT_NONE, name);
assertEqualInt(0, chdir(".."));
}
assertEmptyFile("unpack.err");
assertEmptyFile("unpack.out");
- verify_tree(LIMIT_USTAR);
- assertEqualInt(0, chdir("../.."));
+ verify_tree(LIMIT_USTAR, "ustar");
+ assertEqualInt(0, chdir(".."));
}
DEFINE_TEST(test_copy)
create_tree(); /* Create sample files in "original" dir. */
/* Test simple "tar -c | tar -x" pipeline copy. */
- copy_basic();
+ copy_basic("", "default");
/* Same, but constrain to ustar format. */
copy_ustar();
+
+ /* Same, but with pax format. */
+ copy_basic(" --format pax", "pax");
}