67 lines
1.6 KiB
Python
Executable File
67 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import re
|
|
import subprocess
|
|
from gradelib import *
|
|
|
|
r = Runner(save("xv6.out"))
|
|
|
|
serverout = None
|
|
|
|
@test(0, "running nettest")
|
|
def test_nettest():
|
|
global serverout
|
|
server = subprocess.Popen(["python3", "./nettest.py", "grade"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
r.run_qemu(shell_script([
|
|
'nettest grade'
|
|
]), timeout=30)
|
|
server.terminate()
|
|
serverout = server.communicate()[0].decode()
|
|
|
|
@test(20, "nettest: txone", parent=test_nettest)
|
|
def test_nettest_():
|
|
assert_lines_match(serverout, 'txone: OK')
|
|
|
|
@test(20, "nettest: arp_rx", parent=test_nettest)
|
|
def test_nettest_():
|
|
r.match('arp_rx: received an ARP packet')
|
|
|
|
@test(20, "nettest: ip_rx", parent=test_nettest)
|
|
def test_nettest_():
|
|
r.match('ip_rx: received an IP packet')
|
|
|
|
@test(20, "nettest: ping0", parent=test_nettest)
|
|
def test_nettest_():
|
|
r.match('^ping0: OK$')
|
|
|
|
@test(20, "nettest: ping1", parent=test_nettest)
|
|
def test_nettest_():
|
|
r.match('^ping1: OK$')
|
|
|
|
@test(20, "nettest: ping2", parent=test_nettest)
|
|
def test_nettest_():
|
|
r.match('^ping2: OK$')
|
|
|
|
@test(30, "nettest: ping3", parent=test_nettest)
|
|
def test_nettest_():
|
|
r.match('^ping3: OK$')
|
|
|
|
@test(10, "nettest: dns", parent=test_nettest)
|
|
def test_nettest_():
|
|
r.match('^dns: OK$')
|
|
|
|
@test(10, "nettest: free", parent=test_nettest)
|
|
def test_nettest_():
|
|
r.match('^free: OK$')
|
|
|
|
#@test(10, "answers-net.txt")
|
|
#def test_answers():
|
|
# # just a simple sanity check, will be graded manually
|
|
# check_answers("answers-net.txt")
|
|
|
|
@test(1, "time")
|
|
def test_time():
|
|
check_time()
|
|
|
|
run_tests()
|