6 r
= Runner(save("jos.out"),
7 stop_breakpoint("readline"))
10 """Expand $En in s to the environment ID of the n'th user
11 environment, accounting for idle environments."""
13 tmpl
= "%x" if trim
else "%08x"
14 return re
.sub(r
"\$E([0-9]+)",
15 lambda m
: tmpl
% (0x1007 + int(m
.group(1))), s
)
19 r
.user_test("dumbfork")
20 r
.match(".00000000. new env 00001000",
21 E(".00000000. new env $E1"),
22 "0: I am the parent.",
23 "9: I am the parent.",
26 "19: I am the child.",
27 E(".$E1. exiting gracefully"),
28 E(".$E1. free env $E1"),
29 E(".$E2. exiting gracefully"),
30 E(".$E2. free env $E2"))
36 r
.user_test("faultread")
37 r
.match(E(".$E1. user fault va 00000000 ip 008....."),
38 "TRAP frame at 0xf....... from CPU .",
39 " trap 0x0000000e Page Fault",
41 E(".$E1. free env $E1"),
42 no
=["I read ........ from location 0."])
45 def test_faultwrite():
46 r
.user_test("faultwrite")
47 r
.match(E(".$E1. user fault va 00000000 ip 008....."),
48 "TRAP frame at 0xf....... from CPU .",
49 " trap 0x0000000e Page Fault",
51 E(".$E1. free env $E1"))
55 r
.user_test("faultdie")
56 r
.match("i faulted at va deadbeef, err 6",
57 E(".$E1. exiting gracefully"),
58 E(".$E1. free env $E1"))
62 r
.user_test("faultregs")
63 r
.match("Registers in UTrapframe OK",
64 "Registers after page-fault OK",
65 no
=["Registers in UTrapframe MISMATCH",
66 "Registers after page-fault MISMATCH"])
69 def test_faultalloc():
70 r
.user_test("faultalloc")
71 r
.match("fault deadbeef",
72 "this string was faulted in at deadbeef",
75 "this string was faulted in at cafebffe",
76 E(".$E1. exiting gracefully"),
77 E(".$E1. free env $E1"))
80 def test_faultallocbad():
81 r
.user_test("faultallocbad")
82 r
.match(E(".$E1. user_mem_check assertion failure for va deadbeef"),
83 E(".$E1. free env $E1"))
86 def test_faultnostack():
87 r
.user_test("faultnostack")
88 r
.match(E(".$E1. user_mem_check assertion failure for va eebfff.."),
89 E(".$E1. free env $E1"))
92 def test_faultbadhandler():
93 r
.user_test("faultbadhandler")
94 r
.match(E(".$E1. user_mem_check assertion failure for va (deadb|eebfe)..."),
95 E(".$E1. free env $E1"))
98 def test_faultevilhandler():
99 r
.user_test("faultevilhandler")
100 r
.match(E(".$E1. user_mem_check assertion failure for va (f0100|eebfe)..."),
101 E(".$E1. free env $E1"))
105 r
.user_test("forktree")
106 r
.match("....: I am .0.",
114 E(".$E1. exiting gracefully"),
115 E(".$E2. exiting gracefully"),
116 ".0000200.. exiting gracefully",
117 ".0000200.. free env 0000200.")
124 r
.match(".00000000. new env 00001000",
125 E(".00000000. new env $E1"),
126 "I am the parent. Forking the child...",
127 E(".$E1. new env $E2"),
128 "I am the parent. Running the child...",
129 "I am the child. Spinning...",
130 "I am the parent. Killing the child...",
131 E(".$E1. destroying $E2"),
132 E(".$E1. free env $E2"),
133 E(".$E1. exiting gracefully"),
134 E(".$E1. free env $E1"))
137 def test_stresssched():
138 r
.user_test("stresssched", make_args
=["CPUS=2"])
139 r
.match(".000010... stresssched on CPU 0",
140 ".000010... stresssched on CPU 1",
141 no
=[".*ran on two CPUs at once"])
145 r
.user_test("pingpong", make_args
=["CPUS=2"])
146 r
.match(".00000000. new env 00001000",
147 E(".00000000. new env $E1"),
148 E(".$E1. new env $E2"),
149 E("send 0 from $E1 to $E2", trim
=True),
150 E("$E2 got 0 from $E1", trim
=True),
151 E("$E1 got 1 from $E2", trim
=True),
152 E("$E2 got 8 from $E1", trim
=True),
153 E("$E1 got 9 from $E2", trim
=True),
154 E("$E2 got 10 from $E1", trim
=True),
155 E(".$E1. exiting gracefully"),
156 E(".$E1. free env $E1"),
157 E(".$E2. exiting gracefully"),
158 E(".$E2. free env $E2"))
162 r
.user_test("primes", stop_on_line("CPU .: 1877"), stop_on_line(".*panic"),
163 make_args
=["CPUS=2"], timeout
=30)
164 r
.match(".00000000. new env 00001000",
165 E(".00000000. new env $E1"),
166 E(".$E1. new env $E2"),
167 E("CPU .: 2 .$E2. new env $E3"),
168 E("CPU .: 3 .$E3. new env $E4"),
169 E("CPU .: 5 .$E4. new env $E5"),
170 E("CPU .: 7 .$E5. new env $E6"),
171 E("CPU .: 11 .$E6. new env $E7"),
172 E("CPU .: 1877 .$E289. new env $E290"))