4 # path test: reads paths from stdin and prints out the path along with its
12 use lib "$FindBin::Bin";
19 print "Usage ./test_path.pl [path1 path2...] : Print each path listed and its type\n";
20 print " : If no paths are given, stdin is read\n";
31 } elsif (S_ISCHR($mode)) {
33 } elsif (S_ISBLK($mode)) {
35 } elsif (S_ISREG($mode)) {
37 } elsif (S_ISFIFO($mode)) {
39 } elsif (S_ISLNK($mode)) {
41 } elsif (S_ISSOCK($mode)) {
50 my ($mode, $path) = @_;
52 my $typechar = get_type($mode);
53 print STDOUT "$path: $typechar\n";
58 my ($cmdfh, $outfh, $bits, $path) = @_;
60 # Issue the stat command
61 my $cmdstr = 'CALL stat "';
62 $cmdstr = sprintf("%s%s%s\n", $cmdstr, $path, '" $buf');
64 helper::send_cmd($cmdfh, $outfh, "stat", $cmdstr);
65 helper::verify_cmd($cmdfh, $outfh, "stat");
67 # Print out the stat buffer
69 $cmdstr = 'PRINT $buf 0 8 LONG 12 24 INT 44 8 LONG 52 8 INT 64 24 LONG';
71 $cmdstr = 'PRINT $buf 0 24 LONG 24 16 INT 48 32 LONG 88 8 LONG 104 8 LONG';
74 helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr);
78 my ( $iodev, $ioino, $iomode, $ionlink, $iouid, $iogid, $iordev,
79 $iosize, $ioblksize, $ioblks, $ioatime, $iomtime, $ioctime )
82 ( $iodev, $ioino, $ionlink, $iomode, $iouid, $iogid, $iordev,
83 $iosize, $ioblksize, $ioblks, $ioatime, $iomtime, $ioctime )
86 $iomode = oct($iomode);
89 print_path($iomode, $path);
94 my ($usestdin, $isalpha, @paths) = @_;
99 my $testdir = $FindBin::Bin;
103 open2(\*OUTFILE, \*CMDFILE, "$testdir/test_driver --np");
105 open2(\*OUTFILE, \*CMDFILE,
106 "yod -batch -quiet -sz 1 $testdir/test_driver --np");
111 if ($@ =~ /^open2/) {
112 warn "open2 failed: $!\n$@\n";
118 my $outfh = \*OUTFILE;
119 my $cmdfh = \*CMDFILE;
122 helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n");
125 # Allocate the stat buffer
126 my $cmdstr = '$buf = ALLOC ( $size = CALL sizeof stat )';
128 helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr);
130 # Attempt to determine type
131 $cmdstr = 'PRINT $size'."\n";
132 helper::send_cmd($cmdfh, $outfh, "print", $cmdstr);
133 my $statsize = <$outfh>;
135 $statsize = oct($statsize);
137 if ($statsize == 144) {
144 if (defined($path)) {
148 $path = $paths[$i++];
151 # Enter a loop, reading a path argument and processing it with each
153 while (defined($path)) {
155 process_path($cmdfh, $outfh, $bits, $path);
159 if (defined($path)) {
162 if ($path eq "quit") {
163 helper::print_and_exit($cmdfh, $outfh, 0, "path test successful\n");
166 $path = $paths[$i++];
169 helper::print_and_exit($cmdfh, $outfh, 0, "path test successful\n");
176 # The -alpha arg must be before the paths
178 if ( (@ARGV > 0) && ($ARGV[0] eq "-alpha")) {
187 process_cmd($usestdin, $isalpha, @ARGV);