-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrade-lab-syscall
executable file
·95 lines (79 loc) · 2.34 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python3
import re
from gradelib import *
r = Runner(save("xv6.out"))
@test(5, "sleep, no arguments")
def test_sleep_no_args():
r.run_qemu(shell_script([
'sleep'
]))
r.match(no=["exec .* failed", "$ sleep\n$"])
@test(5, "sleep, returns")
def test_sleep_no_args():
r.run_qemu(shell_script([
'sleep',
'echo OK'
]))
r.match('^OK$', no=["exec .* failed", "$ sleep\n$"])
@test(10, "sleep, makes syscall")
def test_sleep():
r.run_qemu(shell_script([
'sleep 10',
'echo FAIL'
]), stop_breakpoint('sys_sleep'))
r.match('\\$ sleep 10', no=['FAIL'])
@test(20, "pingpong")
def test_pingpong():
r.run_qemu(shell_script([
'pingpong', 'echo OK'
]))
r.match('^\\d+: received ping$', '^\\d+: received pong$', '^OK$')
@test(5, "lab-util-syscall-report.txt")
def test_answers():
# just a simple sanity check, will be graded manually
check_answers("lab-util-syscall-report.txt")
@test(5, "trace 32 grep")
def test_trace_32_grep():
r.run_qemu(shell_script([
'trace 32 grep hello README'
]))
r.match('^\\d+: syscall read -> 1023')
r.match('^\\d+: syscall read -> 961')
r.match('^\\d+: syscall read -> 321')
r.match('^\\d+: syscall read -> 0')
@test(5, "trace all grep")
def test_trace_all_grep():
r.run_qemu(shell_script([
'trace 2147483647 grep hello README'
]))
r.match('^\\d+: syscall trace -> 0')
r.match('^\\d+: syscall exec -> 3')
r.match('^\\d+: syscall open -> 3')
r.match('^\\d+: syscall read -> 1023')
r.match('^\\d+: syscall read -> 961')
r.match('^\\d+: syscall read -> 321')
r.match('^\\d+: syscall read -> 0')
r.match('^\\d+: syscall close -> 0')
@test(5, "trace nothing")
def test_trace_nothing():
r.run_qemu(shell_script([
'grep hello README'
]))
r.match(no=[".* syscall .*"])
@test(5, "trace children")
def test_trace_children():
r.run_qemu(shell_script([
'trace 2 usertests forkforkfork'
]))
r.match('3: syscall fork -> 4')
r.match('^5: syscall fork -> \\d+')
r.match('^6: syscall fork -> \\d+')
r.match('^\\d+: syscall fork -> -1')
r.match('^ALL TESTS PASSED')
@test(15, "sysinfotest")
def test_sysinfotest():
r.run_qemu(shell_script([
'sysinfotest'
]))
r.match('^sysinfotest: OK', no=[".* FAIL .*"])
run_tests()