aboutsummaryrefslogtreecommitdiff
path: root/grade-lab-pgtbl
diff options
context:
space:
mode:
authorFrans Kaashoek <kaashoek@mit.edu>2022-09-19 17:19:32 -0400
committerFrans Kaashoek <kaashoek@mit.edu>2022-09-19 17:19:32 -0400
commitb1083ee059a2aa0e018676f4f3790cb3bafaa1c5 (patch)
treecfacff0e94df41b092fcfda9cdabd854b5b38945 /grade-lab-pgtbl
parent4b46c0c6eb464782faa36d158246ba4e3238c970 (diff)
downloadxv6-labs-2022-b1083ee059a2aa0e018676f4f3790cb3bafaa1c5.tar.xz
xv6-labs-2022-b1083ee059a2aa0e018676f4f3790cb3bafaa1c5.zip
Diffstat (limited to 'grade-lab-pgtbl')
-rwxr-xr-xgrade-lab-pgtbl78
1 files changed, 78 insertions, 0 deletions
diff --git a/grade-lab-pgtbl b/grade-lab-pgtbl
new file mode 100755
index 0000000..4224d00
--- /dev/null
+++ b/grade-lab-pgtbl
@@ -0,0 +1,78 @@
+#!/usr/bin/env python3
+
+import re
+from gradelib import *
+
+r = Runner(save("xv6.out"))
+
+PTE_PRINT = """page table 0x0000000087f6e000
+ ..0: pte 0x0000000021fda801 pa 0x0000000087f6a000
+ .. ..0: pte 0x0000000021fda401 pa 0x0000000087f69000
+ .. .. ..0: pte 0x0000000021fdac1f pa 0x0000000087f6b000
+ .. .. ..1: pte 0x0000000021fda00f pa 0x0000000087f68000
+ .. .. ..2: pte 0x0000000021fd9c1f pa 0x0000000087f67000
+ ..255: pte 0x0000000021fdb401 pa 0x0000000087f6d000
+ .. ..511: pte 0x0000000021fdb001 pa 0x0000000087f6c000
+ .. .. ..509: pte 0x0000000021fdd813 pa 0x0000000087f76000
+ .. .. ..510: pte 0x0000000021fddc07 pa 0x0000000087f77000
+ .. .. ..511: pte 0x0000000020001c0b pa 0x0000000080007000"""
+
+VAL_RE = "(0x00000000[0-9a-f]+)"
+INDENT_RE = r"\s*\.\.\s*"
+INDENT_ESC = "\\\s*\.\.\\\s*"
+
+@test(0, "pgtbltest")
+def test_pgtbltest():
+ r.run_qemu(shell_script([
+ 'pgtbltest'
+ ]), timeout=300)
+
+@test(10, "pgtbltest: ugetpid", parent=test_pgtbltest)
+def test_nettest_():
+ r.match('^ugetpid_test: OK$')
+
+@test(10, "pgtbltest: pgaccess", parent=test_pgtbltest)
+def test_nettest_():
+ r.match('^pgaccess_test: OK$')
+
+@test(10, "pte printout")
+def test_pteprint():
+ first = True
+ r.run_qemu(shell_script([
+ 'echo hi'
+ ]))
+ r.match('^hi')
+ p = re.compile(VAL_RE)
+ d = re.compile(INDENT_RE)
+ for l in PTE_PRINT.splitlines():
+ l = d.sub(INDENT_ESC, l)
+ l = p.sub(VAL_RE, l)
+ r.match(r'^{}$'.format(l))
+ if first:
+ first = False
+ else:
+ matches = re.findall(r'^{}$'.format(l), r.qemu.output, re.MULTILINE)
+ assert_equal(len(matches[0]), 2)
+ pa = (int(matches[0][0], 16) >> 10) << 12
+ assert_equal(int(matches[0][1], 16), pa)
+
+@test(5, "answers-pgtbl.txt")
+def test_answers():
+ # just a simple sanity check, will be graded manually
+ check_answers("answers-pgtbl.txt")
+
+@test(0, "usertests")
+def test_usertests():
+ r.run_qemu(shell_script([
+ 'usertests -q'
+ ]), timeout=300)
+
+@test(10, "usertests: all tests", parent=test_usertests)
+def test_usertests():
+ r.match('^ALL TESTS PASSED$')
+
+@test(1, "time")
+def test_time():
+ check_time()
+
+run_tests()