2
0
Fork 0
20.02
Emery Hemingway 3 years ago
parent e4b6421545
commit 4d51c1671f
  1. 8
      release.nix
  2. 101
      tests/default.nix
  3. 38
      tests/driver-config.xml
  4. 18
      tests/libc.nix
  5. 21
      tests/libc.xml
  6. 14
      tests/log.nix
  7. 34
      tests/log.xml
  8. 14
      tests/signal.nix
  9. 21
      tests/signal.xml
  10. 49
      tests/test-driver.exp

@ -4,7 +4,9 @@
{ genodepkgs ? builtins.fetchGit ./., nixpkgs ? <nixpkgs> }:
{
build.x86_64 = let pkgs = import ./default.nix { inherit nixpkgs; };
in { inherit (pkgs) genode nova stdenv; };
let pkgs = import ./default.nix { inherit nixpkgs; };
in {
build.x86_64 = { inherit (pkgs) genode nova stdenv; };
tests.x86_64 = import ./tests { inherit pkgs; };
}

@ -0,0 +1,101 @@
# SPDX-FileCopyrightText: Emery Hemingway
#
# SPDX-License-Identifier: LicenseRef-Hippocratic-1.1
{ pkgs ? (import ./.. { }) }:
let
lib = pkgs.buildPackages.pkgs.lib // {
renderDhallInit = path: args:
pkgs.buildPackages.runCommand "init.xml" {
buildInputs = with pkgs.buildPackages; [ dhall-text libxml2 ];
initConfig = path;
initArgs = args;
DHALL_PRELUDE = "${pkgs.dhallPackages.prelude}/package.dhall";
DHALL_GENODE = "${pkgs.dhallPackages.genode}/package.dhall";
} ''
echo '(env:DHALL_GENODE).Init.render (env:initConfig initArgs)' \
| dhall-to-text \
| xmllint -format - \
> $out
'';
};
testDriver = with pkgs.buildPackages;
stdenv.mkDerivation {
name = "genode-test-driver";
buildInputs = [ makeWrapper expect ];
dontUnpack = true;
preferLocalBuild = true;
installPhase = ''
install -Dm555 ${./test-driver.exp} $out/bin/genode-test-driver
wrapProgram $out/bin/genode-test-driver \
--prefix PATH : "${lib.makeBinPath [ expect coreutils ]}"
'';
};
runTests = driver:
pkgs.stdenv.mkDerivation {
name = "test-run-${driver.testName}";
buildCommand = ''
mkdir -p $out/nix-support
${driver}/bin/genode-test-driver | tee $out/log
touch $out/nix-support
echo "report testlog $out log" >> $out/nix-support/hydra-build-products
'';
};
makeTest = { testScript, testConfig, name ? "unamed", ... }@t:
let
baseSetup = with pkgs; ''
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
file link -s init ${depot.init}/bin/init
file link -s config ${./driver-config.xml}
file link -s test.config $env(testConfig)
'';
driver = pkgs.buildPackages.runCommand "genode-test-driver-${name}" {
buildInputs = with pkgs.buildPackages; [ makeWrapper expect ];
inherit baseSetup testConfig testScript;
preferLocalBuild = true;
testName = name;
} ''
mkdir -p $out/bin
echo "$testConfig" > $out/test.config
echo "$testScript" > $out/test-script
echo "$baseSetup" > $out/base-setup
ln -s ${testDriver}/bin/genode-test-driver $out/bin/
wrapProgram $out/bin/genode-test-driver \
--run "export testConfig=\"$testConfig\"" \
--run "export testScript=\"\$(cat $out/test-script)\"" \
--run "export baseSetup=\"\$(cat $out/base-setup)\"" \
'';
passMeta = drv:
drv
// lib.optionalAttrs (t ? meta) { meta = (drv.meta or { }) // t.meta; };
test = passMeta (runTests driver);
in test // { inherit driver test; };
callTest = path: args: makeTest (import path ({ inherit pkgs lib; } // args));
in {
libc = callTest ./libc.nix { };
log = callTest ./log.nix { };
signal = callTest ./signal.nix { };
}

@ -0,0 +1,38 @@
<?xml version="1.0"?>
<config prio_levels="2">
<parent-provides>
<service name="ROM"/>
<service name="IRQ"/>
<service name="IO_MEM"/>
<service name="IO_PORT"/>
<service name="PD"/>
<service name="RM"/>
<service name="CPU"/>
<service name="LOG"/>
</parent-provides>
<default-route>
<any-service>
<parent/>
<any-child/>
</any-service>
</default-route>
<start name="timer" caps="96">
<resource name="RAM" quantum="1M"/>
<provides>
<service name="Timer"/>
</provides>
</start>
<start name="init" caps="8000" priority="-1">
<resource name="RAM" quantum="286M"/>
<exit propagate="yes"/>
<route>
<service name="ROM" label="config">
<parent label="test.config"/>
</service>
<any-service>
<parent/>
<any-child/>
</any-service>
</route>
</start>
</config>

@ -0,0 +1,18 @@
{ pkgs, lib }:
with pkgs;
rec {
name = "libc";
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ];
testConfig = ./libc.xml;
testScript = ''
file link -s libc.lib.so ${depot.libc}/lib/libc.lib.so
file link -s libm.lib.so ${depot.libc}/lib/libm.lib.so
file link -s posix.lib.so ${depot.posix}/lib/posix.lib.so
file link -s vfs.lib.so ${depot.vfs}/lib/vfs.lib.so
file link -s test-libc ${depot.test-libc}/bin/test-libc
run_genode_until "child .* exited with exit value 0.*\n" 30
'';
}

@ -0,0 +1,21 @@
<config>
<parent-provides>
<service name="ROM"/>
<service name="PD"/>
<service name="RM"/>
<service name="CPU"/>
<service name="LOG"/>
<service name="Timer"/>
</parent-provides>
<default-route>
<any-service> <parent/> <any-child/> </any-service>
</default-route>
<default caps="200"/>
<start name="test-libc">
<resource name="RAM" quantum="400M"/>
<config>
<vfs> <dir name="dev"> <log/> <inline name="rtc">2019-08-20 15:01</inline> </dir> </vfs>
<libc stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc"/>
</config>
</start>
</config>

@ -0,0 +1,14 @@
{ pkgs, lib }:
with pkgs;
rec {
name = "log";
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ];
testConfig = ./log.xml;
testScript = ''
file link -s test-log ${genode.base}/bin/test-log/test-log
run_genode_until {Test done.} 10
'';
}

