2
0
Fork 0
genodepkgs/tests/default.nix

96 lines
2.8 KiB
Nix

# SPDX-License-Identifier: CC0-1.0
let tests = call: { log = call ./log.nix { }; };
in { self, apps, buildPackages, genodepkgs, lib, nixpkgs, legacyPackages }:
let
testPkgs = genodepkgs;
addManifest = drv:
drv // {
manifest = nixpkgs.runCommand "${drv.name}.dhall" { inherit drv; } ''
set -eu
echo -n '[' >> $out
find $drv/ -type f -printf ',{mapKey= "%f",mapValue="%p"}' >> $out
${if builtins.elem "lib" drv.outputs then
''
find ${drv.lib}/ -type f -printf ',{mapKey= "%f",mapValue="%p"}' >> $out''
else
""}
echo -n ']' >> $out
'';
};
linux =
(call: ((tests call) // { block_router = call ./block_router.nix { }; }))
(import ./driver-linux.nix {
inherit apps addManifest buildPackages lib nixpkgs testPkgs;
}).callTest;
nova = (call:
((tests call) // {
driver_manager = call ./driver_manager.nix { };
posix = call ./posix.nix { };
vmm = call ./vmm_x86.nix { };
x86 = call ./x86.nix { };
} // call ./solo5 { })) (import ./driver-nova.nix {
inherit apps addManifest buildPackages lib nixpkgs testPkgs
legacyPackages;
}).callTest;
hw = (call:
((tests call) // {
posix = call ./posix.nix { };
x86 = call ./x86.nix { };
} // call ./solo5 { })) (import ./driver-hw.nix {
inherit apps addManifest buildPackages lib nixpkgs testPkgs
legacyPackages;
}).callTest;
testsToList = tests:
map (test: {
inherit (test) name;
value = test;
}) (builtins.attrValues tests);
in with builtins;
listToAttrs ((concatLists (map (testsToList) [ linux hw nova ]))) // {
sotest = let
hwTests = with hw; [ multi posix x86 ];
novaTests = with nova; [ multi posix x86 vmm ];
allTests = hwTests ++ novaTests;
projectCfg.boot_items =
(map (test: {
inherit (test) name;
exec = "bender";
load = [ test.image.name ];
}) hwTests)
++ (map (test: {
inherit (test) name;
exec = "bender";
load = [ "hypervisor serial novga iommu" test.image.name ];
}) novaTests);
in buildPackages.stdenv.mkDerivation {
name = "sotest";
buildCommand = ''
mkdir zip; cd zip
cp "${testPkgs.bender}/bender" bender
cp "${testPkgs.NOVA}/hypervisor-x86_64" hypervisor
${concatStringsSep "\n"
(map (test: "cp ${test.image}/image.elf ${test.image.name}") allTests)}
mkdir -p $out/nix-support
${buildPackages.zip}/bin/zip "$out/binaries.zip" *
cat << EOF > "$out/project.json"
${builtins.toJSON projectCfg}
EOF
echo file sotest-binaries $out/binaries.zip >> "$out/nix-support/hydra-build-products"
echo file sotest-config $out/project.json >> "$out/nix-support/hydra-build-products"
'';
};
}