From 5c9e9f732df6d95d712f25de9880b7461c53d6ca Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 30 Jun 2011 15:19:13 +0000 Subject: Add support for the `build-timeout' and `--timeout' options. --- tests/Makefile.am | 3 ++- tests/timeout.builder.sh | 2 ++ tests/timeout.nix | 8 ++++++++ tests/timeout.sh | 24 ++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 tests/timeout.builder.sh create mode 100644 tests/timeout.nix create mode 100644 tests/timeout.sh (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index fb4a2285c1d5..d383bce248ea 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -8,7 +8,7 @@ TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \ referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \ gc-runtime.sh install-package.sh check-refs.sh filter-source.sh \ remote-store.sh export.sh export-graph.sh negative-caching.sh \ - binary-patching.sh + binary-patching.sh timeout.sh XFAIL_TESTS = @@ -33,5 +33,6 @@ EXTRA_DIST = $(TESTS) \ export-graph.nix \ negative-caching.nix \ binary-patching.nix \ + timeout.nix timeout.builder.sh \ $(wildcard lang/*.nix) $(wildcard lang/*.exp) $(wildcard lang/*.exp.xml) $(wildcard lang/*.flags) \ common.sh.in diff --git a/tests/timeout.builder.sh b/tests/timeout.builder.sh new file mode 100644 index 000000000000..3e6e1fc0429a --- /dev/null +++ b/tests/timeout.builder.sh @@ -0,0 +1,2 @@ +echo "\`timeout' builder entering an infinite loop" +while true ; do : ; done diff --git a/tests/timeout.nix b/tests/timeout.nix new file mode 100644 index 000000000000..dec258801e3f --- /dev/null +++ b/tests/timeout.nix @@ -0,0 +1,8 @@ +with import ./config.nix; + +mkDerivation { + name = "timeout"; + builder = ./timeout.builder.sh; + PATH = ""; + goodPath = path; +} diff --git a/tests/timeout.sh b/tests/timeout.sh new file mode 100644 index 000000000000..f27739fb2b52 --- /dev/null +++ b/tests/timeout.sh @@ -0,0 +1,24 @@ +# Test the `--timeout' option. + +source common.sh + +drvPath=$($nixinstantiate timeout.nix) + +test "$($nixstore -q --binding system "$drvPath")" = "$system" + +echo "derivation is $drvPath" + +failed=0 +messages="`$nixstore -r --timeout 2 $drvPath 2>&1 || failed=1`" +if test $failed -ne 0; then + echo "error: \`nix-store' succeeded; should have timed out" >&2 + exit 1 +fi + +if ! echo "$messages" | grep "timed out"; then + echo "error: \`nix-store' may have failed for reasons other than timeout" >&2 + echo >&2 + echo "output of \`nix-store' follows:" >&2 + echo "$messages" >&2 + exit 1 +fi -- cgit 1.4.1