-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgrade-lab3
More file actions
executable file
·254 lines (224 loc) · 9.14 KB
/
Copy pathgrade-lab3
File metadata and controls
executable file
·254 lines (224 loc) · 9.14 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#!/usr/bin/env python
from gradelib import *
r = Runner(save('jos.out'),
stop_breakpoint('readline'))
@test(0, 'running JOS')
def test_jos():
r.run_qemu()
@test(10, 'Slab initialization', parent=test_jos)
def test_kmem_init():
r.match(r'\[LAB 3\] check_kmem_init\(\) succeeded!')
@test(10, 'Slab single alloc', parent=test_jos)
def test_kmem_single_alloc():
r.match(r'\[LAB 3\] check_kmem_single_alloc\(\) succeeded!')
@test(10, 'Slab full alloc', parent=test_jos)
def test_kmem_full_alloc():
r.match(r'\[LAB 3\] check_kmem_full_alloc\(\) succeeded!')
@test(10, 'Slab limit', parent=test_jos)
def test_kmem_single_alloc():
r.match(r'\[LAB 3\] check_kmem_limit\(\) succeeded!')
end_part('slab')
@test(10)
def test_divzero():
r.user_test('divzero')
r.match('\[LAB 3\] check_us\(\) succeeded!',
'\[LAB 3\] check_wx\(\) succeeded!',
'\[LAB 3\] check_null\(\) succeeded!',
'Welcome to the JOS kernel monitor!',
'Incoming INT frame at 0xfffffe7fffffff..',
'INT frame at 0xf.......',
' INT 0: Divide-by-Zero Error Exception \(#DE\)',
' RIP 0x00000000008..... RFL 0x.{16}',
' CS 0x0023 DS 0x001b SS 0x001b',
'.PID 1. Freed task with PID 1',
no=['1/0 is ........!'])
@test(10)
def test_softint():
r.user_test('softint')
r.match('\[LAB 3\] check_us\(\) succeeded!',
'\[LAB 3\] check_wx\(\) succeeded!',
'\[LAB 3\] check_null\(\) succeeded!',
'Welcome to the JOS kernel monitor!',
'Incoming INT frame at 0xfffffe7fffffff..',
'INT frame at 0xf.......',
' INT 13: General Protection \(#GP\)',
' RIP 0x00000000008..... RFL 0x.{16}',
' CS 0x0023 DS 0x001b SS 0x001b',
'.PID 1. Freed task with PID 1')
@test(10)
def test_badsegment():
r.user_test('badsegment')
r.match('\[LAB 3\] check_us\(\) succeeded!',
'\[LAB 3\] check_wx\(\) succeeded!',
'\[LAB 3\] check_null\(\) succeeded!',
'Welcome to the JOS kernel monitor!',
'Incoming INT frame at 0xfffffe7fffffff..',
'INT frame at 0xf.......',
' INT 13: General Protection \(#GP\)',
' RIP 0x00000000008..... RFL 0x.{16}',
' CS 0x0023 DS 0x001b SS 0x001b',
'.PID 1. Freed task with PID 1')
end_part('interrupts')
@test(5)
def test_nullread():
r.user_test('nullread')
r.match('\[LAB 3\] check_us\(\) succeeded!',
'\[LAB 3\] check_wx\(\) succeeded!',
'\[LAB 3\] check_null\(\) succeeded!',
'Welcome to the JOS kernel monitor!',
'.PID 1. user fault va 0x0 ip 0x8.....',
'Incoming INT frame at 0xfffffe7fffffff..',
'INT frame at 0xf.......',
' INT 14: Page Fault \(#PF\)',
' ERR 0x0000000000000004.*',
'.PID 1. Freed task with PID 1',
no=['I read .. from location 0!'])
@test(5)
def test_nullwrite():
r.user_test('nullwrite')
r.match('\[LAB 3\] check_us\(\) succeeded!',
'\[LAB 3\] check_wx\(\) succeeded!',
'\[LAB 3\] check_null\(\) succeeded!',
'Welcome to the JOS kernel monitor!',
'.PID 1. user fault va 0x0 ip 0x8.....',
'Incoming INT frame at 0xfffffe7fffffff..',
'INT frame at 0xf.......',
' INT 14: Page Fault \(#PF\)',
' ERR 0x0000000000000006.*',
'.PID 1. Freed task with PID 1')
@test(5)
def test_nullexec():
r.user_test('nullexec')
r.match('\[LAB 3\] check_us\(\) succeeded!',
'\[LAB 3\] check_wx\(\) succeeded!',
'\[LAB 3\] check_null\(\) succeeded!',
'Welcome to the JOS kernel monitor!',
'.PID 1. user fault va 0x0 ip 0x0',
'Incoming INT frame at 0xfffffe7fffffff..',
'INT frame at 0xf.......',
' INT 14: Page Fault \(#PF\)',
' ERR 0x0000000000000014.*',
'.PID 1. Freed task with PID 1')
@test(5)
def test_faultwrite():
r.user_test('faultwrite')
r.match('\[LAB 3\] check_us\(\) succeeded!',
'\[LAB 3\] check_wx\(\) succeeded!',
'\[LAB 3\] check_null\(\) succeeded!',
'Welcome to the JOS kernel monitor!',
'.PID 1. user fault va 0x800... ip 0x8.....',
'Incoming INT frame at 0xfffffe7fffffff..',
'INT frame at 0xf.......',
' INT 14: Page Fault \(#PF\)',
' ERR 0x0000000000000007.*',
'.PID 1. Freed task with PID 1')
@test(5)
def test_faultexec():
r.user_test('faultexec')
r.match('\[LAB 3\] check_us\(\) succeeded!',
'\[LAB 3\] check_wx\(\) succeeded!',
'\[LAB 3\] check_null\(\) succeeded!',
'Welcome to the JOS kernel monitor!',
'.PID 1. user fault va 0x801... ip 0x801...',
'Incoming INT frame at 0xfffffe7fffffff..',
'INT frame at 0xf.......',
' INT 14: Page Fault \(#PF\)',
' ERR 0x0000000000000015.*',
'.PID 1. Freed task with PID 1')
@test(5)
def test_kernelread():
r.user_test('kernelread')
r.match('\[LAB 3\] check_us\(\) succeeded!',
'\[LAB 3\] check_wx\(\) succeeded!',
'\[LAB 3\] check_null\(\) succeeded!',
'Welcome to the JOS kernel monitor!',
'.PID 1. user fault va 0xffff800000100000 ip 0x8.....',
'Incoming INT frame at 0xfffffe7fffffff..',
'INT frame at 0xf.......',
' INT 14: Page Fault \(#PF\)',
' ERR 0x0000000000000005.*',
'.PID 1. Freed task with PID 1',
no=['I read .. from location 0!'])
@test(5)
def test_kernelwrite():
r.user_test('kernelwrite')
r.match('\[LAB 3\] check_us\(\) succeeded!',
'\[LAB 3\] check_wx\(\) succeeded!',
'\[LAB 3\] check_null\(\) succeeded!',
'Welcome to the JOS kernel monitor!',
'.PID 1. user fault va 0xffff800000100000 ip 0x8.....',
'Incoming INT frame at 0xfffffe7fffffff..',
'INT frame at 0xf.......',
' INT 14: Page Fault \(#PF\)',
' ERR 0x0000000000000007.*',
'.PID 1. Freed task with PID 1')
@test(5)
def test_kernelexec():
r.user_test('kernelexec')
r.match('\[LAB 3\] check_us\(\) succeeded!',
'\[LAB 3\] check_wx\(\) succeeded!',
'\[LAB 3\] check_null\(\) succeeded!',
'Welcome to the JOS kernel monitor!',
'.PID 1. user fault va 0xffff800000100000 ip 0xffff800000100000',
'Incoming INT frame at 0xfffffe7fffffff..',
'INT frame at 0xf.......',
' INT 14: Page Fault \(#PF\)',
' ERR 0x0000000000000015.*',
'.PID 1. Freed task with PID 1')
@test(5)
def test_breakpoint():
r.user_test('breakpoint')
r.match('\[LAB 3\] check_us\(\) succeeded!',
'\[LAB 3\] check_wx\(\) succeeded!',
'\[LAB 3\] check_null\(\) succeeded!',
'Welcome to the JOS kernel monitor!',
'Incoming INT frame at 0xfffffe7fffffff..',
no=['INT frame at 0xf.......',
' INT 3: Breakpoint \(#BP\)',
' RIP 0x00000000008..... RFL 0x.{16}',
' CS 0x0023 DS 0x001b SS 0x001b',
'.PID 1. Freed task with PID 1'])
@test(5)
def test_testbss():
r.user_test('testbss')
r.match('\[LAB 3\] check_us\(\) succeeded!',
'\[LAB 3\] check_wx\(\) succeeded!',
'\[LAB 3\] check_null\(\) succeeded!',
'Making sure bss works right...',
'Yes, good. Now doing a wild write off the end...',
'.PID 1. user fault va 0xc..... ip 0x8.....',
'.PID 1. Freed task with PID 1')
@test(5)
def test_hello():
r.user_test('hello')
r.match('\[LAB 3\] check_us\(\) succeeded!',
'\[LAB 3\] check_wx\(\) succeeded!',
'\[LAB 3\] check_null\(\) succeeded!',
'.PID 0. New task with PID 1',
'Hello, world!',
'We are number 1!',
'.PID 1. Exiting gracefully',
'.PID 1. Freed task with PID 1',
'Destroyed the only task - nothing more to do!')
end_part('userspace')
@test(5)
def test_nullhello():
r.user_test('nullhello')
r.match('.PID 1. Access violation for va 0x0',
'.PID 1. Freed task with PID 1',
'Destroyed the only task - nothing more to do!')
@test(5)
def test_overflowhello():
r.user_test('overflowhello')
r.match('.PID 1. Access violation for va 0x8.....',
'.PID 1. Freed task with PID 1',
'Destroyed the only task - nothing more to do!',
no=['Hello, world!'])
@test(5)
def test_evilhello():
r.user_test('evilhello')
r.match('.PID 1. Access violation for va 0xffff800000100000',
'.PID 1. Freed task with PID 1',
'Destroyed the only task - nothing more to do!')
end_part('user violation')
run_tests()