2
0
Fork 0

Use a host-only Nixpkgs for test environment

Discriminate test-packages and host-packages when building tests.
This avoids the test tooling being tainted with the hostPlatform
and targetPlatform of the test. For example, QEMU must be built
independently and isolated from the guest platform, for the sake
of test control and minimizing rebuilds.
This commit is contained in:
Emery Hemingway 2019-10-07 17:05:37 +02:00
parent 70c090af51
commit 693ac303e0
4 changed files with 45 additions and 35 deletions

View File

@ -16,12 +16,7 @@ let
toolchainOverlay = import ./toolchain-overlay;
# Overlay of toolchain patches
nixpkgs' = builtins.fetchGit {
# A branch of Nixpkgs with a custom "crossSystem" mechanism
url = "https://github.com/ehmry/nixpkgs.git";
ref = "hybrid-19.09";
rev = "9a704b7def9bc9ea04d12d6a0d55ebebe0af982a";
};
nixpkgs' = import ./nixpkgs.nix;
in { nixpkgs ? nixpkgs', dhall-haskell ? ./dhall-haskell.nix }:

6
nixpkgs.nix Normal file
View File

@ -0,0 +1,6 @@
# A branch of Nixpkgs with a custom "crossSystem" mechanism
builtins.fetchGit {
url = "https://github.com/ehmry/nixpkgs.git";
ref = "hybrid-19.09";
rev = "9a704b7def9bc9ea04d12d6a0d55ebebe0af982a";
}

View File

@ -10,21 +10,24 @@ let
signal = call ./signal.nix { };
solo5 = call ./solo5.nix { };
};
in { pkgs ? (import ./.. { }) }:
nixpkgs' = import ./../nixpkgs.nix;
in { nixpkgs ? nixpkgs' }:
let
hostPkgs = import nixpkgs { };
testPkgs = import ./.. { inherit nixpkgs; };
lib = pkgs.buildPackages.pkgs.lib // {
lib = hostPkgs.lib // {
renderDhallInit = path: args:
pkgs.buildPackages.runCommand "init.xml" {
buildInputs = with pkgs.buildPackages; [ linux-dhall ];
hostPkgs.runCommand "init.xml" {
buildInputs = [ testPkgs.buildPackages.linux-dhall ];
initConfig = path;
initArgs = args;
DHALL_PRELUDE = "${pkgs.dhallPackages.prelude}/package.dhall";
DHALL_GENODE = "${pkgs.dhallPackages.genode}/package.dhall";
DHALL_PRELUDE = "${testPkgs.dhallPackages.prelude}/package.dhall";
DHALL_GENODE = "${testPkgs.dhallPackages.genode}/package.dhall";
} ''
set -v
export XDG_CACHE_HOME=$NIX_BUILD_TOP
echo 'let Prelude = env:DHALL_GENODE in Prelude.Init.render (Prelude.Init.defaults { children = toMap (env:initConfig env:initArgs) })' \
| dhall text \
> $out
@ -33,5 +36,6 @@ let
};
in {
linux = tests (import ./driver-linux.nix { inherit pkgs lib; }).callTest;
linux = tests
(import ./driver-linux.nix { inherit testPkgs hostPkgs lib; }).callTest;
}

View File

@ -2,10 +2,10 @@
#
# SPDX-License-Identifier: LicenseRef-Hippocratic-1.1
{ pkgs, lib }:
{ testPkgs, hostPkgs, lib }:
let
testDriver = with pkgs.buildPackages;
testDriver = with hostPkgs;
stdenv.mkDerivation {
name = "genode-test-driver";
@ -23,7 +23,7 @@ let
};
runTests = driver:
pkgs.stdenv.mkDerivation {
hostPkgs.stdenv.mkDerivation {
name = "test-run-${driver.testName}";
buildCommand = ''
@ -39,7 +39,7 @@ let
makeTest = { testScript, testConfig, name ? "unamed", ... }@t:
let
baseSetup = with pkgs; ''
baseSetup = with testPkgs; ''
file link -s core ${depot.base-linux}/bin/core
file link -s timer ${depot.base-linux}/bin/timer
file link -s ld.lib.so ${depot.base-linux}/lib/ld.lib.so
@ -48,8 +48,9 @@ let
file link -s test.config $env(testConfig)
'';
driver = pkgs.buildPackages.runCommand "genode-test-driver-${name}" {
buildInputs = with pkgs.buildPackages; [ makeWrapper expect ];
driver = with hostPkgs;
runCommand "genode-test-driver-${name}" {
buildInputs = [ makeWrapper expect ];
inherit baseSetup testConfig testScript;
preferLocalBuild = true;
testName = name;
@ -74,5 +75,9 @@ let
in test // { inherit driver test; };
in {
callTest = path: args: makeTest (import path ({ inherit pkgs lib; } // args));
callTest = path: args:
makeTest (import path ({
pkgs = testPkgs;
inherit lib;
} // args));
}