6 use Test::More tests => 6;
7 use File::Path qw(rmtree mkpath);
15 (my $dir = $fn) =~ s,/[^/]+$,,;
17 open my $fd, ">", $fn or die "$fn: $!";
18 print $fd "file $n\n";
22 ustar_pathnames: { SKIP: {
23 # Prove that pax breaks up ustar pathnames properly
25 my $top = getcwd . "/ustar-pathnames-1";
26 skip "Current path is too long", 6 if length $top > 92;
28 my $subdir = "x" . "x" x (92 - length $top);
29 my $work94 = "$top/$subdir";
30 mkpath $work94; # $work is 94 characters long
38 "$work94/x099", # 99 chars
39 "$work94/xx100", # 100 chars
40 "$work94/xxx101", # 101 chars
41 "$work94/$x49/${x50}x199", # 199 chars
42 "$work94/$x49/${x50}xx200", # 200 chars
43 "$work94/$x49/${x50}xxx201", # 201 chars
44 "$work94/$x60/${x95}254", # 254 chars
45 "$work94/$x60/${x95}x255", # 255 chars
48 my @l = map { length } @paths;
51 create_file $_ for @paths;
52 system "pax -wf ustar.ok $work94";
53 ok($? == 0, "Wrote 'ustar.ok' containing files with lengths @l");
55 (my $orig = $top) =~ s,1$,2,;
59 system "pax -rf ustar.ok";
60 ok($? == 0, "Restored 'ustar.ok' containing files with lengths @l");
62 system "diff -ru $orig $top";
63 ok($? == 0, "Restored files are identical");
68 # 256 chars (with components < 100 chars) should not work
69 push @paths, "$work94/x$x60/${x95}x256"; # 256 chars
70 push @l, length $paths[-1];
71 create_file $paths[-1];
72 system "pax -wf ustar.fail1 $work94";
73 ok($?, "Failed to write 'ustar.fail1' containing files with lengths @l");
75 # Components with 100 chars shouldn't work
77 $paths[-1] = "$work94/${x95}xc100"; # 100 char filename
78 $l[-1] = length $paths[-1];
79 create_file $paths[-1];
80 system "pax -wf ustar.fail2 $work94";
81 ok($?, "Failed to write 'ustar.fail2' with a 100 char filename");
84 $paths[-1] = "$work94/${x95}xc100/x"; # 100 char component
85 $l[-1] = length $paths[-1];
86 create_file $paths[-1];
87 system "pax -wf ustar.fail3 $work94";
88 ok($?, "Failed to write 'ustar.fail3' with a 100 char component");