zig libvirt: start adding tests, and improve Domain
This commit is contained in:
parent
02bd0b6ccd
commit
c4f178bc1f
6 changed files with 287 additions and 47 deletions
|
@ -1,4 +1,6 @@
|
|||
const std = @import("std");
|
||||
const Build = std.Build;
|
||||
const Step = Build.Step;
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
|
@ -38,14 +40,35 @@ pub fn build(b: *std.Build) !void {
|
|||
const run_step = b.step("run", "Run the app");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
|
||||
const exe_unit_tests = b.addTest(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
const libvirt_test = b.addTest(.{
|
||||
.root_source_file = b.path("src/libvirt.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
});
|
||||
const libvirt_connection_test = b.addTest(.{
|
||||
.root_source_file = b.path("src/libvirt-connection.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
});
|
||||
const libvirt_unit_tests = [_]*Step.Compile{
|
||||
libvirt_test,
|
||||
libvirt_connection_test,
|
||||
};
|
||||
for (libvirt_unit_tests) |tests| {
|
||||
tests.root_module.addIncludePath(b.path("libvirt/include"));
|
||||
tests.addLibraryPath(b.path("libvirt/lib"));
|
||||
tests.addObjectFile(b.path("libvirt/lib/libvirt.so.0.10000.0"));
|
||||
tests.addObjectFile(b.path("libvirt/lib/libvirt-admin.so.0.10000.0"));
|
||||
tests.addObjectFile(b.path("libvirt/lib/libvirt-qemu.so.0.10000.0"));
|
||||
}
|
||||
|
||||
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
|
||||
const run_libvirt_tests = [_]*Step.Run{
|
||||
b.addRunArtifact(libvirt_test),
|
||||
b.addRunArtifact(libvirt_connection_test),
|
||||
};
|
||||
|
||||
const test_step = b.step("test", "Run unit tests");
|
||||
test_step.dependOn(&run_exe_unit_tests.step);
|
||||
for (run_libvirt_tests) |tests| test_step.dependOn(&tests.step);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue