-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.pl
executable file
·69 lines (51 loc) · 1.56 KB
/
driver.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/perl
use Getopt::Std;
##############################################################################
#
# This program is used to test a malloclab submission for correctness and
# performance using mdriver.
#
##############################################################################
sub usage
{
printf STDERR "$_[0]\n";
printf STDERR "Usage: $0 [-h] [-s SECONDS]\n";
printf STDERR "Options:\n";
printf STDERR " -h Print this message\n";
printf STDERR " -s SECONDS Set driver timeout\n";
die "\n" ;
}
# Generic setting
$| = 1; # Autoflush output on every print statement
# Settings
# Driver timeout
$timeout = 1000;
getopts('hs:');
if ($opt_h) {
usage($ARGV[0]);
}
if ($opt_s) {
$timeout = $opt_s;
}
$callibration_flags = "";
$driver_flags = "";
# Run callibration program
$callibration_prog = "./callibrate.pl";
if (!-e $callibration_prog) {
die "Cannot find callibration program $callibration_prog\n";
}
system("$callibration_prog $callibration_flags");
# Run macro checker
$macro_check = `./macro-check.pl -f mm.c`;
if ($macro_check ne "") {
print $macro_check;
print "FAILED macro check: You are not allowed to use macros for this assignment. Use static functions instead.\n";
print "Score: Checkpoint 1: 0 / 50, Checkpoint 2: 0 / 100, Final: 0 / 100\n";
exit;
}
$driver_prog = "./mdriver";
if (!-e $driver_prog) {
die "Cannot find driver program '$driver_prog'\n";
}
print "Running $driver_prog -s $timeout $driver_flags\n";
system("$driver_prog -s $timeout $driver_flags 2>&1")