56 lines
1.4 KiB
Python
Executable File
56 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import re
|
|
from gradelib import *
|
|
|
|
r = Runner(save("xv6.out"))
|
|
|
|
@test(0, "running cowtest")
|
|
def test_cowtest():
|
|
r.run_qemu(shell_script([
|
|
'cowtest'
|
|
]))
|
|
|
|
@test(30, "simple", parent=test_cowtest)
|
|
def test_simple():
|
|
matches = re.findall("^simple: ok$", r.qemu.output, re.M)
|
|
assert_equal(len(matches), 2, "Number of appearances of 'simple: ok'")
|
|
|
|
@test(30, "three", parent=test_cowtest)
|
|
def test_three():
|
|
matches = re.findall("^three: ok$", r.qemu.output, re.M)
|
|
assert_equal(len(matches), 3, "Number of appearances of 'three: ok'")
|
|
|
|
@test(20, "file", parent=test_cowtest)
|
|
def test_file():
|
|
r.match('^file: ok$')
|
|
|
|
@test(0, "usertests")
|
|
def test_usertests():
|
|
r.run_qemu(shell_script([
|
|
'usertests -q'
|
|
]), timeout=1000)
|
|
r.match('^ALL TESTS PASSED$')
|
|
|
|
def usertest_check(testcase, nextcase, output):
|
|
if not re.search(r'\ntest {}: [\s\S]*OK\ntest {}'.format(testcase, nextcase), output):
|
|
raise AssertionError('Failed ' + testcase)
|
|
|
|
@test(5, "usertests: copyin", parent=test_usertests)
|
|
def test_sbrkbugs():
|
|
usertest_check("copyin", "copyout", r.qemu.output)
|
|
|
|
@test(5, "usertests: copyout", parent=test_usertests)
|
|
def test_sbrkbugs():
|
|
usertest_check("copyout", "copyinstr1", r.qemu.output)
|
|
|
|
@test(19, "usertests: all tests", parent=test_usertests)
|
|
def test_usertests_all():
|
|
r.match('^ALL TESTS PASSED$')
|
|
|
|
@test(1, "time")
|
|
def test_time():
|
|
check_time()
|
|
|
|
run_tests()
|