From: Richard D. <ric...@us...> - 2007-07-05 08:36:37
|
Update of /cvsroot/file-extattr/File-ExtAttr/t In directory sc8-pr-cvs17:/tmp/cvs-serv29896/t Modified Files: 11basic.t 13long.t 14optional.t 15create.t 16replace.t 17createreplace.t 18list.t 20tie-basic.t 22tie-nonuser.t 30nsbasic.t 31nsmultiple.t 32nsnonuser.t 33nslong.t 39nsempty.t Log Message: Add test cases for setting attributes on directories, by filename. Index: 14optional.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/14optional.t,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** 14optional.t 6 May 2007 09:56:40 -0000 1.5 --- 14optional.t 5 Jul 2007 08:36:34 -0000 1.6 *************** *** 21,28 **** plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 4; } use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); --- 21,29 ---- plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 8; } use File::Temp qw(tempfile); + use File::Path; use File::ExtAttr qw(setfattr getfattr delfattr); *************** *** 31,36 **** close $fh || die "can't close $filename $!"; ! ! print "# using $filename\n"; #todo: try wierd characters in here? --- 32,41 ---- close $fh || die "can't close $filename $!"; ! # Create a directory. ! my $dirname = "$filename.dir"; ! eval { mkpath($dirname); }; ! if ($@) { ! warn "Couldn't create $dirname: $@"; ! } #todo: try wierd characters in here? *************** *** 39,61 **** my $val = "ZZZadlf03948alsdjfaslfjaoweir12l34kealfkjalskdfas90d8fajdlfkj./.,f"; #for (1..30000) { #checking memory leaks ! #will die if xattr stuff doesn't work at all ! setfattr($filename, "$key", $val) || die "setfattr failed on $filename: $!"; ! #set it ! is (setfattr($filename, "$key", $val), 1); ! #read it back ! is (getfattr($filename, "$key"), $val); ! #delete it ! ok (delfattr($filename, "$key")); ! #check that it's gone ! is (getfattr($filename, "$key"), undef); #} ! #print STDERR "done\n"; ! #<STDIN>; ! END {unlink $filename if $filename}; --- 44,71 ---- my $val = "ZZZadlf03948alsdjfaslfjaoweir12l34kealfkjalskdfas90d8fajdlfkj./.,f"; + foreach ( $filename, $dirname ) { + print "# using $_\n"; + #for (1..30000) { #checking memory leaks ! #will die if xattr stuff doesn't work at all ! setfattr($_, "$key", $val) || die "setfattr failed on $_: $!"; ! #set it ! is (setfattr($_, "$key", $val), 1); ! #read it back ! is (getfattr($_, "$key"), $val); ! #delete it ! ok (delfattr($_, "$key")); ! #check that it's gone ! is (getfattr($_, "$key"), undef); #} ! } ! END { ! unlink $filename if $filename; ! rmdir $dirname if $dirname; ! }; Index: 33nslong.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/33nslong.t,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** 33nslong.t 6 May 2007 09:56:40 -0000 1.3 --- 33nslong.t 5 Jul 2007 08:36:35 -0000 1.4 *************** *** 24,31 **** plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 16; } use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); use IO::File; --- 24,32 ---- plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 24; } use File::Temp qw(tempfile); + use File::Path; use File::ExtAttr qw(setfattr getfattr delfattr); use IO::File; *************** *** 35,38 **** --- 36,46 ---- close $fh || die "can't close $filename $!"; + # Create a directory. + my $dirname = "$filename.dir"; + eval { mkpath($dirname); }; + if ($@) { + warn "Couldn't create $dirname: $@"; + } + #todo: try wierd characters in here? # try unicode? *************** *** 45,49 **** ########################## ! print "# using $filename\n"; #for (1..30000) { #checking memory leaks --- 53,58 ---- ########################## ! foreach ( $filename, $dirname ) { ! print "# using $_\n"; #for (1..30000) { #checking memory leaks *************** *** 52,85 **** #on my /var partition, and 920 is the biggest for my loopback partition. #What's up with that? ! #setfattr($filename, "$key-2", ('x' x 3991)) || die "setfattr failed on $filename: $!"; ! setfattr($filename, "$key", $longval, { namespace => 'user' }) ! || die "setfattr failed on $filename: $!"; ! #set it ! is (setfattr($filename, "$key", $longval, { namespace => 'user' }), 1); ! #read it back ! is (getfattr($filename, "$key", { namespace => 'user' }), $longval); ! #delete it ! ok (delfattr($filename, "$key", { namespace => 'user' })); ! #check that it's gone ! is (getfattr($filename, "$key", { namespace => 'user' }), undef); ! #set it ! is (setfattr($filename, "$key", $longval2, { namespace => 'user' }), 1); ! #read it back ! is (getfattr($filename, "$key", { namespace => 'user' }), $longval2); ! #delete it ! ok (delfattr($filename, "$key", { namespace => 'user' })); ! #check that it's gone ! is (getfattr($filename, "$key", { namespace => 'user' }), undef); #} ! #print STDERR "done\n"; ! #<STDIN>; ########################## --- 61,93 ---- #on my /var partition, and 920 is the biggest for my loopback partition. #What's up with that? ! #setfattr($_, "$key-2", ('x' x 3991)) || die "setfattr failed on $_: $!"; ! setfattr($_, "$key", $longval, { namespace => 'user' }) ! || die "setfattr failed on $_: $!"; ! #set it ! is (setfattr($_, "$key", $longval, { namespace => 'user' }), 1); ! #read it back ! is (getfattr($_, "$key", { namespace => 'user' }), $longval); ! #delete it ! ok (delfattr($_, "$key", { namespace => 'user' })); ! #check that it's gone ! is (getfattr($_, "$key", { namespace => 'user' }), undef); ! #set it ! is (setfattr($_, "$key", $longval2, { namespace => 'user' }), 1); ! #read it back ! is (getfattr($_, "$key", { namespace => 'user' }), $longval2); ! #delete it ! ok (delfattr($_, "$key", { namespace => 'user' })); ! #check that it's gone ! is (getfattr($_, "$key", { namespace => 'user' }), undef); #} ! } ########################## *************** *** 127,129 **** #<STDIN>; ! END {unlink $filename if $filename}; --- 135,140 ---- #<STDIN>; ! END { ! unlink $filename if $filename; ! rmdir $dirname if $dirname; ! }; Index: 15create.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/15create.t,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** 15create.t 6 May 2007 09:56:40 -0000 1.4 --- 15create.t 5 Jul 2007 08:36:34 -0000 1.5 *************** *** 21,28 **** plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 10; } use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); use IO::File; --- 21,29 ---- plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 15; } use File::Temp qw(tempfile); + use File::Path; use File::ExtAttr qw(setfattr getfattr delfattr); use IO::File; *************** *** 33,36 **** --- 34,44 ---- close $fh || die "can't close $filename $!"; + # Create a directory. + my $dirname = "$filename.dir"; + eval { mkpath($dirname); }; + if ($@) { + warn "Couldn't create $dirname: $@"; + } + #todo: try wierd characters in here? # try unicode? *************** *** 42,61 **** ########################## ! print "# using $filename\n"; ! #create it ! is (setfattr($filename, "$key", $val, { create => 1 }), 1); ! #create it again -- should fail ! is (setfattr($filename, "$key", $val, { create => 1 }), 0); ! #read it back ! is (getfattr($filename, "$key"), $val); ! #delete it ! ok (delfattr($filename, "$key")); ! #check that it's gone ! is (getfattr($filename, "$key"), undef); ########################## --- 50,71 ---- ########################## ! foreach ( $filename, $dirname ) { ! print "# using $_\n"; ! #create it ! is (setfattr($_, "$key", $val, { create => 1 }), 1); ! #create it again -- should fail ! is (setfattr($_, "$key", $val, { create => 1 }), 0); ! #read it back ! is (getfattr($_, "$key"), $val); ! #delete it ! ok (delfattr($_, "$key")); ! #check that it's gone ! is (getfattr($_, "$key"), undef); ! } ########################## *************** *** 82,84 **** is (getfattr($fh, "$key"), undef); ! END {unlink $filename if $filename}; --- 92,97 ---- is (getfattr($fh, "$key"), undef); ! END { ! unlink $filename if $filename; ! rmdir $dirname if $dirname; ! }; Index: 31nsmultiple.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/31nsmultiple.t,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** 31nsmultiple.t 6 May 2007 09:56:40 -0000 1.3 --- 31nsmultiple.t 5 Jul 2007 08:36:35 -0000 1.4 *************** *** 21,28 **** plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 26; } use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr listfattrns); use IO::File; --- 21,29 ---- plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 40; } use File::Temp qw(tempfile); + use File::Path; use File::ExtAttr qw(setfattr getfattr delfattr listfattrns); use IO::File; *************** *** 33,36 **** --- 34,44 ---- close $fh || die "can't close $filename $!"; + # Create a directory. + my $dirname = "$filename.dir"; + eval { mkpath($dirname); }; + if ($@) { + warn "Couldn't create $dirname: $@"; + } + #todo: try wierd characters in here? # try unicode? *************** *** 47,96 **** ########################## ! print "# using $filename\n"; #for (1..30000) { #checking memory leaks #will die if xattr stuff doesn't work at all ! setfattr($filename, "$key", $val, { namespace => 'user' }) ! || die "setfattr failed on filename $filename: $!"; #set it ! is (setfattr($filename, "$key", $val, { namespace => 'user' }), 1); #read it back ! is (getfattr($filename, "$key", { namespace => 'user' }), $val); #set another ! is (setfattr($filename, "$key2", $val, { namespace => 'user' }), 1); #read it back ! is (getfattr($filename, "$key2", { namespace => 'user' }), $val); #set yet another ! is (setfattr($filename, "$key3", $val, { namespace => 'user' }), 1); #read it back ! is (getfattr($filename, "$key3", { namespace => 'user' }), $val); #check user namespace exists now ! @ns = listfattrns($filename); is (grep(/^user$/, @ns), 1); #delete them ! ok (delfattr($filename, "$key", { namespace => 'user' })); ! ok (delfattr($filename, "$key2", { namespace => 'user' })); ! ok (delfattr($filename, "$key3", { namespace => 'user' })); #check that they're gone ! is (getfattr($filename, "$key", { namespace => 'user' }), undef); ! is (getfattr($filename, "$key2", { namespace => 'user' }), undef); ! is (getfattr($filename, "$key3", { namespace => 'user' }), undef); #check user namespace doesn't exist now ! @ns = listfattrns($filename); is (grep(/^user$/, @ns), 0); #} ! #print STDERR "done\n"; ! #<STDIN>; ########################## --- 55,104 ---- ########################## ! foreach ( $filename, $dirname ) { ! print "# using $_\n"; #for (1..30000) { #checking memory leaks #will die if xattr stuff doesn't work at all ! setfattr($_, "$key", $val, { namespace => 'user' }) ! || die "setfattr failed on filename $_: $!"; #set it ! is (setfattr($_, "$key", $val, { namespace => 'user' }), 1); #read it back ! is (getfattr($_, "$key", { namespace => 'user' }), $val); #set another ! is (setfattr($_, "$key2", $val, { namespace => 'user' }), 1); #read it back ! is (getfattr($_, "$key2", { namespace => 'user' }), $val); #set yet another ! is (setfattr($_, "$key3", $val, { namespace => 'user' }), 1); #read it back ! is (getfattr($_, "$key3", { namespace => 'user' }), $val); #check user namespace exists now ! @ns = listfattrns($_); is (grep(/^user$/, @ns), 1); #delete them ! ok (delfattr($_, "$key", { namespace => 'user' })); ! ok (delfattr($_, "$key2", { namespace => 'user' })); ! ok (delfattr($_, "$key3", { namespace => 'user' })); #check that they're gone ! is (getfattr($_, "$key", { namespace => 'user' }), undef); ! is (getfattr($_, "$key2", { namespace => 'user' }), undef); ! is (getfattr($_, "$key3", { namespace => 'user' }), undef); #check user namespace doesn't exist now ! @ns = listfattrns($_); is (grep(/^user$/, @ns), 0); #} ! } ########################## *************** *** 145,147 **** #<STDIN>; ! END {unlink $filename if $filename}; --- 153,158 ---- #<STDIN>; ! END { ! unlink $filename if $filename; ! rmdir $dirname if $dirname; ! }; Index: 30nsbasic.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/30nsbasic.t,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** 30nsbasic.t 6 May 2007 09:56:40 -0000 1.5 --- 30nsbasic.t 5 Jul 2007 08:36:35 -0000 1.6 *************** *** 21,28 **** plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 12; } use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr listfattrns); use IO::File; --- 21,29 ---- plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 18; } use File::Temp qw(tempfile); + use File::Path; use File::ExtAttr qw(setfattr getfattr delfattr listfattrns); use IO::File; *************** *** 33,36 **** --- 34,44 ---- close $fh || die "can't close $filename $!"; + # Create a directory. + my $dirname = "$filename.dir"; + eval { mkpath($dirname); }; + if ($@) { + warn "Couldn't create $dirname: $@"; + } + #todo: try wierd characters in here? # try unicode? *************** *** 44,78 **** ########################## ! print "# using $filename\n"; #for (1..30000) { #checking memory leaks #will die if xattr stuff doesn't work at all ! setfattr($filename, "$key", $val, { namespace => 'user' }) ! || die "setfattr failed on filename $filename: $!"; #set it ! is (setfattr($filename, "$key", $val, { namespace => 'user' }), 1); #check user namespace exists now ! @ns = listfattrns($filename); is (grep(/^user$/, @ns), 1); print '# '.join(' ', @ns)."\n"; #read it back ! is (getfattr($filename, "$key", { namespace => 'user' }), $val); #delete it ! ok (delfattr($filename, "$key", { namespace => 'user' })); #check that it's gone ! is (getfattr($filename, "$key", { namespace => 'user' }), undef); #check user namespace doesn't exist now ! @ns = listfattrns($filename); is (grep(/^user$/, @ns), 0); #} ! #print STDERR "done\n"; ! #<STDIN>; ########################## --- 52,86 ---- ########################## ! foreach ( $filename, $dirname ) { ! print "# using $_\n"; #for (1..30000) { #checking memory leaks #will die if xattr stuff doesn't work at all ! setfattr($_, "$key", $val, { namespace => 'user' }) ! || die "setfattr failed on filename $_: $!"; #set it ! is (setfattr($_, "$key", $val, { namespace => 'user' }), 1); #check user namespace exists now ! @ns = listfattrns($_); is (grep(/^user$/, @ns), 1); print '# '.join(' ', @ns)."\n"; #read it back ! is (getfattr($_, "$key", { namespace => 'user' }), $val); #delete it ! ok (delfattr($_, "$key", { namespace => 'user' })); #check that it's gone ! is (getfattr($_, "$key", { namespace => 'user' }), undef); #check user namespace doesn't exist now ! @ns = listfattrns($_); is (grep(/^user$/, @ns), 0); #} ! } ########################## *************** *** 114,116 **** #<STDIN>; ! END {unlink $filename if $filename}; --- 122,127 ---- #<STDIN>; ! END { ! unlink $filename if $filename; ! rmdir $dirname if $dirname; ! }; Index: 13long.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/13long.t,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** 13long.t 6 May 2007 09:56:40 -0000 1.6 --- 13long.t 5 Jul 2007 08:36:34 -0000 1.7 *************** *** 24,31 **** plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 16; } use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); use IO::File; --- 24,32 ---- plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 24; } use File::Temp qw(tempfile); + use File::Path; use File::ExtAttr qw(setfattr getfattr delfattr); use IO::File; *************** *** 35,38 **** --- 36,46 ---- close $fh || die "can't close $filename $!"; + # Create a directory. + my $dirname = "$filename.dir"; + eval { mkpath($dirname); }; + if ($@) { + warn "Couldn't create $dirname: $@"; + } + #todo: try wierd characters in here? # try unicode? *************** *** 45,85 **** ########################## ! print "# using $filename\n"; #for (1..30000) { #checking memory leaks ! #check a really big one, bigger than $File::ExtAttr::MAX_INITIAL_VALUELEN ! #Hmmm, 3991 is the biggest number that doesn't generate "no space left on device" ! #on my /var partition, and 920 is the biggest for my loopback partition. ! #What's up with that? ! #setfattr($filename, "$key-2", ('x' x 3991)) || die "setfattr failed on $filename: $!"; ! setfattr($filename, "$key", $longval) ! || die "setfattr failed on $filename: $!"; ! #set it ! is (setfattr($filename, "$key", $longval), 1); ! #read it back ! is (getfattr($filename, "$key"), $longval); ! #delete it ! ok (delfattr($filename, "$key")); ! #check that it's gone ! is (getfattr($filename, "$key"), undef); ! #set it ! is (setfattr($filename, "$key", $longval2), 1); ! #read it back ! is (getfattr($filename, "$key"), $longval2); ! #delete it ! ok (delfattr($filename, "$key")); ! #check that it's gone ! is (getfattr($filename, "$key"), undef); #} ! #print STDERR "done\n"; ! #<STDIN>; ########################## --- 53,92 ---- ########################## ! foreach ( $filename, $dirname ) { ! print "# using $_\n"; #for (1..30000) { #checking memory leaks ! #check a really big one, bigger than $File::ExtAttr::MAX_INITIAL_VALUELEN ! #Hmmm, 3991 is the biggest number that doesn't generate "no space left on device" ! #on my /var partition, and 920 is the biggest for my loopback partition. ! #What's up with that? ! #setfattr($_, "$key-2", ('x' x 3991)) || die "setfattr failed on $_: $!"; ! setfattr($_, "$key", $longval) || die "setfattr failed on $_: $!"; ! #set it ! is (setfattr($_, "$key", $longval), 1); ! #read it back ! is (getfattr($_, "$key"), $longval); ! #delete it ! ok (delfattr($_, "$key")); ! #check that it's gone ! is (getfattr($_, "$key"), undef); ! #set it ! is (setfattr($_, "$key", $longval2), 1); ! #read it back ! is (getfattr($_, "$key"), $longval2); ! #delete it ! ok (delfattr($_, "$key")); ! #check that it's gone ! is (getfattr($_, "$key"), undef); #} ! } ########################## *************** *** 127,129 **** #<STDIN>; ! END {unlink $filename if $filename}; --- 134,141 ---- #<STDIN>; ! # todo: Add support for IO::Dir handles, and test here. ! ! END { ! unlink $filename if $filename; ! rmdir $dirname if $dirname; ! }; Index: 20tie-basic.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/20tie-basic.t,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** 20tie-basic.t 6 May 2007 09:56:40 -0000 1.8 --- 20tie-basic.t 5 Jul 2007 08:36:35 -0000 1.9 *************** *** 14,21 **** plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 12; } use File::Temp qw(tempfile); use File::ExtAttr::Tie; use File::ExtAttr qw(getfattr); --- 14,22 ---- plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 24; } use File::Temp qw(tempfile); + use File::Path; use File::ExtAttr::Tie; use File::ExtAttr qw(getfattr); *************** *** 26,77 **** close $fh || die "can't close $filename $!"; ! my %extattr; ! my @ks; ! tie %extattr, 'File::ExtAttr::Tie', $filename; # ok()? ! # Check there are no user extattrs. ! @ks = keys(%extattr); ! ok(scalar(@ks) == 0); ! # Test multiple attributes. ! my %test_attrs = ( 'foo' => '123', 'bar' => '456' ); ! my $k; ! foreach $k (sort(keys(%test_attrs))) ! { ! my $v = $test_attrs{$k}; ! # Check that creation works. ! $extattr{$k} = $v; ! is(getfattr($filename, "$k"), $v); ! # Check that updating works. ! $extattr{$k} = "$v$v"; ! is(getfattr($filename, "$k"), "$v$v"); ! $extattr{$k} = $v; ! is(getfattr($filename, "$k"), $v); ! # Check that deletion works. ! delete $extattr{$k}; ! is(getfattr($filename, "$k"), undef); ! } ! # Recreate the keys and check that they're all in the hash. ! foreach $k (sort(keys(%test_attrs))) ! { ! my $v = $test_attrs{$k}; ! # Check that creation works. ! $extattr{$k} = $v; ! is(getfattr($filename, "$k"), $v); ! } ! # Check there are only our extattrs. ! @ks = keys(%extattr); ! ok(scalar(@ks) == scalar(keys(%test_attrs))); ! print '# '.join(' ', @ks)."\n"; ! END {unlink $filename if $filename}; --- 27,92 ---- close $fh || die "can't close $filename $!"; ! # Create a directory. ! my $dirname = "$filename.dir"; ! eval { mkpath($dirname); }; ! if ($@) { ! warn "Couldn't create $dirname: $@"; ! } ! foreach ( $filename, $dirname ) { ! print "# using $_\n"; ! my %extattr; ! my @ks; ! tie %extattr, 'File::ExtAttr::Tie', $_; # ok()? ! # Check there are no user extattrs. ! @ks = keys(%extattr); ! ok(scalar(@ks) == 0); ! # Test multiple attributes. ! my %test_attrs = ( 'foo' => '123', 'bar' => '456' ); ! my $k; ! foreach $k (sort(keys(%test_attrs))) ! { ! my $v = $test_attrs{$k}; ! # Check that creation works. ! $extattr{$k} = $v; ! is(getfattr($_, "$k"), $v); ! # Check that updating works. ! $extattr{$k} = "$v$v"; ! is(getfattr($_, "$k"), "$v$v"); ! $extattr{$k} = $v; ! is(getfattr($_, "$k"), $v); ! # Check that deletion works. ! delete $extattr{$k}; ! is(getfattr($_, "$k"), undef); ! } ! # Recreate the keys and check that they're all in the hash. ! foreach $k (sort(keys(%test_attrs))) ! { ! my $v = $test_attrs{$k}; ! # Check that creation works. ! $extattr{$k} = $v; ! is(getfattr($_, "$k"), $v); ! } ! ! # Check there are only our extattrs. ! @ks = keys(%extattr); ! ok(scalar(@ks) == scalar(keys(%test_attrs))); ! print '# '.join(' ', @ks)."\n"; ! } ! ! END { ! unlink $filename if $filename; ! rmdir $dirname if $dirname; ! }; Index: 39nsempty.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/39nsempty.t,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** 39nsempty.t 6 May 2007 09:56:40 -0000 1.3 --- 39nsempty.t 5 Jul 2007 08:36:35 -0000 1.4 *************** *** 21,28 **** plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 8; } use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); use IO::File; --- 21,29 ---- plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 12; } use File::Temp qw(tempfile); + use File::Path; use File::ExtAttr qw(setfattr getfattr delfattr); use IO::File; *************** *** 33,36 **** --- 34,44 ---- close $fh || die "can't close $filename $!"; + # Create a directory. + my $dirname = "$filename.dir"; + eval { mkpath($dirname); }; + if ($@) { + warn "Couldn't create $dirname: $@"; + } + #todo: try wierd characters in here? # try unicode? *************** *** 42,60 **** ########################## ! print "# using $filename\n"; ! #set it - should fail ! undef $@; ! eval { setfattr($filename, "$key", $val, { namespace => '' }); }; ! isnt ($@, undef); ! #read it back - should be missing ! is (getfattr($filename, "$key", { namespace => '' }), undef); ! #delete it - should fail ! is (delfattr($filename, "$key", { namespace => '' }), 0); ! #check that it's gone ! is (getfattr($filename, "$key", { namespace => '' }), undef); ########################## --- 50,70 ---- ########################## ! foreach ( $filename, $dirname ) { ! print "# using $_\n"; ! #set it - should fail ! undef $@; ! eval { setfattr($_, "$key", $val, { namespace => '' }); }; ! isnt ($@, undef); ! #read it back - should be missing ! is (getfattr($_, "$key", { namespace => '' }), undef); ! #delete it - should fail ! is (delfattr($_, "$key", { namespace => '' }), 0); ! #check that it's gone ! is (getfattr($_, "$key", { namespace => '' }), undef); ! } ########################## *************** *** 79,81 **** is (getfattr($fh->fileno(), "$key", { namespace => '' }), undef); ! END {unlink $filename if $filename}; --- 89,94 ---- is (getfattr($fh->fileno(), "$key", { namespace => '' }), undef); ! END { ! unlink $filename if $filename; ! rmdir $dirname if $dirname; ! }; Index: 22tie-nonuser.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/22tie-nonuser.t,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** 22tie-nonuser.t 4 Jul 2007 10:04:36 -0000 1.4 --- 22tie-nonuser.t 5 Jul 2007 08:36:35 -0000 1.5 *************** *** 15,22 **** plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 20; } use File::Temp qw(tempfile); use File::ExtAttr::Tie; use File::ExtAttr qw(getfattr); --- 15,23 ---- plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 40; } use File::Temp qw(tempfile); + use File::Path; use File::ExtAttr::Tie; use File::ExtAttr qw(getfattr); *************** *** 34,89 **** close $fh || die "can't close $filename $!"; ! my %extattr; ! my @ks; ! tie %extattr, 'File::ExtAttr::Tie', $filename, { namespace => 'nonuser' }; # ok()? ! # Check there are no user extattrs. ! @ks = keys(%extattr); ! ok(scalar(@ks) == 0); ! # Test multiple attributes. ! my %test_attrs = ( 'foo' => '123', 'bar' => '456' ); ! my $k; ! foreach $k (sort(keys(%test_attrs))) ! { ! my $v = $test_attrs{$k}; ! # Check that creation works. ! $extattr{$k} = $v; ! is ($warning =~ /(Operation not supported|No such file or directory|Attribute not found)/, 1); ! is(getfattr($filename, "$k"), undef); ! # Check that updating works. ! $extattr{$k} = "$v$v"; ! is ($warning =~ /(Operation not supported|No such file or directory|Attribute not found)/, 1); ! is(getfattr($filename, "$k"), undef); ! $extattr{$k} = $v; ! is ($warning =~ /(Operation not supported|No such file or directory|Attribute not found)/, 1); ! is(getfattr($filename, "$k"), undef); ! # Check that deletion works. ! delete $extattr{$k}; ! is(getfattr($filename, "$k"), undef); ! } ! # Recreate the keys and check that they're all in the hash. ! foreach $k (sort(keys(%test_attrs))) ! { ! my $v = $test_attrs{$k}; ! # Check that creation works. ! $extattr{$k} = $v; ! is ($warning =~ /(Operation not supported|No such file or directory|Attribute not found)/, 1); ! is(getfattr($filename, "$k"), undef); ! } ! # Check there are only our extattrs. ! @ks = keys(%extattr); ! ok(scalar(@ks) == 0); ! print '# '.join(' ', @ks)."\n"; ! END {unlink $filename if $filename}; --- 35,104 ---- close $fh || die "can't close $filename $!"; ! # Create a directory. ! my $dirname = "$filename.dir"; ! eval { mkpath($dirname); }; ! if ($@) { ! warn "Couldn't create $dirname: $@"; ! } ! foreach ( $filename, $dirname ) { ! print "# using $_\n"; ! my %extattr; ! my @ks; ! tie %extattr, 'File::ExtAttr::Tie', $_, { namespace => 'nonuser' }; # ok()? ! # Check there are no user extattrs. ! @ks = keys(%extattr); ! ok(scalar(@ks) == 0); ! # Test multiple attributes. ! my %test_attrs = ( 'foo' => '123', 'bar' => '456' ); ! my $k; ! foreach $k (sort(keys(%test_attrs))) ! { ! my $v = $test_attrs{$k}; ! # Check that creation works. ! $extattr{$k} = $v; ! is ($warning =~ /(Operation not supported|No such file or directory|Attribute not found)/, 1); ! is(getfattr($_, "$k"), undef); ! # Check that updating works. ! $extattr{$k} = "$v$v"; ! is ($warning =~ /(Operation not supported|No such file or directory|Attribute not found)/, 1); ! is(getfattr($_, "$k"), undef); ! $extattr{$k} = $v; ! is ($warning =~ /(Operation not supported|No such file or directory|Attribute not found)/, 1); ! is(getfattr($_, "$k"), undef); ! # Check that deletion works. ! delete $extattr{$k}; ! is(getfattr($_, "$k"), undef); ! } ! # Recreate the keys and check that they're all in the hash. ! foreach $k (sort(keys(%test_attrs))) ! { ! my $v = $test_attrs{$k}; ! # Check that creation works. ! $extattr{$k} = $v; ! is ($warning =~ /(Operation not supported|No such file or directory|Attribute not found)/, 1); ! is(getfattr($_, "$k"), undef); ! } ! ! # Check there are only our extattrs. ! @ks = keys(%extattr); ! ok(scalar(@ks) == 0); ! print '# '.join(' ', @ks)."\n"; ! } ! ! END { ! unlink $filename if $filename; ! rmdir $dirname if $dirname; ! }; Index: 11basic.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/11basic.t,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** 11basic.t 6 May 2007 09:56:40 -0000 1.6 --- 11basic.t 5 Jul 2007 08:36:34 -0000 1.7 *************** *** 21,28 **** plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 8; } use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); use IO::File; --- 21,29 ---- plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 12; } use File::Temp qw(tempfile); + use File::Path; use File::ExtAttr qw(setfattr getfattr delfattr); use IO::File; *************** *** 33,36 **** --- 34,44 ---- close $fh || die "can't close $filename $!"; + # Create a directory. + my $dirname = "$filename.dir"; + eval { mkpath($dirname); }; + if ($@) { + warn "Couldn't create $dirname: $@"; + } + #todo: try wierd characters in here? # try unicode? *************** *** 42,66 **** ########################## ! print "# using $filename\n"; #for (1..30000) { #checking memory leaks #will die if xattr stuff doesn't work at all ! setfattr($filename, "$key", $val) || die "setfattr failed on filename $filename: $!"; #set it ! is (setfattr($filename, "$key", $val), 1); #read it back ! is (getfattr($filename, "$key"), $val); #delete it ! ok (delfattr($filename, "$key")); #check that it's gone ! is (getfattr($filename, "$key"), undef); #} ! #print STDERR "done\n"; ! #<STDIN>; ########################## --- 50,75 ---- ########################## ! foreach ( $filename, $dirname ) { ! print "# using $_\n"; #for (1..30000) { #checking memory leaks #will die if xattr stuff doesn't work at all ! setfattr($_, "$key", $val) || die "setfattr failed on filename $_: $!"; #set it ! is (setfattr($_, "$key", $val), 1); #read it back ! is (getfattr($_, "$key"), $val); #delete it ! ok (delfattr($_, "$key")); #check that it's gone ! is (getfattr($_, "$key"), undef); ! #} ! } ########################## *************** *** 93,95 **** #<STDIN>; ! END {unlink $filename if $filename}; --- 102,109 ---- #<STDIN>; ! # todo: Add support for IO::Dir handles, and test here. ! ! END { ! unlink $filename if $filename; ! rmdir $dirname if $dirname; ! }; Index: 16replace.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/16replace.t,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** 16replace.t 6 May 2007 09:56:40 -0000 1.4 --- 16replace.t 5 Jul 2007 08:36:34 -0000 1.5 *************** *** 21,28 **** plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 10; } use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); use IO::File; --- 21,29 ---- plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 15; } use File::Temp qw(tempfile); + use File::Path; use File::ExtAttr qw(setfattr getfattr delfattr); use IO::File; *************** *** 33,36 **** --- 34,44 ---- close $fh || die "can't close $filename $!"; + # Create a directory. + my $dirname = "$filename.dir"; + eval { mkpath($dirname); }; + if ($@) { + warn "Couldn't create $dirname: $@"; + } + #todo: try wierd characters in here? # try unicode? *************** *** 42,61 **** ########################## ! print "# using $filename\n"; ! #create it ! is (setfattr($filename, "$key", $val, { create => 1 }), 1); ! #replace it ! is (setfattr($filename, "$key", $val, { replace => 1 }), 1); ! #read it back ! is (getfattr($filename, "$key"), $val); ! #delete it ! ok (delfattr($filename, "$key")); ! #check that it's gone ! is (getfattr($filename, "$key"), undef); ########################## --- 50,71 ---- ########################## ! foreach ( $filename, $dirname ) { ! print "# using $_\n"; ! #create it ! is (setfattr($_, "$key", $val, { create => 1 }), 1); ! #replace it ! is (setfattr($_, "$key", $val, { replace => 1 }), 1); ! #read it back ! is (getfattr($_, "$key"), $val); ! #delete it ! ok (delfattr($_, "$key")); ! #check that it's gone ! is (getfattr($_, "$key"), undef); ! } ########################## *************** *** 82,84 **** is (getfattr($fh, "$key"), undef); ! END {unlink $filename if $filename}; --- 92,97 ---- is (getfattr($fh, "$key"), undef); ! END { ! unlink $filename if $filename; ! rmdir $dirname if $dirname; ! }; Index: 17createreplace.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/17createreplace.t,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** 17createreplace.t 6 May 2007 09:56:40 -0000 1.4 --- 17createreplace.t 5 Jul 2007 08:36:34 -0000 1.5 *************** *** 21,28 **** plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 4; } use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); use IO::File; --- 21,29 ---- plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 6; } use File::Temp qw(tempfile); + use File::Path; use File::ExtAttr qw(setfattr getfattr delfattr); use IO::File; *************** *** 33,36 **** --- 34,44 ---- close $fh || die "can't close $filename $!"; + # Create a directory. + my $dirname = "$filename.dir"; + eval { mkpath($dirname); }; + if ($@) { + warn "Couldn't create $dirname: $@"; + } + #todo: try wierd characters in here? # try unicode? *************** *** 42,54 **** ########################## ! print "# using $filename\n"; ! #create and replace it -- should fail ! undef $@; ! eval { setfattr($filename, "$key", $val, { create => 1, replace => 1 }); }; ! isnt ($@, undef); ! #check that it's not been created ! is (getfattr($filename, "$key"), undef); ########################## --- 50,64 ---- ########################## ! foreach ( $filename, $dirname ) { ! print "# using $_\n"; ! #create and replace it -- should fail ! undef $@; ! eval { setfattr($_, "$key", $val, { create => 1, replace => 1 }); }; ! isnt ($@, undef); ! #check that it's not been created ! is (getfattr($_, "$key"), undef); ! } ########################## *************** *** 70,72 **** is (getfattr($fh, $key2), undef); ! END {unlink $filename if $filename}; --- 80,85 ---- is (getfattr($fh, $key2), undef); ! END { ! unlink $filename if $filename; ! rmdir $dirname if $dirname; ! }; Index: 32nsnonuser.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/32nsnonuser.t,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** 32nsnonuser.t 4 Jul 2007 10:04:36 -0000 1.6 --- 32nsnonuser.t 5 Jul 2007 08:36:35 -0000 1.7 *************** *** 19,26 **** plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 4; } use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); --- 19,27 ---- plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 8; } use File::Temp qw(tempfile); + use File::Path; use File::ExtAttr qw(setfattr getfattr delfattr); *************** *** 36,40 **** close $fh || die "can't close $filename $!"; ! print "# using $filename\n"; #todo: try wierd characters in here? --- 37,46 ---- close $fh || die "can't close $filename $!"; ! # Create a directory. ! my $dirname = "$filename.dir"; ! eval { mkpath($dirname); }; ! if ($@) { ! warn "Couldn't create $dirname: $@"; ! } #todo: try wierd characters in here? *************** *** 43,59 **** my $val = "ZZZadlf03948alsdjfaslfjaoweir12l34kealfkjalskdfas90d8fajdlfkj./.,f"; ! #set it ! setfattr($filename, "$key", $val, { namespace => 'nonuser' }); ! is ($warning =~ /(Operation not supported|No such file or directory|Attribute not found)/, 1); ! #read it back ! is (getfattr($filename, "$key", { namespace => 'nonuser' }), undef); ! #delete it ! delfattr($filename, "$key", { namespace => 'nonuser' }); ! is ($warning =~ /(Operation not supported|No such file or directory|Attribute not found)/, 1); ! #check that it's gone ! is (getfattr($filename, "$key", { namespace => 'nonuser' }), undef); ! END {unlink $filename if $filename}; --- 49,72 ---- my $val = "ZZZadlf03948alsdjfaslfjaoweir12l34kealfkjalskdfas90d8fajdlfkj./.,f"; ! foreach ( $filename, $dirname ) { ! print "# using $_\n"; ! #set it ! setfattr($_, "$key", $val, { namespace => 'nonuser' }); ! is ($warning =~ /(Operation not supported|No such file or directory|Attribute not found)/, 1); ! #read it back ! is (getfattr($_, "$key", { namespace => 'nonuser' }), undef); ! #delete it ! delfattr($_, "$key", { namespace => 'nonuser' }); ! is ($warning =~ /(Operation not supported|No such file or directory|Attribute not found)/, 1); ! #check that it's gone ! is (getfattr($_, "$key", { namespace => 'nonuser' }), undef); ! } ! ! END { ! unlink $filename if $filename; ! rmdir $dirname if $dirname; ! }; Index: 18list.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/18list.t,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** 18list.t 6 May 2007 09:56:40 -0000 1.3 --- 18list.t 5 Jul 2007 08:36:34 -0000 1.4 *************** *** 14,21 **** plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 122; } use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr listfattr); use IO::File; --- 14,22 ---- plan skip_all => 'Tests unsupported on this OS/filesystem'; } else { ! plan tests => 183; } use File::Temp qw(tempfile); + use File::Path; use File::ExtAttr qw(setfattr getfattr delfattr listfattr); use IO::File; *************** *** 26,29 **** --- 27,37 ---- close $fh || die "can't close $filename $!"; + # Create a directory. + my $dirname = "$filename.dir"; + eval { mkpath($dirname); }; + if ($@) { + warn "Couldn't create $dirname: $@"; + } + my %vals; for (my $i = 0; $i < 10; ++$i) *************** *** 36,68 **** ########################## ! print "# using $filename\n"; ! ! foreach (keys %vals) ! { ! # create it ! is (setfattr($filename, $_, $vals{$_}, { create => 1 }), 1); ! # create it again -- should fail ! is (setfattr($filename, $_, $vals{$_}, { create => 1 }), 0); ! # read it back ! is (getfattr($filename, $_), $vals{$_}); ! } ! # Check that the list contains all the attributes. ! my @attrs = listfattr($filename); ! @attrs = sort @attrs; ! my @ks = sort keys %vals; ! check_attrs(\@attrs, \@ks); ! # Clean up for next round of testing ! foreach (keys %vals) ! { ! # delete it ! ok (delfattr($filename, $_)); ! # check that it's gone ! is (getfattr($filename, $_), undef); } --- 44,78 ---- ########################## ! foreach ( $filename, $dirname ) { ! print "# using $_\n"; ! foreach my $k (keys %vals) ! { ! # create it ! is (setfattr($_, $k, $vals{$k}, { create => 1 }), 1); ! # create it again -- should fail ! is (setfattr($_, $k, $vals{$k}, { create => 1 }), 0); ! # read it back ! is (getfattr($_, $k), $vals{$k}); ! } ! ! # Check that the list contains all the attributes. ! my @attrs = listfattr($_); ! @attrs = sort @attrs; ! my @ks = sort keys %vals; ! check_attrs(\@attrs, \@ks); ! # Clean up for next round of testing ! foreach my $k (keys %vals) ! { ! # delete it ! ok (delfattr($_, $k)); ! # check that it's gone ! is (getfattr($_, $k), undef); ! } } *************** *** 88,94 **** # Check that the list contains all the attributes. ! @attrs = listfattr($fh); @attrs = sort @attrs; ! @ks = sort keys %vals; check_attrs(\@attrs, \@ks); --- 98,104 ---- # Check that the list contains all the attributes. ! my @attrs = listfattr($fh); @attrs = sort @attrs; ! my @ks = sort keys %vals; check_attrs(\@attrs, \@ks); *************** *** 104,108 **** } ! END {unlink $filename if $filename}; sub check_attrs --- 114,121 ---- } ! END { ! unlink $filename if $filename; ! rmdir $dirname if $dirname; ! }; sub check_attrs |