First upload
[CS310.git] / grade_lab_cow.py
blobf2c02828197f207b57490171507cca81b7c9f292
1 #!/usr/bin/env python3
3 import re
4 import sys
5 from gradelib import *
7 r = Runner(save("xv6.out"))
9 @test(0, "running cowtest")
10 def test_cowtest():
11 r.run_qemu(shell_script([
12 'cowtest'
13 ]),timeout=300)
15 @test(30, "simple", parent=test_cowtest)
16 def test_simple():
17 matches = re.findall("^simple: ok$", r.qemu.output, re.M)
18 assert_equal(len(matches), 2, "Number of appearances of 'simple: ok'")
20 @test(30, "three", parent=test_cowtest)
21 def test_three():
22 matches = re.findall("^three: ok$", r.qemu.output, re.M)
23 assert_equal(len(matches), 3, "Number of appearances of 'three: ok'")
25 @test(20, "file", parent=test_cowtest)
26 def test_file():
27 r.match('^file: ok$')
29 @test(20, "usertests")
30 def test_usertests():
31 r.run_qemu(shell_script([
32 'usertests'
33 ]), timeout=300)
34 r.match('^ALL TESTS PASSED$')
36 if __name__ == '__main__':
37 if len(sys.argv) > 1:
38 run_tests(outputJSON=sys.argv[1])
39 else:
40 run_tests()