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";
34 print $cmdfh "exit\n";
37 # Give test_driver time to finish
44 # Output the given command and make sure that the exit
45 # code for the command was valid
48 my ($cmdfh, $outfh, $cmd, $cmdstr) = @_;
56 print_and_exit($cmdfh, $outfh, 1, "ERROR! Cmd $cmdstr returned null value!\n");
59 if ($res ne "0000 ") {
60 print_and_exit($cmdfh, $outfh, 1, "ERROR! Command $cmd failed with code $res\n");
64 # Check the return value from the last libsysio call
68 my ($cmdfh, $outfh, $cmd) = @_;
70 # Verify the system call's output
71 my $cmdstr = 'PRINT $$';
73 send_cmd($cmdfh, $outfh, "PRINT", $cmdstr);
79 print_and_exit($cmdfh, $outfh, 1, "ERROR! Cmd $cmdstr returned null value!\n");
82 if ($res eq "0xffffffff") {
85 $cmdstr = 'PRINT $errno';
87 send_cmd($cmdfh, $outfh, "PRINT", $cmdstr);
93 print_and_exit($cmdfh, $outfh, 1, "ERROR! Cmd $cmdstr returned null value!\n");
96 print_and_exit($cmdfh, $outfh, 1, "ERROR! $cmd returned $err\n");
101 # Compares two numbers. Output error message and exit if
105 my ($cmdfh, $outfh, $ionum, $pnum, $desc) = @_;
108 if (!defined($ionum)) {
109 print_and_exit($cmdfh, $outfh, 1, "ERROR! ionum for $desc undefined");
110 } elsif (!defined($pnum)) {
111 print_and_exit($cmdfh, $outfh, 1, "ERROR! pnum for $desc undefined");
113 if ($ionum != $pnum) {
114 my $str = sprintf("ERROR! Sysio's number %x does not match Perl's (%x)\n",
116 $str = sprintf("%s Numbers were %s\n", $str, $desc);
117 print_and_exit($cmdfh, $outfh, 1, $str);
126 if (S_ISDIR($mode)) {
128 } elsif (S_ISCHR($mode)) {
130 } elsif (S_ISBLK($mode)) {
132 } elsif (S_ISREG($mode)) {
134 } elsif (S_ISFIFO($mode)) {
136 } elsif (S_ISLNK($mode)) {
138 } elsif (S_ISSOCK($mode)) {