forked from DGNum/liminix
convert test script to derivation
This commit is contained in:
parent
3b1bc7eff8
commit
a0380728a5
3 changed files with 66 additions and 62 deletions
47
tests/pseudofiles/fixture.nix
Normal file
47
tests/pseudofiles/fixture.nix
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
{
|
||||||
|
pseudofile
|
||||||
|
}: let
|
||||||
|
inherit (pseudofile) dir;
|
||||||
|
structure = {
|
||||||
|
service = dir {
|
||||||
|
s6-linux-init-runleveld = dir {
|
||||||
|
notification-fd = { file = "3"; };
|
||||||
|
run = {
|
||||||
|
file = ''
|
||||||
|
hello
|
||||||
|
world
|
||||||
|
'';
|
||||||
|
mode = "0755";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
s6-linux-init-shutdownd = dir {
|
||||||
|
fifo = {
|
||||||
|
type = "i";
|
||||||
|
subtype = "f";
|
||||||
|
mode = "0600";
|
||||||
|
};
|
||||||
|
run = {
|
||||||
|
file = ''
|
||||||
|
s6-linux-init/bin/s6-linux-init-shutdownd -c "/etc/s6-linux-init/current" -g 3000
|
||||||
|
'';
|
||||||
|
mode = "0755";
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
s6-svscan-log = dir {
|
||||||
|
fifo = {
|
||||||
|
type = "i";
|
||||||
|
subtype = "f";
|
||||||
|
mode = "0600";
|
||||||
|
};
|
||||||
|
notification-fd = { file = "3"; };
|
||||||
|
run = {
|
||||||
|
file = ''
|
||||||
|
gdsgdfgsdgf
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
uncaught-logs = (dir {}) // {mode = "2750";};
|
||||||
|
};
|
||||||
|
in pseudofile.write "pseudo.s6-init" structure
|
|
@ -1,16 +0,0 @@
|
||||||
set -e
|
|
||||||
|
|
||||||
expr=$(cat <<"EXPR"
|
|
||||||
let
|
|
||||||
overlay = import <liminix/overlay.nix>;
|
|
||||||
nixpkgs = import <nixpkgs> { overlays = [overlay]; };
|
|
||||||
in nixpkgs.pkgs.callPackage ./test.nix {}
|
|
||||||
EXPR
|
|
||||||
)
|
|
||||||
|
|
||||||
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build -E "${expr}" -o result $*
|
|
||||||
diff result result.expected
|
|
||||||
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 result -quiet -no-progress"
|
|
||||||
foo="$(nix-shell -p squashfsTools --run 'unsquashfs -cat /tmp/out.squashfs service/s6-linux-init-runleveld/run')"
|
|
||||||
test "$foo" = "$(printf "hello\nworld")"
|
|
65
tests/pseudofiles/test.nix
Normal file → Executable file
65
tests/pseudofiles/test.nix
Normal file → Executable file
|
@ -1,47 +1,20 @@
|
||||||
{
|
{
|
||||||
pseudofile
|
liminix
|
||||||
}: let
|
, nixpkgs
|
||||||
inherit (pseudofile) dir;
|
}:
|
||||||
structure = {
|
let
|
||||||
service = dir {
|
overlay = import "${liminix}/overlay.nix";
|
||||||
s6-linux-init-runleveld = dir {
|
nixpkgs = import <nixpkgs> { overlays = [overlay]; };
|
||||||
notification-fd = { file = "3"; };
|
fixture = nixpkgs.callPackage ./fixture.nix {};
|
||||||
run = {
|
check = nixpkgs.runCommand "check" {
|
||||||
file = ''
|
nativeBuildInputs = with nixpkgs; [ squashfsTools qprint ] ;
|
||||||
hello
|
} ''
|
||||||
world
|
set -e
|
||||||
'';
|
diff ${fixture} ${./result.expected}
|
||||||
mode = "0755";
|
test -f /tmp/out.squashfs && rm /tmp/out.squashfs
|
||||||
};
|
mksquashfs - /tmp/out.squashfs -p '/ d 755 0 0' -pf ${fixture} -quiet -no-progress
|
||||||
};
|
foo="$(unsquashfs -cat /tmp/out.squashfs service/s6-linux-init-runleveld/run)"
|
||||||
s6-linux-init-shutdownd = dir {
|
test "$foo" = "$(printf "hello\nworld")"
|
||||||
fifo = {
|
date > $out
|
||||||
type = "i";
|
'';
|
||||||
subtype = "f";
|
in { inherit check; }
|
||||||
mode = "0600";
|
|
||||||
};
|
|
||||||
run = {
|
|
||||||
file = ''
|
|
||||||
s6-linux-init/bin/s6-linux-init-shutdownd -c "/etc/s6-linux-init/current" -g 3000
|
|
||||||
'';
|
|
||||||
mode = "0755";
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
s6-svscan-log = dir {
|
|
||||||
fifo = {
|
|
||||||
type = "i";
|
|
||||||
subtype = "f";
|
|
||||||
mode = "0600";
|
|
||||||
};
|
|
||||||
notification-fd = { file = "3"; };
|
|
||||||
run = {
|
|
||||||
file = ''
|
|
||||||
gdsgdfgsdgf
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
uncaught-logs = (dir {}) // {mode = "2750";};
|
|
||||||
};
|
|
||||||
in pseudofile.write "pseudo.s6-init" structure
|
|
||||||
|
|
Loading…
Reference in a new issue