4 # Provides a set of helper routines for use in the Perl
14 # Print out a given error message, close the command file
18 my ($cmdfh, $outfh, $exit_num, $exit_str) = @_;
20 print STDOUT "$exit_str";
23 my $cmdstr = 'FREE $buf';
24 $cmdstr = $cmdstr."\n";
31 print $cmdfh "exit\n";
34 # Give test_driver time to finish
41 # Output the given command and make sure that the exit
42 # code for the command was valid
45 my ($cmdfh, $outfh, $cmd, $cmdstr) = @_;
51 if ($res ne "0000 ") {
52 print_and_exit($cmdfh, $outfh, 1, "ERROR! Command $cmd failed with code $res\n");
56 # Check the return value from the last libsysio call
60 my ($cmdfh, $outfh, $cmd) = @_;
62 # Verify the system call's output
63 my $cmdstr = 'PRINT $$';
65 send_cmd($cmdfh, $outfh, "PRINT", $cmdstr);
70 if ($res eq "0xffffffff") {
73 $cmdstr = 'PRINT $errno';
75 send_cmd($cmdfh, $outfh, "PRINT", $cmdstr);
79 print_and_exit($cmdfh, $outfh, 1, "ERROR! $cmd returned $err\n");
84 # Compares two numbers. Output error message and exit if
88 my ($cmdfh, $outfh, $ionum, $pnum, $desc) = @_;
91 if (!defined($ionum)) {
92 print_and_exit($cmdfh, $outfh, 1, "ERROR! ionum for $desc undefined");
93 } elsif (!defined($pnum)) {
94 print_and_exit($cmdfh, $outfh, 1, "ERROR! pnum for $desc undefined");
96 if ($ionum != $pnum) {
97 my $str = sprintf("ERROR! Sysio's number %x does not match Perl's (%x)\n",
99 $str = sprintf("%s Numbers were %s\n", $str, $desc);
100 print_and_exit($cmdfh, $outfh, 1, $str);
109 if (S_ISDIR($mode)) {
111 } elsif (S_ISCHR($mode)) {
113 } elsif (S_ISBLK($mode)) {
115 } elsif (S_ISREG($mode)) {
117 } elsif (S_ISFIFO($mode)) {
119 } elsif (S_ISLNK($mode)) {
121 } elsif (S_ISSOCK($mode)) {