First upload
[CS310.git] / grade_lab_util.py
blob16857130efdc020a61a1ebe9c6229c824a164a0b
1 import re
2 import sys
3 from gradelib import *
5 r = Runner(save("xv6.out"))
7 @test(20, "sleep, no args")
8 def test_sleep_no_args():
9 r.run_qemu(shell_script([
10 'sleep'
11 ]))
12 r.match(no=["exec .* failed", "$ sleep\n$"])
14 @test(20, "sleep, returns")
15 def test_sleep_echo():
16 r.run_qemu(shell_script([
17 'sleep',
18 'echo OK'
19 ]))
20 r.match('^OK$', no=["exec .* failed", "$ sleep\n$"])
22 @test(10, "sleep, makes syscall")
23 def test_sleep_breakpoint():
24 r.run_qemu(shell_script([
25 'sleep 10',
26 'echo FAIL'
27 ]), stop_breakpoint('sys_sleep'))
28 r.match('\\$ sleep 10', no=['FAIL'])
30 @test(20, "countsys, simple")
31 def test_countsys_simple():
32 r.run_qemu(shell_script([
33 'countsys',
34 ]))
35 r.match('4[12345]', no=["exec .* failed"])
37 @test(20, "countsys, twice")
38 def test_countsys_twice():
39 r.run_qemu(shell_script([
40 'countsys',
41 'countsys',
42 ]))
43 r.match('6[12345]', no=["exec .* failed"])
45 @test(10, "countsys, sleep 10, countsys")
46 def test_countsys_sleep():
47 r.run_qemu(shell_script([
48 'sleep 10',
49 'countsys',
50 ]))
51 r.match('(5[89]|6[012])', no=["exec .* failed"])
53 if __name__ == '__main__':
54 if len(sys.argv) > 1:
55 run_tests(outputJSON=sys.argv[1])
56 else:
57 run_tests()