summaryrefslogtreecommitdiff
path: root/grade-lab-traps
diff options
context:
space:
mode:
authorSanjit Bhat <[email protected]>2023-09-13 01:24:07 -0400
committerSanjit Bhat <[email protected]>2023-09-13 01:24:07 -0400
commite7ad79c0c51a27efcdcc94c4bc848ca0f41937e1 (patch)
tree05f5b9b2de7af2ef674070b1e4cd690a9b521f58 /grade-lab-traps
parent74c1eba516fdb0ec1a17b16be7e76613ccba92bf (diff)
downloadxv6-labs-e7ad79c0c51a27efcdcc94c4bc848ca0f41937e1.tar.gz
xv6-labs-e7ad79c0c51a27efcdcc94c4bc848ca0f41937e1.tar.bz2
xv6-labs-e7ad79c0c51a27efcdcc94c4bc848ca0f41937e1.zip
release traps
Diffstat (limited to 'grade-lab-traps')
-rwxr-xr-xgrade-lab-traps69
1 files changed, 69 insertions, 0 deletions
diff --git a/grade-lab-traps b/grade-lab-traps
new file mode 100755
index 0000000..afa93b8
--- /dev/null
+++ b/grade-lab-traps
@@ -0,0 +1,69 @@
+#!/usr/bin/env python3
+
+import os
+import re
+import subprocess
+from gradelib import *
+
+r = Runner(save("xv6.out"))
+
+BACKTRACE_RE = r"^(0x000000008[0-9a-f]+)"
+
+def addr2line():
+ for f in ['riscv64-unknown-elf-addr2line', 'riscv64-linux-gnu-addr2line', 'addr2line', ]:
+ try:
+ devnull = open(os.devnull)
+ subprocess.Popen([f], stdout=devnull, stderr=devnull).communicate()
+ return f
+ except OSError:
+ continue
+ raise AssertionError('Cannot find the addr2line program')
+
+@test(10, "backtrace test")
+def test_backtracetest():
+ r.run_qemu(shell_script([
+ 'bttest'
+ ]))
+ a2l = addr2line()
+ matches = re.findall(BACKTRACE_RE, r.qemu.output, re.MULTILINE)
+ assert_equal(len(matches), 3)
+ files = ['sysproc.c', 'syscall.c', 'trap.c']
+ for f, m in zip(files, matches):
+ result = subprocess.run([a2l, '-e', 'kernel/kernel', m], stdout=subprocess.PIPE)
+ if not f in result.stdout.decode("utf-8"):
+ raise AssertionError('Trace is incorrect; no %s' % f)
+
+@test(0, "running alarmtest")
+def test_alarmtest():
+ r.run_qemu(shell_script([
+ 'alarmtest'
+ ]))
+
+@test(20, "alarmtest: test0", parent=test_alarmtest)
+def test_alarmtest_test0():
+ r.match('^test0 passed$')
+
+@test(20, "alarmtest: test1", parent=test_alarmtest)
+def test_alarmtest_test1():
+ r.match('^\\.?test1 passed$')
+
+@test(10, "alarmtest: test2", parent=test_alarmtest)
+def test_alarmtest_test2():
+ r.match('^\\.?test2 passed$')
+
+@test(10, "alarmtest: test3", parent=test_alarmtest)
+def test_alarmtest_test3():
+ r.match('^test3 passed$')
+
+@test(19, "usertests")
+def test_usertests():
+ r.run_qemu(shell_script([
+ 'usertests -q'
+ ]), timeout=300)
+ r.match('^ALL TESTS PASSED$')
+
+@test(1, "time")
+def test_time():
+ check_time()
+
+run_tests()