7 r
= Runner(save("xv6.out"))
9 PTE_PRINT
= """page table 0x0000000087f6e000
10 ..0: pte 0x0000000021fda801 pa 0x0000000087f6a000
11 .. ..0: pte 0x0000000021fda401 pa 0x0000000087f69000
12 .. .. ..0: pte 0x0000000021fdac1f pa 0x0000000087f6b000
13 .. .. ..1: pte 0x0000000021fda00f pa 0x0000000087f68000
14 .. .. ..2: pte 0x0000000021fd9c1f pa 0x0000000087f67000
15 ..255: pte 0x0000000021fdb401 pa 0x0000000087f6d000
16 .. ..511: pte 0x0000000021fdb001 pa 0x0000000087f6c000
17 .. .. ..510: pte 0x0000000021fdd807 pa 0x0000000087f76000
18 .. .. ..511: pte 0x000000002000200b pa 0x0000000080008000"""
20 VAL_RE
= "(0x00000000[0-9a-f]+)"
21 INDENT_RE
= r
"\s*\.\.\s*"
22 INDENT_ESC
= "\\\s*\.\.\\\s*"
24 @test(0, "running lazytests")
26 r
.run_qemu(shell_script([
30 @test(10, "lazy: pte printout", parent
=test_lazytests
)
33 p
= re
.compile(VAL_RE
)
34 d
= re
.compile(INDENT_RE
)
35 for l
in PTE_PRINT
.splitlines():
36 l
= d
.sub(INDENT_ESC
, l
)
38 r
.match(r
'^{}$'.format(l
))
42 matches
= re
.findall(r
'^{}$'.format(l
), r
.qemu
.output
, re
.MULTILINE
)
43 assert_equal(len(matches
[0]), 2)
44 pa
= (int(matches
[0][0], 16) >> 10) << 12
45 assert_equal(int(matches
[0][1], 16), pa
)
47 @test(20, "lazy: map", parent
=test_lazytests
)
49 r
.match("^test lazy unmap: OK$")
51 @test(20, "lazy: unmap", parent
=test_lazytests
)
53 r
.match("test lazy alloc: OK$")
57 r
.run_qemu(shell_script([
61 def usertest_check(testcase
, nextcase
, output
):
62 if not re
.search(r
'\ntest {}: [\s\S]*OK\ntest {}'.format(testcase
, nextcase
), output
):
63 raise AssertionError('Failed ' + testcase
)
65 @test(4, "usertests: pgbug", parent
=test_usertests
)
67 usertest_check("pgbug", "sbrkbugs", r
.qemu
.output
)
69 @test(4, "usertests: sbrkbugs", parent
=test_usertests
)
71 usertest_check("sbrkbugs", "badarg", r
.qemu
.output
)
73 @test(4, "usertests: argptest", parent
=test_usertests
)
75 usertest_check("argptest", "createdelete", r
.qemu
.output
)
77 @test(4, "usertests: sbrkmuch", parent
=test_usertests
)
79 usertest_check("sbrkmuch", "kernmem", r
.qemu
.output
)
81 @test(4, "usertests: sbrkfail", parent
=test_usertests
)
83 usertest_check("sbrkfail", "sbrkarg", r
.qemu
.output
)
85 @test(5, "usertests: sbrkarg", parent
=test_usertests
)
87 usertest_check("sbrkarg", "validatetest", r
.qemu
.output
)
89 @test(5, "usertests: stacktest", parent
=test_usertests
)
91 usertest_check("stacktest", "opentest", r
.qemu
.output
)
93 @test(20, "usertests: all tests", parent
=test_usertests
)
94 def test_usertests_all():
95 r
.match('^ALL TESTS PASSED$')
97 if __name__
== '__main__':
99 run_tests(outputJSON
=sys
.argv
[1])