use strict;
use Getopt::Long;
+use POSIX;
my ($pintos) = "pintos";
my ($os_disk) = "../../src/userprog/build/os.dsk";
our ($formatted) = 0;
unlink $fs_disk;
-xsystem ("$pintos make-disk '$fs_disk' 2");
+xsystem (0, "$pintos make-disk '$fs_disk' 2");
put_file ("$test");
put_file ("sample.txt")
if grep ($_ eq $test,
my ($cmd) = "$pintos -v --os-disk='$os_disk' --fs-disk='$fs_disk' put";
$cmd .= " -f", $formatted = 1 if !$formatted;
$cmd .= " '$fn'";
- xsystem ($cmd);
+ xsystem (1, $cmd);
}
sub xsystem {
- my ($cmd) = @_;
+ my ($expect, $cmd) = @_;
print "$cmd\n";
- system ($cmd) == 0 || die "command failed\n";
+ WIFEXITED ($code) && WEXITSTATUS ($code) == $expect
+ or die "command failed\n";
}
use strict;
use Getopt::Long;
+use POSIX;
my ($pintos) = "pintos";
my ($os_disk) = "../../src/userprog/build/os.dsk";
our ($formatted) = 0;
unlink $fs_disk;
-xsystem ("$pintos make-disk '$fs_disk' 2");
+xsystem (0, "$pintos make-disk '$fs_disk' 2");
while (@ARGV) {
put_file (shift (@ARGV));
}
my ($cmd) = "$pintos -v --os-disk='$os_disk' --fs-disk='$fs_disk' put";
$cmd .= " -f", $formatted = 1 if !$formatted;
$cmd .= " '$fn'";
- xsystem ($cmd);
+ xsystem (1, $cmd);
}
sub xsystem {
- my ($cmd) = @_;
+ my ($expect, $cmd) = @_;
print "$cmd\n";
- system ($cmd) == 0 || die "command failed\n";
+ my ($code) = system ($cmd);
+ WIFEXITED ($code) && WEXITSTATUS ($code) == $expect
+ or die "command failed\n";
}