137 lines
3.1 KiB
Python
Executable File
137 lines
3.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import re
|
|
from gradelib import *
|
|
|
|
r = Runner(save("xv6.out"))
|
|
|
|
@test(5, "answers-syscall.txt")
|
|
def test_answers():
|
|
# just a simple sanity check, will be graded manually
|
|
check_answers("answers-syscall.txt")
|
|
|
|
@test(5, "trace 32 grep")
|
|
def test_trace_32_grep():
|
|
r.run_qemu(shell_script([
|
|
'trace 32 grep hello README'
|
|
]))
|
|
|
|
sys_cnt = {
|
|
'read' : 0
|
|
}
|
|
|
|
sys_cnt['read'] += 1
|
|
s = r'^\d+: syscall read\(trace counts: ' + str(sys_cnt['read']) + r'\) -> 1023'
|
|
r.match(s)
|
|
|
|
sys_cnt['read'] += 1
|
|
s = r'^\d+: syscall read\(trace counts: ' + str(sys_cnt['read']) + r'\) -> 961'
|
|
r.match(s)
|
|
|
|
sys_cnt['read'] += 1
|
|
s = r'^\d+: syscall read\(trace counts: ' + str(sys_cnt['read']) + r'\) -> 321'
|
|
r.match(s)
|
|
|
|
sys_cnt['read'] += 1
|
|
s = r'^\d+: syscall read\(trace counts: ' + str(sys_cnt['read']) + r'\) -> 0'
|
|
r.match(s)
|
|
|
|
@test(5, "trace all grep")
|
|
def test_trace_all_grep():
|
|
r.run_qemu(shell_script([
|
|
'trace 2147483647 grep hello README'
|
|
]))
|
|
|
|
sys_cnt = {
|
|
'read' : 0,
|
|
'trace' : 0,
|
|
'exec' : 0,
|
|
'open' : 0,
|
|
'close' : 0,
|
|
'fork' : 0,
|
|
}
|
|
|
|
sys_cnt['trace'] += 1
|
|
s = r'^\d+: syscall trace\(trace counts: ' + str(sys_cnt['trace']) + r'\) -> 0'
|
|
r.match(s)
|
|
|
|
sys_cnt['exec'] += 1
|
|
s = r'^\d+: syscall exec\(trace counts: ' + str(sys_cnt['exec']) + r'\) -> 3'
|
|
r.match(s)
|
|
|
|
sys_cnt['open'] += 1
|
|
s = r'^\d+: syscall open\(trace counts: ' + str(sys_cnt['open']) + r'\) -> 3'
|
|
r.match(s)
|
|
|
|
|
|
sys_cnt['read'] += 1
|
|
s = r'^\d+: syscall read\(trace counts: ' + str(sys_cnt['read']) + r'\) -> 1023'
|
|
r.match(s)
|
|
|
|
sys_cnt['read'] += 1
|
|
s = r'^\d+: syscall read\(trace counts: ' + str(sys_cnt['read']) + r'\) -> 961'
|
|
r.match(s)
|
|
|
|
sys_cnt['read'] += 1
|
|
s = r'^\d+: syscall read\(trace counts: ' + str(sys_cnt['read']) + r'\) -> 321'
|
|
r.match(s)
|
|
|
|
sys_cnt['read'] += 1
|
|
s = r'^\d+: syscall read\(trace counts: ' + str(sys_cnt['read']) + r'\) -> 0'
|
|
r.match(s)
|
|
|
|
sys_cnt['close'] += 1
|
|
s = r'^\d+: syscall close\(trace counts: ' + str(sys_cnt['close']) + r'\) -> 0'
|
|
r.match(s)
|
|
|
|
@test(5, "trace nothing")
|
|
def test_trace_nothing():
|
|
r.run_qemu(shell_script([
|
|
'grep hello README'
|
|
]))
|
|
r.match(no=[".* syscall .*"])
|
|
|
|
@test(5, "trace children")
|
|
def test_trace_children():
|
|
r.run_qemu(shell_script([
|
|
'trace 2 usertests forkforkfork'
|
|
]))
|
|
|
|
sys_cnt = {
|
|
'read' : 0,
|
|
'trace' : 0,
|
|
'exec' : 0,
|
|
'open' : 0,
|
|
'close' : 0,
|
|
'fork' : 0,
|
|
}
|
|
|
|
sys_cnt['fork'] += 1
|
|
s = r'3: syscall fork\(trace counts: ' + str(sys_cnt['fork']) + r'\) -> 4'
|
|
r.match(s)
|
|
|
|
s = r'^5: syscall fork\(trace counts: \d+\) -> \d+'
|
|
r.match(s)
|
|
|
|
s = r'^6: syscall fork\(trace counts: \d+\) -> \d+'
|
|
r.match(s)
|
|
|
|
s = r'^\d+: syscall fork\(trace counts: \d+\) -> -1'
|
|
r.match(s)
|
|
|
|
r.match('^ALL TESTS PASSED')
|
|
|
|
@test(14, "sysinfotest")
|
|
def test_sysinfotest():
|
|
r.run_qemu(shell_script([
|
|
'sysinfotest'
|
|
]))
|
|
r.match('^sysinfotest: OK', no=[".* FAIL .*"])
|
|
|
|
@test(1, "time")
|
|
def test_time():
|
|
check_time()
|
|
|
|
run_tests()
|
|
|