diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2012-12-06 00:03:26 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2012-12-06 00:07:08 +0100 |
| commit | 69cfce50dbb2000c5f5d98f0f364fe324004bf99 (patch) | |
| tree | ceb925ad7fa3f30b88c6074a071a229a31f769eb | |
| parent | b980f0f9fd6f926f2a1130f77bd3cdb70e741429 (diff) | |
build: Run all the tests against the just-built daemon.
* test-env.in: New file.
* configure.ac: Add it to `AC_CONFIG_FILES' and `commands-exec'.
* config-daemon.ac: Set and substitute `GUIX_TEST_ROOT'.
* Makefile.am (SCM_LOG_COMPILER, SH_LOG_COMPILER): Use it in lieu of
`pre-inst-env'.
* daemon.am (test_root): Remove
(AM_TESTS_ENVIRONMENT): Remove `TEST_ROOT'.
(clean-local): Use $(GUIX_TEST_ROOT); make files writable before
removing them.guix_test_root
* tests/guix-daemon.sh: Remove `NIX_' variable settings; don't launch
`guix-daemon'.
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Makefile.am | 4 | ||||
| -rw-r--r-- | config-daemon.ac | 6 | ||||
| -rw-r--r-- | configure.ac | 5 | ||||
| -rw-r--r-- | daemon.am | 9 | ||||
| -rw-r--r-- | test-env.in | 53 | ||||
| -rw-r--r-- | tests/guix-daemon.sh | 19 |
7 files changed, 68 insertions, 29 deletions
diff --git a/.gitignore b/.gitignore index 3ef17152bac..8f224467c9c 100644 --- a/.gitignore +++ b/.gitignore | |||
| @@ -62,3 +62,4 @@ stamp-h[0-9] | |||
| 62 | /guix-daemon | 62 | /guix-daemon |
| 63 | /test-tmp | 63 | /test-tmp |
| 64 | /nix/scripts/list-runtime-roots | 64 | /nix/scripts/list-runtime-roots |
| 65 | /test-env | ||
diff --git a/Makefile.am b/Makefile.am index 101ac1dfdbb..bb5dfbe0f9a 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -181,10 +181,10 @@ TEST_EXTENSIONS = .scm .sh | |||
| 181 | 181 | ||
| 182 | AM_TESTS_ENVIRONMENT = abs_top_srcdir="$(abs_top_srcdir)" | 182 | AM_TESTS_ENVIRONMENT = abs_top_srcdir="$(abs_top_srcdir)" |
| 183 | 183 | ||
| 184 | SCM_LOG_COMPILER = $(top_builddir)/pre-inst-env $(GUILE) | 184 | SCM_LOG_COMPILER = $(top_builddir)/test-env $(GUILE) |
| 185 | AM_SCM_LOG_FLAGS = --no-auto-compile -L "$(top_srcdir)" | 185 | AM_SCM_LOG_FLAGS = --no-auto-compile -L "$(top_srcdir)" |
| 186 | 186 | ||
| 187 | SH_LOG_COMPILER = $(top_builddir)/pre-inst-env $(SHELL) | 187 | SH_LOG_COMPILER = $(top_builddir)/test-env $(SHELL) |
| 188 | AM_SH_LOG_FLAGS = -x -e | 188 | AM_SH_LOG_FLAGS = -x -e |
| 189 | 189 | ||
| 190 | EXTRA_DIST = \ | 190 | EXTRA_DIST = \ |
diff --git a/config-daemon.ac b/config-daemon.ac index 946f6e453d6..edd372fba97 100644 --- a/config-daemon.ac +++ b/config-daemon.ac | |||
| @@ -92,6 +92,12 @@ if test "x$guix_build_daemon" = "xyes"; then | |||
| 92 | dnl Check for <linux/fs.h> (for immutable file support). | 92 | dnl Check for <linux/fs.h> (for immutable file support). |
| 93 | AC_CHECK_HEADERS([linux/fs.h]) | 93 | AC_CHECK_HEADERS([linux/fs.h]) |
| 94 | 94 | ||
| 95 | dnl Temporary directory used to store the daemon's data. | ||
| 96 | AC_MSG_CHECKING([for unit test root]) | ||
| 97 | GUIX_TEST_ROOT="`pwd`/test-tmp" | ||
| 98 | AC_MSG_RESULT([$GUIX_TEST_ROOT]) | ||
| 99 | AC_SUBST([GUIX_TEST_ROOT]) | ||
| 100 | |||
| 95 | AC_CONFIG_FILES([nix/scripts/list-runtime-roots], | 101 | AC_CONFIG_FILES([nix/scripts/list-runtime-roots], |
| 96 | [chmod +x nix/scripts/list-runtime-roots]) | 102 | [chmod +x nix/scripts/list-runtime-roots]) |
| 97 | fi | 103 | fi |
diff --git a/configure.ac b/configure.ac index 6c7be59895e..5509735d8e1 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -104,9 +104,10 @@ AC_CONFIG_FILES([Makefile | |||
| 104 | guix-download | 104 | guix-download |
| 105 | guix-import | 105 | guix-import |
| 106 | guix-package | 106 | guix-package |
| 107 | pre-inst-env]) | 107 | pre-inst-env |
| 108 | test-env]) | ||
| 108 | 109 | ||
| 109 | AC_CONFIG_COMMANDS([commands-exec], | 110 | AC_CONFIG_COMMANDS([commands-exec], |
| 110 | [chmod +x guix-build guix-download guix-import guix-package pre-inst-env]) | 111 | [chmod +x guix-build guix-download guix-import guix-package pre-inst-env test-env]) |
| 111 | 112 | ||
| 112 | AC_OUTPUT | 113 | AC_OUTPUT |
| @@ -155,15 +155,12 @@ EXTRA_DIST += \ | |||
| 155 | nix/AUTHORS \ | 155 | nix/AUTHORS \ |
| 156 | nix/COPYING | 156 | nix/COPYING |
| 157 | 157 | ||
| 158 | # Temporary directory used to store the daemon's data. | ||
| 159 | test_root = $(abs_top_builddir)/test-tmp | ||
| 160 | |||
| 161 | AM_TESTS_ENVIRONMENT += \ | 158 | AM_TESTS_ENVIRONMENT += \ |
| 162 | top_builddir="$(abs_top_builddir)" \ | 159 | top_builddir="$(abs_top_builddir)" |
| 163 | TEST_ROOT="$(test_root)" | ||
| 164 | 160 | ||
| 165 | TESTS += \ | 161 | TESTS += \ |
| 166 | tests/guix-daemon.sh | 162 | tests/guix-daemon.sh |
| 167 | 163 | ||
| 168 | clean-local: | 164 | clean-local: |
| 169 | -rm -rf "$(test_root)" | 165 | -find "$(GUIX_TEST_ROOT)" | xargs chmod +w |
| 166 | -rm -rf "$(GUIX_TEST_ROOT)" | ||
diff --git a/test-env.in b/test-env.in new file mode 100644 index 00000000000..9eb03dd4988 --- /dev/null +++ b/test-env.in | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Guix --- Nix package management from Guile. -*- coding: utf-8 -*- | ||
| 4 | # Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org> | ||
| 5 | # | ||
| 6 | # This file is part of Guix. | ||
| 7 | # | ||
| 8 | # Guix is free software; you can redistribute it and/or modify it | ||
| 9 | # under the terms of the GNU General Public License as published by | ||
| 10 | # the Free Software Foundation; either version 3 of the License, or (at | ||
| 11 | # your option) any later version. | ||
| 12 | # | ||
| 13 | # Guix is distributed in the hope that it will be useful, but | ||
| 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | # GNU General Public License for more details. | ||
| 17 | # | ||
| 18 | # You should have received a copy of the GNU General Public License | ||
| 19 | # along with Guix. If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | |||
| 21 | # Usage: ./test-env COMMAND ARG... | ||
| 22 | # | ||
| 23 | # Run the daemon in the build directory, and run COMMAND within | ||
| 24 | # `pre-inst-env'. This is used to run unit tests with the just-built | ||
| 25 | # daemon, unless `--disable-daemon' was passed at configure time. | ||
| 26 | |||
| 27 | if [ -x "@abs_top_builddir@/guix-daemon" ] | ||
| 28 | then | ||
| 29 | NIX_SUBSTITUTERS="" # don't resort to substituters | ||
| 30 | NIX_IGNORE_SYMLINK_STORE=1 # in case the store is a symlink | ||
| 31 | NIX_STORE_DIR="@GUIX_TEST_ROOT@/store" | ||
| 32 | NIX_LOCALSTATE_DIR="@GUIX_TEST_ROOT@/var" | ||
| 33 | NIX_LOG_DIR="@GUIX_TEST_ROOT@/var/log/nix" | ||
| 34 | NIX_STATE_DIR="@GUIX_TEST_ROOT@/var/nix-$$" # allow for parallel tests | ||
| 35 | NIX_DB_DIR="@GUIX_TEST_ROOT@/db" | ||
| 36 | NIX_ROOT_FINDER="@abs_top_builddir@/nix/scripts/list-runtime-roots" | ||
| 37 | export NIX_SUBSTITUTERS NIX_IGNORE_SYMLINK_STORE NIX_STORE_DIR \ | ||
| 38 | NIX_LOCALSTATE_DIR NIX_LOG_DIR NIX_STATE_DIR NIX_DB_DIR \ | ||
| 39 | NIX_ROOT_FINDER | ||
| 40 | |||
| 41 | # Do that because store.scm calls `canonicalize-path' on it. | ||
| 42 | mkdir -p "$NIX_STORE_DIR" | ||
| 43 | |||
| 44 | # Launch the daemon without chroot support because is may be | ||
| 45 | # unavailable, for instance if we're not running as root. | ||
| 46 | "@abs_top_builddir@/guix-daemon" --disable-chroot & | ||
| 47 | |||
| 48 | daemon_pid=$! | ||
| 49 | trap "kill $daemon_pid ; rm -rf $NIX_STATE_DIR" EXIT | ||
| 50 | fi | ||
| 51 | |||
| 52 | "@abs_top_builddir@/pre-inst-env" "$@" | ||
| 53 | exit $? | ||
diff --git a/tests/guix-daemon.sh b/tests/guix-daemon.sh index b6b92a78d43..b942cbd5460 100644 --- a/tests/guix-daemon.sh +++ b/tests/guix-daemon.sh | |||
| @@ -22,27 +22,8 @@ | |||
| 22 | 22 | ||
| 23 | set -e | 23 | set -e |
| 24 | 24 | ||
| 25 | NIX_SUBSTITUTERS="" # don't resort to substituters | ||
| 26 | NIX_IGNORE_SYMLINK_STORE=1 # in case the store is a symlink | ||
| 27 | NIX_STORE_DIR="$TEST_ROOT/store" | ||
| 28 | NIX_LOCALSTATE_DIR="$TEST_ROOT/var" | ||
| 29 | NIX_LOG_DIR="$TEST_ROOT/var/log/nix" | ||
| 30 | NIX_STATE_DIR="$TEST_ROOT/var/nix" | ||
| 31 | NIX_DB_DIR="$TEST_ROOT/db" | ||
| 32 | NIX_ROOT_FINDER="$top_builddir/nix/scripts/list-runtime-roots" | ||
| 33 | export NIX_SUBSTITUTERS NIX_IGNORE_SYMLINK_STORE NIX_STORE_DIR \ | ||
| 34 | NIX_LOCALSTATE_DIR NIX_LOG_DIR NIX_STATE_DIR NIX_DB_DIR \ | ||
| 35 | NIX_ROOT_FINDER | ||
| 36 | |||
| 37 | guix-daemon --version | 25 | guix-daemon --version |
| 38 | guix-build --version | 26 | guix-build --version |
| 39 | 27 | ||
| 40 | # Launch the daemon without chroot support because is may be | ||
| 41 | # unavailable, for instance if we're not running as root. | ||
| 42 | guix-daemon --disable-chroot & | ||
| 43 | |||
| 44 | daemon_pid=$! | ||
| 45 | trap "kill $daemon_pid" EXIT | ||
| 46 | |||
| 47 | guix-build -e '(@ (distro packages bootstrap) %bootstrap-guile)' | 28 | guix-build -e '(@ (distro packages bootstrap) %bootstrap-guile)' |
| 48 | guix-build coreutils -n | 29 | guix-build coreutils -n |
