From: Ben Pfaff Date: Wed, 24 Nov 2004 00:31:39 +0000 (+0000) Subject: Deal with update `pintos' script. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pintos-anon;a=commitdiff_plain;h=3403a18c29c58560ea393faf81d8d341c0cda503 Deal with update `pintos' script. --- diff --git a/grading/userprog/prep-disk b/grading/userprog/prep-disk index 1d34e5f..f1b766c 100755 --- a/grading/userprog/prep-disk +++ b/grading/userprog/prep-disk @@ -2,6 +2,7 @@ use strict; use Getopt::Long; +use POSIX; my ($pintos) = "pintos"; my ($os_disk) = "../../src/userprog/build/os.dsk"; @@ -33,7 +34,7 @@ if (! -e $os_disk) { 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, @@ -55,11 +56,12 @@ sub put_file { 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"; } diff --git a/grading/vm/prep-disk b/grading/vm/prep-disk index 10afa8f..d6d85a2 100755 --- a/grading/vm/prep-disk +++ b/grading/vm/prep-disk @@ -2,6 +2,7 @@ use strict; use Getopt::Long; +use POSIX; my ($pintos) = "pintos"; my ($os_disk) = "../../src/userprog/build/os.dsk"; @@ -27,7 +28,7 @@ if (! -e $os_disk) { 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)); } @@ -37,11 +38,13 @@ sub put_file { 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"; }