From d8ba46e74294baaf773ff2c2c58b474fea3c2b09 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Sun, 26 Apr 2020 10:49:07 +0530 Subject: [PATCH] tests: consolidate sotest to a single project Make one SoTest run per hydra evaluation. --- flake.nix | 1 + tests/default.nix | 54 ++++++++++++++++++++++++++++++----------- tests/driver-hw.nix | 20 ++------------- tests/driver-nova.nix | 25 +++---------------- tests/solo5/default.nix | 1 - 5 files changed, 46 insertions(+), 55 deletions(-) diff --git a/flake.nix b/flake.nix index 451156e..1e25e01 100644 --- a/flake.nix +++ b/flake.nix @@ -120,6 +120,7 @@ checks = let checks' = forAllCrossSystems ({ system, localSystem, crossSystem }: import ./tests { + inherit self; apps = self.apps.${system}; buildPackages = nixpkgsFor.${localSystem}; depot = genode-depot.packages.${system}; diff --git a/tests/default.nix b/tests/default.nix index 8fa1b19..7d6c8cd 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -2,7 +2,7 @@ let tests = call: { log = call ./log.nix { }; }; -in { apps, buildPackages, depot, genodepkgs, lib, nixpkgs }: +in { self, apps, buildPackages, depot, genodepkgs, lib, nixpkgs }: let testPkgs = genodepkgs; @@ -47,17 +47,43 @@ let value = test; }) (builtins.attrValues tests); - hw-sotest = map ({ name, value }: { - name = name + "-sotest"; - value = value.sotest; - }) (builtins.filter ({ name, value }: !isNull value.sotest) (testsToList hw)); - - nova-sotest = map ({ name, value }: { - name = name + "-sotest"; - value = value.sotest; - }) (builtins.filter ({ name, value }: !isNull value.sotest) - (testsToList nova)); - in with builtins; -listToAttrs ((concatLists (map (testsToList) [ linux hw nova ])) ++ hw-sotest - ++ nova-sotest) +listToAttrs ((concatLists (map (testsToList) [ linux hw nova ]))) // { + sotest = let + hwTests = [ hw.multi hw.x86 ]; + novaTests = [ nova.multi nova.x86 nova.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 { + pname = "sotest"; + version = toString self.revCount; + buildCommand = '' + mkdir zip; cd zip + cp "${testPkgs.bender}" bender + cp "${testPkgs.NOVA}/hypervisor-x86_64" hypervisor + ${concatStringsSep "\n" + (map (test: "cp ${test.image} ${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" + ''; + }; +} diff --git a/tests/driver-hw.nix b/tests/driver-hw.nix index ab7b6f1..c0780f1 100644 --- a/tests/driver-hw.nix +++ b/tests/driver-hw.nix @@ -38,7 +38,7 @@ let ''run_genode_until {child "init" exited with exit value 0} 120''; mkTest = { name ? "unamed", testScript ? defaultScript, testConfig - , testInputs ? [ ], testEnv ? { }, qemuArgs ? [ ], sotest ? false, ... }@t: + , testInputs ? [ ], testEnv ? { }, qemuArgs ? [ ], ... }@t: let manifest = lib.mergeManifests (map addManifest (with testPkgs; [ base-hw-pc sotest-producer ] @@ -49,7 +49,7 @@ let DHALL_GENODE_TEST = "${./test.dhall}"; } // testEnv; - image = lib.hwImage name testEnv' testConfig'; + image = lib.hwImage ("hw-" + name) testEnv' testConfig'; baseSetup = '' ## @@ -142,22 +142,6 @@ let xml = buildPackages.runCommand (name + ".config") testEnv' ''${apps.render-init.program} <<< "(${testConfig'}).config" > $out''; - sotest = if sotest then - buildPackages.runCommand "hw-${name}-sotest" testEnv' '' - cp "${testPkgs.bender}" bender - cp ${image} image.elf - mkdir -p $out/nix-support - ${buildPackages.zip}/bin/zip "$out/binaries.zip" \ - image.elf - ${apps.dhall-to-yaml.program} < ${ - ./sotest_hw_config.dhall - } > "$out/sotest_config.yaml" - echo file sotest-binaries $out/binaries.zip >> "$out/nix-support/hydra-build-products" - echo file sotest-config $out/sotest_config.yaml >> "$out/nix-support/hydra-build-products" - '' - else - null; - }; in { diff --git a/tests/driver-nova.nix b/tests/driver-nova.nix index f196ffc..6f82d09 100644 --- a/tests/driver-nova.nix +++ b/tests/driver-nova.nix @@ -38,19 +38,18 @@ let ''run_genode_until {child "init" exited with exit value 0} 120''; mkTest = { name ? "unamed", testScript ? defaultScript, testConfig - , testInputs ? [ ], testEnv ? { }, qemuArgs ? [ ], sotest ? false, ... }@t: + , testInputs ? [ ], testEnv ? { }, qemuArgs ? [ ], ... }@t: let manifest = lib.mergeManifests (map addManifest (with testPkgs; [ base-nova sotest-producer ] - ++ map genodeSources.depot [ "init" "rtc_drv" ] - ++ testInputs)); + ++ map genodeSources.depot [ "init" "rtc_drv" ] ++ testInputs)); testConfig' = "${./test-wrapper.dhall} ${testConfig} (toMap ${manifest})"; testEnv' = { DHALL_GENODE = "${testPkgs.dhallGenode}/source.dhall"; DHALL_GENODE_TEST = "${./test.dhall}"; } // testEnv; - image = lib.novaImage name testEnv' testConfig'; + image = lib.novaImage ("nova-" + name) testEnv' testConfig'; build = lib.compileBoot name testEnv' testConfig'; baseSetup = '' @@ -144,24 +143,6 @@ let compile = lib.compileBoot name testConfig'; iso = apps.nova-iso.function testEnv' "${testConfig'}"; - - sotest = if sotest then - buildPackages.runCommand "nova-${name}-sotest" testEnv' '' - cp "${testPkgs.bender}" bender - cp "${testPkgs.NOVA}/hypervisor-x86_64" hypervisor - cp ${image} image.elf - mkdir -p $out/nix-support - ${buildPackages.zip}/bin/zip "$out/binaries.zip" \ - hypervisor image.elf - ${apps.dhall-to-yaml.program} < ${ - ./sotest_nova_config.dhall - } > "$out/sotest_config.yaml" - echo file sotest-binaries $out/binaries.zip >> "$out/nix-support/hydra-build-products" - echo file sotest-config $out/sotest_config.yaml >> "$out/nix-support/hydra-build-products" - '' - else - null; - }; in { diff --git a/tests/solo5/default.nix b/tests/solo5/default.nix index 6d0d775..7413aa6 100644 --- a/tests/solo5/default.nix +++ b/tests/solo5/default.nix @@ -29,7 +29,6 @@ let tests = [ { name = "multi"; - sotest = true; testConfig = "${./.}/solo5.dhall"; testInputs = map genodeMake [ "app/ping" ] ++ (map genodeDepot [ "ram_block"