14 Star 217 Fork 313

kikiyu/chcore-lab

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
grade-lab1 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
dongzy 提交于 2020-11-24 19:53 +08:00 . lab1
#!/usr/bin/env python3
import re
from gradelib import *
r = Runner(save("chcore.out"),
stop_breakpoint("break_point"))
@test(0, "running ChCore")
def test_chcore():
r.run_qemu(30)
@test(15, parent=test_chcore)
def test_print_hex():
addrs = [int(sym[:16], 16) for sym in open("./build/kernel.sym")
if sym[19:].strip() == "main"]
r.match("\[INFO\] Address of main\(\) is 0x%x" % addrs[0])
@test(15, parent=test_chcore)
def test_print_oct():
r.match("\[INFO\] 123456 decimal is 0361100 octal")
BACKTRACE_RE = r" *LR *ffffff00000[0-9a-z]{5} *FP *ffffff0000[0-9a-z]{6} *Args *([0-9a-z]+)"
BACKTRACE_LR = r" *LR *(ffffff00000[0-9a-z]{5}) *FP *ffffff0000[0-9a-z]{6} *Args *[0-9a-z]+"
@test(15, parent=test_chcore)
def test_stack_count():
matches = re.findall(BACKTRACE_RE, r.qemu.output, re.MULTILINE)
assert_equal(len(matches), 7)
@test(15, parent=test_chcore)
def test_stack_arguments():
matches = re.findall(BACKTRACE_RE, r.qemu.output, re.MULTILINE)
assert_equal("\n".join(matches[:6]),
"\n".join("%01x" % n for n in [0,1,2,3,4,5]))
@test(20, parent=test_chcore)
def test_stack_lr():
matches = re.findall(BACKTRACE_LR, r.qemu.output, re.MULTILINE)
addrs = [int(sym[:16], 16) for sym in open("./build/kernel.sym")
if sym[19:].strip() == "stack_test"][0] + 80
for i in range(5):
assert_equal(int(matches[i], 16), addrs)
run_tests()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C/C++
1
https://gitee.com/ipads-lab/chcore-lab.git
git@gitee.com:ipads-lab/chcore-lab.git
ipads-lab
chcore-lab
chcore-lab
lab5

搜索帮助