diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-07-21T12·46+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-07-21T12·46+0000 |
commit | 7adaa6d4466063893c9ac6b5b7d71c423be34b69 (patch) | |
tree | 144e3b4f6e9c070d56e45c218e27c5a9e0cc8f57 /tests | |
parent | dcded7da4704ae66ebbb4343597868a7eb992aa7 (diff) |
* Test for runtime root finding.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 5 | ||||
-rw-r--r-- | tests/common.sh.in | 10 | ||||
-rw-r--r-- | tests/gc-runtime.builder.sh | 8 | ||||
-rw-r--r-- | tests/gc-runtime.nix.in | 7 | ||||
-rw-r--r-- | tests/gc-runtime.sh | 39 |
5 files changed, 64 insertions, 5 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 8a432d8996d6..cab1f6a327a2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -13,11 +13,13 @@ fallback.sh: fallback.nix gc-concurrent.sh: gc-concurrent.nix gc-concurrent2.nix user-envs.sh: user-envs.nix fixed.sh: fixed.nix +gc-runtime.sh: gc-runtime.nix TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \ locking.sh parallel.sh build-hook.sh substitutes.sh substitutes2.sh \ fallback.sh nix-push.sh gc.sh gc-concurrent.sh verify.sh nix-pull.sh \ - referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh + referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \ + gc-runtime.sh XFAIL_TESTS = @@ -39,5 +41,6 @@ EXTRA_DIST = $(TESTS) \ fallback.nix.in \ user-envs.nix.in user-envs.builder.sh \ fixed.nix.in fixed.builder1.sh fixed.builder2.sh \ + gc-runtime.nix.in gc-runtime.builder.sh \ $(wildcard lang/*.nix) $(wildcard lang/*.exp) \ common.sh.in diff --git a/tests/common.sh.in b/tests/common.sh.in index f96f28d206c9..12162649e4b2 100644 --- a/tests/common.sh.in +++ b/tests/common.sh.in @@ -1,10 +1,12 @@ set -e -# Maybe the build directory is symlinked. -export NIX_IGNORE_SYMLINK_STORE=1 - export TEST_ROOT=$(pwd)/test-tmp -export NIX_STORE_DIR=$TEST_ROOT/store +export NIX_STORE_DIR +if ! NIX_STORE_DIR=$(readlink -f $TEST_ROOT/store); then + # Maybe the build directory is symlinked. + export NIX_IGNORE_SYMLINK_STORE=1 + NIX_STORE_DIR=$TEST_ROOT/store +fi export NIX_DATA_DIR=$TEST_ROOT/data export NIX_LOCALSTATE_DIR=$TEST_ROOT/var export NIX_LOG_DIR=$TEST_ROOT/var/log/nix diff --git a/tests/gc-runtime.builder.sh b/tests/gc-runtime.builder.sh new file mode 100644 index 000000000000..a8c2d3e09150 --- /dev/null +++ b/tests/gc-runtime.builder.sh @@ -0,0 +1,8 @@ +mkdir $out + +cat > $out/program <<EOF +#! $SHELL +sleep 10000 +EOF + +chmod +x $out/program diff --git a/tests/gc-runtime.nix.in b/tests/gc-runtime.nix.in new file mode 100644 index 000000000000..e54fcf2d15ad --- /dev/null +++ b/tests/gc-runtime.nix.in @@ -0,0 +1,7 @@ +derivation { + name = "gc-runtime"; + system = "@system@"; + builder = "@shell@"; + args = ["-e" "-x" ./gc-runtime.builder.sh]; + PATH = "@coreutils@"; +} diff --git a/tests/gc-runtime.sh b/tests/gc-runtime.sh new file mode 100644 index 000000000000..5a6e0da8cda2 --- /dev/null +++ b/tests/gc-runtime.sh @@ -0,0 +1,39 @@ +source common.sh + +case $system in + *linux*) + ;; + *) + exit 0; +esac + +set -m # enable job control, needed for kill + +profiles="$NIX_STATE_DIR"/profiles +rm -f $profiles/* + +$nixenv -p $profiles/test -f ./gc-runtime.nix -i gc-runtime + +outPath=$($nixenv -p $profiles/test -q --no-name --out-path gc-runtime) +echo $outPath + +echo "backgrounding program..." +$profiles/test/program & +child=$! +echo PID=$child + +$nixenv -p $profiles/test -e gc-runtime +$nixenv -p $profiles/test --delete-generations old + +cp $TOP/scripts/find-runtime-roots.pl $TEST_ROOT/foo.pl +chmod +x $TEST_ROOT/foo.pl +NIX_ROOT_FINDER=$TEST_ROOT/foo.pl $nixstore --gc + +kill -- -$child + +if ! test -e $outPath; then + echo "running program was garbage collected!" + exit 1 +fi + +exit 0 |