[Libsysio-commit] HEAD: libsysio/tests test_symlink.pl
Brought to you by:
lward
From: Sonja T. <so...@us...> - 2003-10-28 22:02:40
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv21250/tests Modified Files: test_symlink.pl Log Message: test_symlink didn't clean up after itself very well..fixed. Index: test_symlink.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_symlink.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -b -B -p -r1.1 -r1.2 --- test_symlink.pl 28 Oct 2003 21:00:39 -0000 1.1 +++ test_symlink.pl 28 Oct 2003 22:01:22 -0000 1.2 @@ -17,6 +17,42 @@ sub usage exit(-1); } +sub clean_exit +{ + my ($cmdfh, $outfh, $exit_num, $exit_str) = @_; + + print STDOUT "$exit_str"; + + # Free buffers + my $cmdstr = 'FREE $srcbuf'."\n"; + + print $cmdfh $cmdstr; + + my $res = <$outfh>; + chop($res); + if ($res ne "0000 ") { + print STDOUT "ERROR! Failed to free srcbuf (code $res)\n"; + } + + $cmdstr = 'FREE $destbuf'."\n"; + + print $cmdfh $cmdstr; + + $res = <$outfh>; + chop($res); + if ($res ne "0000 ") { + print STDOUT "ERROR! Failed to free destbuf (code $res)\n"; + } + + print $cmdfh "exit\n"; + close $outfh; + + # Give test_driver time to finish + sleep 0.000001; + + exit $exit_num; +} + sub process_cmd { my ($src, $dest, $is_alpha) = @_; @@ -98,9 +134,10 @@ sub process_cmd $res = helper::verify_cmd($cmdfh, $outfh, "read $dest"); + my $errstr; if ($readb != oct($res)) { - print STDOUT "ERROR! Read $readb bytes from src but only $res bytes from dest\n"; - exit 1; + $errstr = "ERROR! Read $readb bytes from src but only $res bytes from dest\n"; + clean_exit($cmdfh, $outfh, 1, $errstr); } # Compare the two buffers @@ -118,8 +155,8 @@ sub process_cmd $res = helper::verify_cmd($cmdfh, $outfh, "cmpstr"); $res = oct($res); if ($res != 0) { - print STDOUT "ERROR! Buffers from $src and $dest do not match\n"; - exit 1; + $errstr = "ERROR! Buffers from $src and $dest do not match\n"; + clean_exit($cmdfh, $outfh, 1, $errstr); } # Clean up @@ -150,9 +187,8 @@ sub process_cmd chop($res); if ($res ne "0xffffffff") { - - print STDOUT "ERROR! Open on $dest succeeded (should have failed)\n"; - exit 1; + $errstr = "ERROR! Open on $dest succeeded (should have failed)\n"; + clean_exit($cmdfh, $outfh, 1, $errstr); } # Now read from the src again and make sure it matches the original @@ -167,8 +203,8 @@ sub process_cmd $res = helper::verify_cmd($cmdfh, $outfh, "read $src(2)"); if ($readb != oct($res)) { - print STDOUT "ERROR! Read $readb bytes from src originally but now only $res bytes\n"; - exit 1; + $errstr = "ERROR! Read $readb bytes from src originally but now only $res bytes\n"; + clean_exit($cmdfh, $outfh, 1, $errstr); } # Compare the two buffers @@ -177,16 +213,15 @@ sub process_cmd $res = helper::verify_cmd($cmdfh, $outfh, "cmpstr"); $res = oct($res); if ($res != 0) { - print STDOUT "ERROR! Original buffers from $src and new buf do not match\n"; - exit 1; + $errstr = "ERROR! Original buffers from $src and new buf do not match\n"; + clean_exit($cmdfh, $outfh, 1, $errstr); } # Clean up $cmdstr = 'CALL close $src2'."\n"; helper::send_cmd($cmdfh, $outfh, "close", $cmdstr); - - print STDOUT "Symlink test successful\n"; + clean_exit($cmdfh, $outfh, 0, "Symlink test successful\n"); exit 0; } |