-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrade-lab8
More file actions
executable file
·129 lines (109 loc) · 3.85 KB
/
grade-lab8
File metadata and controls
executable file
·129 lines (109 loc) · 3.85 KB
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
from gradelib import *
r = Runner(save("jos.out"),
stop_breakpoint("readline"))
def E(s, trim=False):
"""Expand $En in s to the environment ID of the n'th user
environment."""
tmpl = "%x" if trim else "%08x"
return re.sub(r"\$E([0-9]+)",
lambda m: tmpl % (0x1000 + int(m.group(1))-1), s)
@test(10)
def test_divzero():
r.user_test("divzero")
r.match('Incoming TRAP.0. frame at 0x803fffff40',
'TRAP frame at 0x80........',
' trap 0x00000000 Divide error',
' rip 0x008.....',
' ss 0x----0033',
E('.$E1. free env $E1'),
no=['1337/0 is ........!'])
@test(10)
def test_softint():
r.user_test("softint")
r.match('Welcome to the JOS kernel monitor!',
'Incoming TRAP.13. frame at 0x803fffff40',
'TRAP frame at 0x80........',
' trap 0x0000000d General Protection',
' rip 0x008.....',
' ss 0x----0033',
E('.$E1. free env $E1'))
@test(10)
def test_badsegment():
r.user_test("badsegment")
r.match('Incoming TRAP.13. frame at 0x803fffff40',
'TRAP frame at 0x80........',
' trap 0x0000000d General Protection',
' err 0x00000038',
' rip 0x008.....',
' ss 0x----0033',
E('.$E1. free env $E1'))
end_part("A")
@test(7)
def test_faultread():
r.user_test("faultread")
r.match("<0x80........> Page fault ip=[0-9A-F]+ va=00000000 err=-U--- -> fault",
E(".$E1. free env $E1"),
no=["I read ........ from location 0."])
@test(7)
def test_faultwrite():
r.user_test("faultwrite")
r.match("<0x80........> Page fault ip=[0-9A-F]+ va=00000000 err=-UW-- -> fault",
E(".$E1. free env $E1"))
@test(7)
def test_faultreadkernel():
r.user_test("faultreadkernel")
r.match("<0x80........> Page fault ip=[0-9A-F]+ va=8040000000 err=PU--- -> fault",
E(".$E1. free env $E1"),
no=["I read ........ from location 0."])
@test(7)
def test_faultwritekernel():
r.user_test("faultwritekernel")
r.match("<0x80........> Page fault ip=[0-9A-F]+ va=8040000000 err=PUW-- -> fault",
E(".$E1. free env $E1"))
@test(7)
def test_breakpoint():
r.user_test("breakpoint")
r.match('Welcome to the JOS kernel monitor!',
'Incoming TRAP.3. frame at 0x803fffff40',
'TRAP frame at 0x80........',
' trap 0x00000003 Breakpoint',
' rip 0x008.....',
' ss 0x----0033',
no=[E('.$E1. free env $E1')])
@test(7)
def test_testbss():
r.user_test("testbss")
r.match('Making sure bss works right...',
'Yes, good. Now doing a wild write off the end...',
'Incoming TRAP.14. frame at 0x803ffe7f40',
'<0x80........> Page fault ip=[0-9A-F]+ va=02C..000 err=-UW-- -> fault',
E('.$E1. free env $E1'))
@test(7)
def test_hello():
r.user_test("hello")
r.match(E('.00000000. new env $E1'),
'hello, world',
'i am environment 00001000',
E('.$E1. exiting gracefully'),
E('.$E1. free env $E1'))
@test(7)
def test_buggyhello():
r.user_test("buggyhello")
r.match(E('.$E1. user_mem_check assertion failure for va.0000000000000001 ip.00000000008.....'),
E('.$E1. free env $E1'))
@test(7)
def test_buggyhello2():
r.user_test("buggyhello2")
r.match(E('.$E1. user_mem_check assertion failure for va................. ip.00000000008.....'),
E('.$E1. free env $E1'),
no=['hello, world'])
@test(7)
def test_evilhello():
r.user_test("evilhello")
r.match(E('.$E1. user_mem_check assertion failure for va.0000008040200... ip.00000000008.....'),
E('.$E1. free env $E1'))
end_part("B")
run_tests()