diff options
author | Nathan Scott <nathans@sgi.com> | 2002-02-25 22:10:22 +0000 |
---|---|---|
committer | Nathan Scott <nathans@sgi.com> | 2002-02-25 22:10:22 +0000 |
commit | c82edc1013cf28a096cb8f5ba21c28d3e9312227 (patch) | |
tree | 5a2c12886725666beddf1aaf8cdf20e474359ebc /test | |
parent | a87485aca58ea2236b31b0c0b8e438b3d967709b (diff) | |
download | attr-c82edc1013cf28a096cb8f5ba21c28d3e9312227.tar.gz |
Merge of xfs-cmds-2.4.18:slinx:111138a by nathans.
bump to version 2.0.0 for extended attribute and other interface changes.
incorporate new code, docs, etc from ext2/ext3 project.
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile | 44 | ||||
-rw-r--r-- | test/README | 9 | ||||
-rw-r--r-- | test/attr.test | 78 | ||||
-rw-r--r-- | test/run | 145 |
4 files changed, 276 insertions, 0 deletions
diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..bc1e326 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,44 @@ +# +# Copyright (c) 2001 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# Further, this software is distributed without any warranty that it is +# free of the rightful claim of any third person regarding infringement +# or the like. Any license provided herein, whether implied or +# otherwise, applies only to this software file. Patent licenses, if +# any, provided herein do not apply to combinations of this program with +# other software, or any other product whatsoever. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write the Free Software Foundation, Inc., 59 +# Temple Place - Suite 330, Boston MA 02111-1307, USA. +# +# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, +# Mountain View, CA 94043, or: +# +# http://www.sgi.com +# +# For further information regarding this notice, see: +# +# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ +# + +TOPDIR = .. +include $(TOPDIR)/include/builddefs + +# ensure we pick these up in the source tarball +LSRCFILES = attr.test run README + +default: + +include $(BUILDRULES) + +install: +install-dev: diff --git a/test/README b/test/README new file mode 100644 index 0000000..ab8f232 --- /dev/null +++ b/test/README @@ -0,0 +1,9 @@ + +Andreas Gruenbacher's tests for the ext2 filesystem extended attributes +support. Most of these tests should work for any filesystem type, and +most are actually used as part of the XFS test suite. However, those +tests relating to the exercising of boundary conditions of attribute +value lengths, etc, are specific to ext2. + + -- nathans@sgi.com + diff --git a/test/attr.test b/test/attr.test new file mode 100644 index 0000000..b1399e8 --- /dev/null +++ b/test/attr.test @@ -0,0 +1,78 @@ +! +! Tests for getting/setting extended file attributes with ext2/ext3 +! The initial size checks are ext2/ext3 specific, but the remainder +! should work for any extended attributes filesystem (eg. XFS). +! +$ mkdir attr-test +$ touch attr-test/f +! Maximum attribute size for 1024 byte blocks = 1024 - (20+20+4) = 980 +$ aset -n user.name -v 968+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ attr-test/f +! Attribute too big for 1024 byte blocks +$ aset -n user.name -v 969++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ attr-test/f +attr-test/f: No space left on device +$ aset -n user.name attr-test/f +$ aget -d attr-test/f +# file: attr-test/f +user.name + +$ aset -n user.name -v 0xbabe attr-test/f +$ aset -n user.name2 -v 0xdeadbeef attr-test/f +$ aset -n user.name3 -v 0xdeface attr-test/f +! +! +$ aget -d -e hex attr-test/f +# file: attr-test/f +user.name=0xbabe +user.name2=0xdeadbeef +user.name3=0xdeface + +$ aget -d -e base64 attr-test/f +# file: attr-test/f +user.name=0sur4= +user.name2=0s3q2+7w== +user.name3=0s3vrO + +! +! shrink value of existing attribute +! +$ aset -n user.name2 -v 0xdeaf attr-test/f +$ aget -d -e hex attr-test/f +# file: attr-test/f +user.name=0xbabe +user.name2=0xdeaf +user.name3=0xdeface + +! +! grow value of existing attribute +! +$ aset -n user.name2 -v 0xdecade attr-test/f +$ aget -d -e hex attr-test/f +# file: attr-test/f +user.name=0xbabe +user.name2=0xdecade +user.name3=0xdeface + +! +! empty value +! +$ aset -n user.name2 attr-test/f +$ aget -d -n user.name2 attr-test/f +# file: attr-test/f +user.name2 + +! +! overwrite empty value +! +$ aset -n user.name2 -v 0xcafe attr-test/f +$ aget -d -e hex -n user.name2 attr-test/f +# file: attr-test/f +user.name2=0xcafe + +! +! remove attribute +! +$ aset -x user.name2 attr-test/f +$ aget -d -n user.name2 attr-test/f +attr-test/f: user.name2: No such attribute +$ rm attr-test/f +$ rmdir attr-test diff --git a/test/run b/test/run new file mode 100644 index 0000000..b545a53 --- /dev/null +++ b/test/run @@ -0,0 +1,145 @@ +#!/usr/bin/perl + +use strict; +use FileHandle; +use POSIX qw(geteuid getegid isatty); + +my $owner = getpwuid(geteuid()); +my $group = getgrgid(getegid()); + +my ($OK, $FAILED) = ("ok", "failed"); +if (isatty(fileno(STDOUT))) { + $OK = "\033[32m" . $OK . "\033[m"; + $FAILED = "\033[31m\033[1m" . $FAILED . "\033[m"; +} + +my ($prog, $in, $out) = ([], [], []); +my $line = 0; +my $prog_line; +for (;;) { + my $script = <>; $line++; + $script =~ s/\@OWNER\@/$owner/g; + $script =~ s/\@GROUP\@/$group/g; + next if (defined($script) && $script =~ /^!/); + if (!defined($script) || $script =~ s/^\$ ?//) { + if (@$prog) { + #print "[$prog_line] \$ ", join(' ', @$prog), " -- "; + my $p = [ @$prog ]; + print "[$prog_line] \$ ", join(' ', + map { s/\s/\\$&/g; $_ } @$p), " -- "; + my $result = exec_test($prog, $in); + my $good = 1; + my $nmax = (@$out > @$result) ? @$out : @$result; + for (my $n=0; $n < $nmax; $n++) { + if (!defined($out->[$n]) || !defined($result->[$n]) || + $out->[$n] ne $result->[$n]) { + $good = 0; + #chomp $out->[$n]; + #chomp $result->[$n]; + #print "$out->[$n] != $result->[$n]"; + } + } + print $good ? $OK : $FAILED, "\n"; + if (!$good) { + for (my $n=0; $n < $nmax; $n++) { + my $l = defined($out->[$n]) ? $out->[$n] : "~"; + chomp $l; + my $r = defined($result->[$n]) ? $result->[$n] : "~"; + chomp $r; + print sprintf("%-37s | %-39s\n", $l, $r); + } + } + } + #$prog = [ split /\s+/, $script ] if $script; + $prog = [ map { s/\\(.)/$1/g; $_ } split /(?<!\\)\s+/, $script ] if $script; + $prog_line = $line; + $in = []; + $out = []; + } elsif ($script =~ s/^> ?//) { + push @$in, $script; + } else { + push @$out, $script; + } + last unless defined($script); +} + +sub exec_test($$) { + my ($prog, $in) = @_; + local (*IN, *IN_DUP, *IN2, *OUT_DUP, *OUT, *OUT2); + + if ($prog->[0] eq "umask") { + umask oct $prog->[1]; + return []; + } elsif ($prog->[0] eq "cd") { + if (!chdir $prog->[1]) { + return [ "chdir: $prog->[1]: $!\n" ]; + } + return []; + } + + pipe *IN2, *OUT + or die "Can't create pipe for reading: $!"; + open *IN_DUP, "<&STDIN" + or *IN_DUP = undef; + open *STDIN, "<&IN2" + or die "Can't duplicate pipe for reading: $!"; + close *IN2; + + open *OUT_DUP, ">&STDOUT" + or die "Can't duplicate STDOUT: $!"; + pipe *IN, *OUT2 + or die "Can't create pipe for writing: $!"; + open *STDOUT, ">&OUT2" + or die "Can't duplicate pipe for writing: $!"; + close *OUT2; + + *STDOUT->autoflush(); + *OUT->autoflush(); + + if (fork()) { + # Server + if (*IN_DUP) { + open *STDIN, "<&IN_DUP" + or die "Can't duplicate STDIN: $!"; + close *IN_DUP + or die "Can't close STDIN duplicate: $!"; + } + open *STDOUT, ">&OUT_DUP" + or die "Can't duplicate STDOUT: $!"; + close *OUT_DUP + or die "Can't close STDOUT duplicate: $!"; + + foreach my $line (@$in) { + #print "> $line"; + print OUT $line; + } + close *OUT + or die "Can't close pipe for writing: $!"; + + my $result = []; + while (<IN>) { + #print "< $_"; + push @$result, $_; + } + return $result; + } else { + # Client + close IN + or die "Can't close read end for input pipe: $!"; + close OUT + or die "Can't close write end for output pipe: $!"; + close OUT_DUP + or die "Can't close STDOUT duplicate: $!"; + local *ERR_DUP; + open ERR_DUP, ">&STDERR" + or die "Can't duplicate STDERR: $!"; + open STDERR, ">&STDOUT" + or die "Can't join STDOUT and STDERR: $!"; + + #print ERR_DUP "<", join(' ', @$prog), ">\n"; + exec @$prog; + print ERR_DUP $prog->[0], ": $!\n"; + exit; + } +} + |