8 use Test::More tests => 6;
9 use File::Path qw(rmtree mkpath);
17 (my $dir = $fn) =~ s,/[^/]+$,,;
19 open my $fd, ">", $fn or die "$fn: $!";
20 print $fd "file $n\n";
24 ustar_pathnames: { SKIP: {
25 # Prove that pax breaks up ustar pathnames properly
27 my $top = getcwd . "/ustar-pathnames-1";
28 skip "Current path is too long", 6 if length $top > 92;
30 my $subdir = "x" . "x" x (92 - length $top);
31 my $work94 = "$top/$subdir";
32 mkpath $work94; # $work is 94 characters long
40 "$work94/x099", # 99 chars
41 "$work94/xx100", # 100 chars
42 "$work94/xxx101", # 101 chars
43 "$work94/$x49/${x50}x199", # 199 chars
44 "$work94/$x49/${x50}xx200", # 200 chars
45 "$work94/$x49/${x50}xxx201", # 201 chars
46 "$work94/$x60/${x95}254", # 254 chars
47 "$work94/$x60/${x95}x255", # 255 chars
50 my @l = map { length } @paths;
53 create_file $_ for @paths;
54 system "pax -wf ustar.ok $work94";
55 ok($? == 0, "Wrote 'ustar.ok' containing files with lengths @l");
57 (my $orig = $top) =~ s,1$,2,;
61 system "pax -rf ustar.ok";
62 ok($? == 0, "Restored 'ustar.ok' containing files with lengths @l");
64 system "diff -ru $orig $top";
65 ok($? == 0, "Restored files are identical");
70 # 256 chars (with components < 100 chars) should not work
71 push @paths, "$work94/x$x60/${x95}x256"; # 256 chars
72 push @l, length $paths[-1];
73 create_file $paths[-1];
74 system "pax -wf ustar.fail1 $work94";
75 ok($?, "Failed to write 'ustar.fail1' containing files with lengths @l");
77 # Components with 100 chars shouldn't work
79 $paths[-1] = "$work94/${x95}xc100"; # 100 char filename
80 $l[-1] = length $paths[-1];
81 create_file $paths[-1];
82 system "pax -wf ustar.fail2 $work94";
83 ok($?, "Failed to write 'ustar.fail2' with a 100 char filename");
86 $paths[-1] = "$work94/${x95}xc100/x"; # 100 char component
87 $l[-1] = length $paths[-1];
88 create_file $paths[-1];
89 system "pax -wf ustar.fail3 $work94";
90 ok($?, "Failed to write 'ustar.fail3' with a 100 char component");