@ -0,0 +1,34 @@
<?xml version="1.0"?>
<config verbose="yes">
<parent-provides>
<service name="LOG"/>
<service name="ROM"/>
<service name="CPU"/>
<service name="RM"/>
<service name="PD"/>
</parent-provides>
<start name="test-log" caps="50">
<resource name="RAM" quantum="1048576"/>
<provides/>
<exit propagate="yes"/>
<binary name="test-log"/>
<config/>
<route>
<service name="PD">
<parent/>
</service>
<service name="RM">
<parent/>
</service>
<service name="CPU">
<parent/>
</service>
<service name="ROM">
<parent/>
</service>
<service name="LOG">
<parent/>
</service>
</route>
</start>
</config>

@ -0,0 +1,14 @@
{ pkgs, lib }:
with pkgs;
rec {
name = "signal";
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ];
testConfig = ./signal.xml;
testScript = ''
file link -s test-signal ${depot.test-signal}/bin/test-signal
run_genode_until {--- Signalling test finished ---} 60
'';
}

@ -0,0 +1,21 @@
<?xml version="1.0"?>
<config>
<parent-provides>
<service name="ROM"/>
<service name="CPU"/>
<service name="RM"/>
<service name="PD"/>
<service name="LOG"/>
<service name="Timer"/>
</parent-provides>
<default-route>
<any-service>
<parent/>
<any-child/>
</any-service>
</default-route>
<default caps="100"/>
<start name="test-signal" caps="500">
<resource name="RAM" quantum="10M"/>
</start>
</config>

@ -0,0 +1,49 @@
#! /usr/bin/env expect
##
# Wait for a specific output of a already running spawned process
#
proc wait_for_output { wait_for_re timeout_value running_spawn_id } {
global output
if {$wait_for_re == "forever"} {
set timeout -1
interact {
\003 {
send_user "Expect: 'interact' received 'strg+c' and was cancelled\n";
exit
}
-i $running_spawn_id
}
} else {
set timeout $timeout_value
}
expect {
-i $running_spawn_id -re $wait_for_re { }
eof { puts stderr "Error: Spawned process died unexpectedly"; exit -1 }
timeout { puts stderr "Error: Test execution timed out"; exit -1 }
}
set output $expect_out(buffer)
}
proc run_genode_until {{wait_for_re forever} {timeout_value 0} {running_spawn_id -1}} {
#
# If a running_spawn_id is specified, wait for the expected output
#
if {$running_spawn_id != -1} {
wait_for_output $wait_for_re $timeout_value $running_spawn_id
return
}
global image_dir spawn_id
spawn ./core
wait_for_output $wait_for_re $timeout_value $spawn_id
}
eval $env(baseSetup)
eval $env(testScript)
Loading…
Cancel
Save