Added runtime tests for VGA

Added doc comments as well
A little refactor of code
Reordered


Removed types
This commit is contained in:
ED 2019-09-29 12:55:34 +01:00
parent b682afa79d
commit 420a09f039
9 changed files with 267 additions and 150 deletions

View file

@ -1,4 +1,4 @@
def getTestCases(TestCase):
def get_test_cases(TestCase):
return [
TestCase("GDT init", [r"Init gdt", r"Done"]),
TestCase("GDT tests", [r"GDT: Tested loading GDT"]),

View file

@ -1,14 +1,17 @@
const mock_framework = @import("mock_framework.zig");
pub const initTest = mock_framework.initTest;
pub const freeTest = mock_framework.freeTest;
pub const addTestParams = mock_framework.addTestParams;
pub const addConsumeFunction = mock_framework.addConsumeFunction;
pub const addRepeatFunction = mock_framework.addRepeatFunction;
pub const Level = enum {
INFO,
DEBUG,
WARNING,
ERROR
ERROR,
};
fn logCallback(context: void, str: []const u8) anyerror!void {}
pub fn log(comptime level: Level, comptime format: []const u8, args: ...) void {
//return mock_framework.performAction("log", void, level, format, args);
}
@ -28,23 +31,3 @@ pub fn logWarning(comptime format: []const u8, args: ...) void {
pub fn logError(comptime format: []const u8, args: ...) void {
//return mock_framework.performAction("logError", void, format, args);
}
pub fn addRepeatFunction(comptime fun_name: []const u8, function: var) void {
mock_framework.addRepeatFunction(fun_name, function);
}
pub fn addTestFunction(comptime fun_name: []const u8, function: var) void {
mock_framework.addRepeatFunction(fun_name, function);
}
pub fn addTestParams(comptime fun_name: []const u8, params: ...) void {
mock_framework.addTestParams(fun_name, params);
}
pub fn initTest() void {
mock_framework.initTest();
}
pub fn freeTest() void {
mock_framework.freeTest();
}

View file

@ -18,6 +18,20 @@ def test_failure(case, exp, expected_idx, found):
def test_pass(case, exp, expected_idx, found):
print("PASS: %s #%d, expected '%s', found '%s'" %(case.name, expected_idx + 1, exp, found))
def get_pre_archinit_cases():
return [
TestCase("Arch init starts", [r"Init arch \w+"])
]
def get_post_archinit_cases():
return [
TestCase("Arch init finishes", [r"Arch init done"]),
TestCase("VGA init", [r"Init vga", r"Done"]),
TestCase("VGA tests", [r"VGA: Tested max scan line", r"VGA: Tested cursor shape", r"VGA: Tested updating cursor"]),
TestCase("TTY init", [r"Init tty", r"Done"]),
TestCase("Init finishes", [r"Init done"])
]
if __name__ == "__main__":
arch = sys.argv[1]
zig_path = sys.argv[2]
@ -25,18 +39,10 @@ if __name__ == "__main__":
arch_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(arch_module)
# The list of log statements to look for before arch init is called
pre_archinit_cases = [
TestCase("Arch init starts", [r"Init arch \w+"])
]
# The list of log statements to look for before arch init is called +
# All log statements to look for, including the arch-specific ones +
# The list of log statements to look for after arch init is called
post_archinit_cases = [
TestCase("Arch init finishes", [r"Arch init done"]),
TestCase("TTY init", [r"Init tty", r"Done"]),
TestCase("Init finishes", [r"Init done"])
]
# All log statements to look for, including the arch-specific ones
cases = pre_archinit_cases + arch_module.getTestCases(TestCase) + post_archinit_cases
cases = get_pre_archinit_cases() + arch_module.get_test_cases(TestCase) + get_post_archinit_cases()
if len(cases) > 0:
proc = subprocess.Popen(zig_path + " build run -Drt-test=true", stdout=subprocess.PIPE, shell=True)
@ -47,7 +53,7 @@ if __name__ == "__main__":
expected_idx = 0
# Go through the expected log messages
while expected_idx < len(case.expected):
e = "\[INFO\] " + case.expected[expected_idx]
e = r"\[INFO\] " + case.expected[expected_idx]
line = proc.stdout.readline().decode("utf-8")
if not line:
break