mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 00:08:07 +02:00
* Test for runtime root finding.
This commit is contained in:
parent
dcded7da47
commit
7adaa6d446
5 changed files with 64 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
8
tests/gc-runtime.builder.sh
Normal file
8
tests/gc-runtime.builder.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
mkdir $out
|
||||
|
||||
cat > $out/program <<EOF
|
||||
#! $SHELL
|
||||
sleep 10000
|
||||
EOF
|
||||
|
||||
chmod +x $out/program
|
7
tests/gc-runtime.nix.in
Normal file
7
tests/gc-runtime.nix.in
Normal file
|
@ -0,0 +1,7 @@
|
|||
derivation {
|
||||
name = "gc-runtime";
|
||||
system = "@system@";
|
||||
builder = "@shell@";
|
||||
args = ["-e" "-x" ./gc-runtime.builder.sh];
|
||||
PATH = "@coreutils@";
|
||||
}
|
39
tests/gc-runtime.sh
Normal file
39
tests/gc-runtime.sh
Normal file
|
@ -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
|
Loading…
Reference in a new issue