-
Notifications
You must be signed in to change notification settings - Fork 0
/
grade-lab-syscall
executable file
·66 lines (55 loc) · 1.99 KB
/
grade-lab-syscall
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
#!/usr/bin/env python
import re
from gradelib import *
r = Runner(save("xv6.out"))
@test(5, "answers-syscall.txt")
def test_answers():
# just a simple sanity check, will be graded manually
try:
with open('answers-syscall.txt') as f:
d = f.read().strip()
if not len(d) > 10:
raise AssertionError('answers-syscall.txt does not seem to contain enough text')
except IOError:
raise AssertionError('Cannot read answers-syscall.txt')
@test(25, "uthread")
def test_uthread():
r.run_qemu(shell_script([
'uthread'
]))
expected = ['thread_a started', 'thread_b started', 'thread_c started']
expected.extend(['thread_%s %d' % (tid, n) for n in range(100) for tid in ('c', 'a', 'b')])
expected.extend(['thread_c: exit after 100', 'thread_a: exit after 100', 'thread_b: exit after 100'])
expected.append('thread_schedule: no runnable threads')
if not re.findall('\n'.join(expected), r.qemu.output, re.M):
raise AssertionError('Output does not match expected output')
@test(0, "running alarmtest")
def test_alarmtest():
r.run_qemu(shell_script([
'alarmtest'
]))
@test(20, "alarmtest: test0", parent=test_alarmtest)
def test_alarmtest_test0():
r.match('^test0 passed$')
@test(20, "alarmtest: test1", parent=test_alarmtest)
def test_alarmtest_test1():
r.match('^\\.?test1 passed$')
@test(10, "alarmtest: test2", parent=test_alarmtest)
def test_alarmtest_test2():
r.match('^\\.?test2 passed$')
@test(19, "usertests")
def test_usertests():
r.run_qemu(shell_script([
'usertests'
]), timeout=150)
r.match('^ALL TESTS PASSED$')
@test(1, "time")
def test_time():
try:
with open('time.txt') as f:
d = f.read().strip()
if not re.match(r'^\d+$', d):
raise AssertionError('time.txt does not contain a single integer (number of hours spent on the lab)')
except IOError:
raise AssertionError('Cannot read time.txt')
run_tests()