summaryrefslogtreecommitdiff
path: root/build-aux/test-env.in
diff options
context:
space:
mode:
authorMathieu Lirzin <mthl@gnu.org>2016-04-03 18:18:46 +0200
committerMathieu Lirzin <mthl@gnu.org>2016-04-15 00:59:07 +0200
commita1097caa6a30f45661ee510c59bf0e01972cebba (patch)
tree6ffe4997938608d555e5ecddbbdb267226e82246 /build-aux/test-env.in
parente66d1f59abc02d60be3328cb511452fec946bbb0 (diff)
build: Move environment '.in' scripts to 'build-aux' directory.
* pre-inst-env.in: Move to ... * build-aux/pre-inst-env.in: ... here. * test-env.in: Move to ... * build-aux/test-env.in: ... here. * configure.ac (AC_CONFIG_FILES): Adapt to this. Keep the generated scripts in their current location which is $(top_builddir).
Diffstat (limited to 'build-aux/test-env.in')
-rw-r--r--build-aux/test-env.in131
1 files changed, 131 insertions, 0 deletions
diff --git a/build-aux/test-env.in b/build-aux/test-env.in
new file mode 100644
index 00000000000..c3f60f7283b
--- /dev/null
+++ b/build-aux/test-env.in
@@ -0,0 +1,131 @@
1#!/bin/sh
2
3# GNU Guix --- Functional package management for GNU
4# Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
5#
6# This file is part of GNU Guix.
7#
8# GNU 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# GNU 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 GNU 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
28# Make sure 'cd' behaves deterministically and doesn't write anything to
29# stdout.
30unset CDPATH
31
32if [ -x "@abs_top_builddir@/guix-daemon" ]
33then
34 # Silence the daemon's output, which is often useless, as well as that of
35 # Bash (such as "Terminated" messages when 'guix-daemon' is killed.)
36 exec 2> /dev/null
37
38 NIX_STORE_DIR="@GUIX_TEST_ROOT@/store"
39
40 # Do that because store.scm calls `canonicalize-path' on it.
41 mkdir -p "$NIX_STORE_DIR"
42
43 # Canonicalize the store directory name in an attempt to avoid symlinks in
44 # it or its parent directories. See <http://bugs.gnu.org/17935>.
45 NIX_STORE_DIR="`cd "@GUIX_TEST_ROOT@/store"; pwd -P`"
46
47 NIX_LOCALSTATE_DIR="@GUIX_TEST_ROOT@/var"
48 NIX_LOG_DIR="@GUIX_TEST_ROOT@/var/log/guix"
49 NIX_DB_DIR="@GUIX_TEST_ROOT@/db"
50 NIX_ROOT_FINDER="@abs_top_builddir@/nix/scripts/list-runtime-roots"
51
52 # Choose a PID-dependent name to allow for parallel builds. Note
53 # that the directory name must be chosen so that the socket's file
54 # name is less than 108-char long (the size of `sun_path' in glibc).
55 # Currently, in Nix builds, we're at ~106 chars...
56 NIX_STATE_DIR="@GUIX_TEST_ROOT@/var/$$"
57
58 # We can't exit when we reach the limit, because perhaps the test doesn't
59 # actually rely on the daemon, but at least warn.
60 if test "`echo -n "$NIX_STATE_DIR/daemon-socket/socket" | wc -c`" -ge 108
61 then
62 echo "warning: exceeding socket file name limit; test may fail!" >&2
63 fi
64
65 # The configuration directory, for import/export signing keys.
66 NIX_CONF_DIR="@GUIX_TEST_ROOT@/etc"
67 if [ ! -d "$NIX_CONF_DIR" ]
68 then
69 # Copy the keys so that the secret key has the right permissions (the
70 # daemon errors out when this is not the case.)
71 mkdir -p "$NIX_CONF_DIR"
72 cp "@abs_top_srcdir@/tests/signing-key.sec" \
73 "@abs_top_srcdir@/tests/signing-key.pub" \
74 "$NIX_CONF_DIR"
75 chmod 400 "$NIX_CONF_DIR/signing-key.sec"
76 fi
77
78 # A place to store data of the substituter.
79 GUIX_BINARY_SUBSTITUTE_URL="file://$NIX_STATE_DIR/substituter-data"
80 rm -rf "$NIX_STATE_DIR/substituter-data"
81 mkdir -p "$NIX_STATE_DIR/substituter-data"
82
83 # For a number of tests, we want to allow unsigned narinfos, for
84 # simplicity.
85 GUIX_ALLOW_UNAUTHENTICATED_SUBSTITUTES=yes
86
87 # Place for the substituter's cache.
88 XDG_CACHE_HOME="$NIX_STATE_DIR/cache-$$"
89
90 # For the (guix import snix) tests.
91 NIXPKGS="@NIXPKGS@"
92
93 export NIX_IGNORE_SYMLINK_STORE NIX_STORE_DIR \
94 NIX_LOCALSTATE_DIR NIX_LOG_DIR NIX_STATE_DIR NIX_DB_DIR \
95 NIX_ROOT_FINDER GUIX_BINARY_SUBSTITUTE_URL \
96 GUIX_ALLOW_UNAUTHENTICATED_SUBSTITUTES \
97 NIX_CONF_DIR XDG_CACHE_HOME NIXPKGS
98
99 # Launch the daemon without chroot support because is may be
100 # unavailable, for instance if we're not running as root.
101 "@abs_top_builddir@/pre-inst-env" \
102 "@abs_top_builddir@/guix-daemon" --disable-chroot \
103 --substitute-urls="$GUIX_BINARY_SUBSTITUTE_URL" &
104
105 daemon_pid=$!
106 trap "kill $daemon_pid ; rm -rf $NIX_STATE_DIR" EXIT
107fi
108
109# Avoid issues that could stem from l10n, such as language/encoding
110# mismatches.
111unset LANGUAGE
112LC_MESSAGES=C
113export LC_MESSAGES
114
115# Disable grafts by default because they can cause things to be built
116# regardless of '--dry-run'.
117GUIX_BUILD_OPTIONS="--no-grafts"
118export GUIX_BUILD_OPTIONS
119
120# Ignore user settings.
121unset GUIX_PACKAGE_PATH
122
123storedir="@storedir@"
124prefix="@prefix@"
125datarootdir="@datarootdir@"
126datadir="@datadir@"
127localstatedir="@localstatedir@"
128export storedir prefix datarootdir datadir localstatedir
129
130"@abs_top_builddir@/pre-inst-env" "$@"
131exit $?