Fixed tesing

Add mocking of functions


Added new function type


Fixed up the mock testing


Working mock_framework :), fixed up all tests for VGA and TTY


Adding tests


VGA testing done


Fin vga and tty mock testing


Fixed build


Removed white spaces


WIP


Added tests for all build modes + reduced import string length for testing


Added comments refactoring


Re-added constants


Added some comments


Updated to master of zig


Added unit tests to pipeline


PR comments


Fixed typos
This commit is contained in:
ED 2019-09-08 20:48:23 +01:00
parent 89c47d064b
commit d5d4082a66
24 changed files with 1812 additions and 829 deletions

View file

@ -4,6 +4,7 @@ const Builder = std.build.Builder;
const Step = std.build.Step;
const Target = std.build.Target;
const fs = std.fs;
const Mode = builtin.Mode;
pub fn build(b: *Builder) !void {
const target = Target{
@ -13,12 +14,19 @@ pub fn build(b: *Builder) !void {
.abi = .gnu,
},
};
const target_str = switch (target.getArch()) {
builtin.Arch.i386 => "x86",
else => unreachable,
};
const debug = b.option(bool, "debug", "build with debug symbols / make qemu wait for a debug connection") orelse false;
const rt_test = b.option(bool, "rt-test", "enable/disable runtime testing") orelse false;
const main_src = "src/kernel/kmain.zig";
const exec = b.addExecutable("pluto", main_src);
exec.setMainPkgPath(".");
const const_path = try fs.path.join(b.allocator, [_][]const u8{ "src/kernel/arch/", target_str, "/constants.zig" });
exec.addPackagePath("constants", const_path);
exec.addBuildOption(bool, "rt_test", rt_test);
exec.setLinkerScriptPath("link.ld");
exec.setTheTarget(target);
@ -72,10 +80,17 @@ pub fn build(b: *Builder) !void {
const script = b.addSystemCommand([_][]const u8{ "python3", "test/rt-test.py", "x86", b.zig_exe });
test_step.dependOn(&script.step);
} else {
const unit_tests = b.addTest(main_src);
unit_tests.setMainPkgPath(".");
unit_tests.addBuildOption(bool, "rt_test", rt_test);
test_step.dependOn(&unit_tests.step);
inline for ([_]Mode{ Mode.Debug, Mode.ReleaseFast, Mode.ReleaseSafe, Mode.ReleaseSmall }) |test_mode| {
const mode_str = comptime modeToString(test_mode);
const unit_tests = b.addTest("test/unittests/test_all.zig");
unit_tests.setBuildMode(test_mode);
unit_tests.setMainPkgPath(".");
unit_tests.setNamePrefix(mode_str ++ " - ");
unit_tests.addPackagePath("mocking", "test/mock/kernel/mocking.zig");
unit_tests.addPackagePath("constants", const_path);
unit_tests.addBuildOption(bool, "rt_test", rt_test);
test_step.dependOn(&unit_tests.step);
}
}
const debug_step = b.step("debug", "Debug with gdb");
@ -91,3 +106,12 @@ pub fn build(b: *Builder) !void {
});
debug_step.dependOn(&debug_cmd.step);
}
fn modeToString(comptime mode: Mode) []const u8 {
return switch (mode) {
Mode.Debug => "debug",
Mode.ReleaseFast => "release-fast",
Mode.ReleaseSafe => "release-safe",
Mode.ReleaseSmall => "release-small",
};
}