~ehmry/sigil

7b873f47023e066ae5d8434170e4275ebcbb6d6d — Emery Hemingway 4 years ago dba4d80 sandbox
tests: consolidate sotest to a single project

Make one SoTest run per hydra evaluation.
5 files changed, 45 insertions(+), 54 deletions(-)

M flake.nix
M tests/default.nix
M tests/driver-hw.nix
M tests/driver-nova.nix
M tests/solo5/default.nix
M flake.nix => flake.nix +1 -0
@@ 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};

M tests/default.nix => tests/default.nix +39 -13
@@ 7,7 7,7 @@ let
      signal = call ./signal.nix { };
    } // call ./solo5 { };

in { apps, buildPackages, depot, genodepkgs, lib, nixpkgs }:
in { self, apps, buildPackages, depot, genodepkgs, lib, nixpkgs }:

let
  testPkgs = genodepkgs;


@@ 52,17 52,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));
in with builtins;
listToAttrs ((concatLists (map (testsToList) [ linux hw nova ]))) // {
  sotest = let
    hwTests = [ hw.multi hw.x86 ];
    novaTests = [ nova.multi nova.x86 nova.vmm ];
    allTests = hwTests ++ novaTests;

  nova-sotest = map ({ name, value }: {
    name = name + "-sotest";
    value = value.sotest;
  }) (builtins.filter ({ name, value }: !isNull value.sotest)
    (testsToList nova));
    projectCfg.boot_items =

in with builtins;
listToAttrs ((concatLists (map (testsToList) [ linux hw nova ])) ++ hw-sotest
  ++ nova-sotest)
      (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 = self.lastModified;
    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"
    '';
  };
}

M tests/driver-hw.nix => tests/driver-hw.nix +2 -18
@@ 38,7 38,7 @@ let
    ''run_genode_until {[init] child "harness" exited with exit value 0} 60'';

  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 {

M tests/driver-nova.nix => tests/driver-nova.nix +3 -22
@@ 38,19 38,18 @@ let
    ''run_genode_until {child "init" exited with exit value 0} 60'';

  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 {

M tests/solo5/default.nix => tests/solo5/default.nix +0 -1
@@ 29,7 29,6 @@ let
  tests = [
    {
      name = "multi";
      sotest = true;
      testConfig = "${./.}/solo5.dhall";
      testInputs = map genodeMake [ "app/ping" ] ++ (map genodeDepot [
        "ram_block"