run-tests cd into each test directory before running it

This commit is contained in:
Daniel Barlow 2022-09-23 17:21:43 +01:00
parent 1bc8fd7873
commit 7a4314baee
4 changed files with 14 additions and 12 deletions

View file

@ -3,7 +3,9 @@
export DEVICE=${DEVICE-qemu} export DEVICE=${DEVICE-qemu}
export TMPDIR=${TMPDIR-/tmp} export TMPDIR=${TMPDIR-/tmp}
NIX_PATH=liminix=`pwd`:$NIX_PATH
for i in tests/*/run.sh; do for i in tests/*/run.sh; do
echo $i echo $i
$i $* || exit 1 (cd `dirname $i`; ./`basename $i` $* ) || exit 1
done done

View file

@ -1,5 +1,5 @@
set -e set -e
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build -I liminix-config=./tests/smoke/configuration.nix --arg device "import ./devices/$DEVICE.nix" -A outputs.kernel.vmlinux -o vmlinux $* NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build '<liminix>' -I liminix-config=../smoke/configuration.nix --arg device "import <liminix/devices/$DEVICE.nix>" -A outputs.kernel.vmlinux -o vmlinux $*
TESTS=$(cat <<"EOF" TESTS=$(cat <<"EOF"

View file

@ -2,16 +2,16 @@ set -e
expr=$(cat <<"EXPR" expr=$(cat <<"EXPR"
let let
overlay = import ./overlay.nix; overlay = import <liminix/overlay.nix>;
nixpkgs = import <nixpkgs> ( {overlays = [overlay]; }); nixpkgs = import <nixpkgs> { overlays = [overlay]; };
structure = import ./tests/pseudofiles/structure.nix; structure = import ./structure.nix;
in nixpkgs.pkgs.pseudofile "pseudo.s6-init" structure in nixpkgs.pkgs.pseudofile "pseudo.s6-init" structure
EXPR EXPR
) )
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build -E "${expr}" -o tests/pseudofiles/result $* NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build -E "${expr}" -o result $*
diff tests/pseudofiles/result tests/pseudofiles/result.expected diff result result.expected
test -f /tmp/out.squashfs && rm /tmp/out.squashfs test -f /tmp/out.squashfs && rm /tmp/out.squashfs
nix-shell -p squashfsTools -p qprint --run "mksquashfs - /tmp/out.squashfs -p '/ d 755 0 0' -pf tests/pseudofiles/result -quiet -no-progress" nix-shell -p squashfsTools -p qprint --run "mksquashfs - /tmp/out.squashfs -p '/ d 755 0 0' -pf result -quiet -no-progress"
foo="$(nix-shell -p squashfsTools --run 'unsquashfs -cat /tmp/out.squashfs service/s6-linux-init-runleveld/run')" foo="$(nix-shell -p squashfsTools --run 'unsquashfs -cat /tmp/out.squashfs service/s6-linux-init-runleveld/run')"
test "$foo" = "$(printf "hello\nworld")" test "$foo" = "$(printf "hello\nworld")"

View file

@ -1,14 +1,14 @@
set -e set -e
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build -I liminix-config=./tests/smoke/configuration.nix --arg device "import ./devices/$DEVICE.nix" -o smoke.img NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build '<liminix>' -I liminix-config=./configuration.nix --arg device "import <liminix/devices/$DEVICE.nix>" -A outputs.squashfs -o smoke.img $*
TESTS=$(cat <<"EOF" TESTS=$(cat <<"EOF"
trap 'echo "command $(eval echo $BASH_COMMAND) failed with exit code $?"; exit $?' ERR trap 'echo "command $(eval echo $BASH_COMMAND) failed with exit code $?"; exit $?' ERR
dest_path=${TMPDIR}/smoke.img-$$ dest_path=${TMPDIR}/smoke.img-$$
echo $dest_path echo $dest_path
unsquashfs -q -d $dest_path smoke.img unsquashfs -q -d $dest_path -excludes smoke.img /dev
cd $dest_path; cd $dest_path;
db=*-s6-rc-db/compiled/ db=nix/store/*-s6-rc-db/compiled/
test -d $db test -d $db
chmod -R +w $db chmod -R +w $db
# check we have closure of config.services (lo.link.service exists only # check we have closure of config.services (lo.link.service exists only