-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-lab-l3
executable file
·167 lines (147 loc) · 4.35 KB
/
test-lab-l3
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/usr/bin/env python3
import re
from gradelib import *
r = Runner(save("xv6.out"))
@test(1, "[MANDATORY] vatopa exists")
def test1():
r.run_qemu(shell_script(["vatopa"]))
r.match("Usage\: vatopa virtual_address \[pid\]")
@test(1, "[MANDATORY] vatopa 0")
def test2():
r.run_qemu(shell_script(["vatopa 0"]))
r.match("^0x[0-9a-fA-F]{8}$")
@test(1, "[MANDATORY] vatopa 0 1 matches")
def test3():
r.run_qemu(
shell_script(["vatopa 0 1", "vatopa 0 1"]),
)
r.match(
"^0x([0-9a-fA-F]{8})$",
"^0x([0-9a-fA-F]{8})$",
match_fn=lambda matches: int(matches[0], base=16)
== int(matches[1], base=16),
)
@test(1, "[MANDATORY] cowtest no crash")
def test4():
r.run_qemu(
shell_script(["cowtest 1"]),
)
r.match(no=["panic: assert failed"])
@test(1, "[MANDATORY] cowtest 1 match addresses")
def test5():
r.run_qemu(
shell_script(["cowtest 1"]),
)
r.match(
"^\[prnt\] v1 --> (\d+)$",
"^\[prnt\] v4 --> (\d+)$",
match_fn=lambda matches: (int(matches[0]) == int(matches[1])),
)
r.match(
"^\[prnt\] v3 --> (\d+)$",
"^\[chld\] v2 --> (\d+)$",
match_fn=lambda matches: (int(matches[0]) == int(matches[1])),
)
@test(1, "[MANDATORY] cowtest 2 match addresses")
def test6():
r.run_qemu(
shell_script(["cowtest 2"]),
)
r.match(
"^\[prnt\] v1 --> (\d+)$",
"^\[prnt\] v5 --> (\d+)$",
match_fn=lambda matches: (int(matches[0]) == int(matches[1])),
)
r.match(
"^\[prnt\] v2 --> (\d+)$",
"^\[chld\] v3 --> (\d+)$",
match_fn=lambda matches: (int(matches[0]) == int(matches[1])),
)
r.match(
"^\[chld\] v4 --> (\d+)$",
"^\[chld\] v3 --> (\d+)$",
match_fn=lambda matches: (int(matches[0]) == int(matches[1])),
)
r.match(
"^\[chld\] read global_var, global_var=0$",
)
@test(1, "[MANDATORY] cowtest 3 match addresses")
def test7():
r.run_qemu(
shell_script(["cowtest 3"]),
)
r.match(
"^\[prnt\] v1 --> (\d+)$",
"^\[prnt\] v6 --> (\d+)$",
match_fn=lambda matches: (int(matches[0]) == int(matches[1])),
)
r.match(
"^\[prnt\] v2 --> (\d+)$",
"^\[prnt\] v3 --> (\d+)$",
match_fn=lambda matches: (int(matches[0]) == int(matches[1])),
)
r.match(
"^\[prnt\] v3 --> (\d+)$",
"^\[chld\] v4 --> (\d+)$",
match_fn=lambda matches: (int(matches[0]) == int(matches[1])),
)
r.match(
"^\[chld\] v4 --> (\d+)$",
"^\[chld\] v5 --> (\d+)$",
match_fn=lambda matches: (int(matches[0]) - 1 == int(matches[1])),
)
r.match(
"^\[chld\] modified global_var, global_var=100$",
)
r.match(
"^\[prnt\] read global_var, global_var=0$",
)
@test(1, "[MANDATORY] cowtest 4 match addresses")
def test8():
r.run_qemu(
shell_script(["cowtest 4"]),
)
r.match(
"^\[prnt\] v1 --> (\d+)$",
"^\[prnt\] v7 --> (\d+)$",
match_fn=lambda matches: (int(matches[0]) == int(matches[1])),
)
r.match(
"^\[prnt\] v2 --> (\d+)$",
"^\[prnt\] v3 --> (\d+)$",
match_fn=lambda matches: (int(matches[0]) - 1 == int(matches[1])),
)
r.match(
"^\[chld\] pa1 --> 0x([0-9a-fA-F]+)$",
"^\[chld\] pa2 --> 0x([0-9a-fA-F]+)$",
"^\[prnt\] pa3 --> 0x([0-9a-fA-F]+)$",
match_fn=lambda matches: (
int(matches[0], base=16) != int(matches[1], base=16)
and int(matches[1], base=16) != int(matches[2], base=16)
),
)
r.match(
"^\[prnt\] v3 --> (\d+)$",
"^\[chld\] v4 --> (\d+)$",
match_fn=lambda matches: (int(matches[0]) == int(matches[1])),
)
r.match(
"^\[prnt\] v3 --> (\d+)$",
"^\[chld\] v5 --> (\d+)$",
match_fn=lambda matches: (int(matches[0]) == int(matches[1])),
)
r.match(
"^\[chld\] v5 --> (\d+)$",
"^\[chld\] v6 --> (\d+)$",
match_fn=lambda matches: (int(matches[0]) - 1 == int(matches[1])),
)
r.match(
"^\[chld\] modified one element in the 1st page, global_array\[0\]=222$",
)
r.match(
"^\[chld\] modified two elements in the 2nd page, global_array\[2047\]=333$",
)
r.match(
"^\[prnt\] modified one element in the 1st page, global_array\[0\]=111$",
)
run_tests()