summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile.am4
-rw-r--r--config-daemon.ac6
-rw-r--r--configure.ac5
-rw-r--r--daemon.am9
-rw-r--r--test-env.in53
-rw-r--r--tests/guix-daemon.sh19
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
182AM_TESTS_ENVIRONMENT = abs_top_srcdir="$(abs_top_srcdir)" 182AM_TESTS_ENVIRONMENT = abs_top_srcdir="$(abs_top_srcdir)"
183 183
184SCM_LOG_COMPILER = $(top_builddir)/pre-inst-env $(GUILE) 184SCM_LOG_COMPILER = $(top_builddir)/test-env $(GUILE)
185AM_SCM_LOG_FLAGS = --no-auto-compile -L "$(top_srcdir)" 185AM_SCM_LOG_FLAGS = --no-auto-compile -L "$(top_srcdir)"
186 186
187SH_LOG_COMPILER = $(top_builddir)/pre-inst-env $(SHELL) 187SH_LOG_COMPILER = $(top_builddir)/test-env $(SHELL)
188AM_SH_LOG_FLAGS = -x -e 188AM_SH_LOG_FLAGS = -x -e
189 189
190EXTRA_DIST = \ 190EXTRA_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])
97fi 103fi
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
109AC_CONFIG_COMMANDS([commands-exec], 110AC_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
112AC_OUTPUT 113AC_OUTPUT
diff --git a/daemon.am b/daemon.am
index f5d58ea2751..8c2c22dd887 100644
--- a/daemon.am
+++ b/daemon.am
@@ -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.
159test_root = $(abs_top_builddir)/test-tmp
160
161AM_TESTS_ENVIRONMENT += \ 158AM_TESTS_ENVIRONMENT += \
162 top_builddir="$(abs_top_builddir)" \ 159 top_builddir="$(abs_top_builddir)"
163 TEST_ROOT="$(test_root)"
164 160
165TESTS += \ 161TESTS += \
166 tests/guix-daemon.sh 162 tests/guix-daemon.sh
167 163
168clean-local: 164clean-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
27if [ -x "@abs_top_builddir@/guix-daemon" ]
28then
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
50fi
51
52"@abs_top_builddir@/pre-inst-env" "$@"
53exit $?
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
23set -e 23set -e
24 24
25NIX_SUBSTITUTERS="" # don't resort to substituters
26NIX_IGNORE_SYMLINK_STORE=1 # in case the store is a symlink
27NIX_STORE_DIR="$TEST_ROOT/store"
28NIX_LOCALSTATE_DIR="$TEST_ROOT/var"
29NIX_LOG_DIR="$TEST_ROOT/var/log/nix"
30NIX_STATE_DIR="$TEST_ROOT/var/nix"
31NIX_DB_DIR="$TEST_ROOT/db"
32NIX_ROOT_FINDER="$top_builddir/nix/scripts/list-runtime-roots"
33export 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
37guix-daemon --version 25guix-daemon --version
38guix-build --version 26guix-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.
42guix-daemon --disable-chroot &
43
44daemon_pid=$!
45trap "kill $daemon_pid" EXIT
46
47guix-build -e '(@ (distro packages bootstrap) %bootstrap-guile)' 28guix-build -e '(@ (distro packages bootstrap) %bootstrap-guile)'
48guix-build coreutils -n 29guix-build coreutils -n