gnu: gtk+: Update to 3.16.0.
[guix.git] / test-env.in
bloba7f506ec1923c559e16c127accd9458a44cc597d
1 #!/bin/sh
3 # GNU Guix --- Functional package management for GNU
4 # Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
6 # This file is part of GNU Guix.
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.
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.
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/>.
21 # Usage: ./test-env COMMAND ARG...
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.
28 # Make sure 'cd' behaves deterministically and doesn't write anything to
29 # stdout.
30 unset CDPATH
32 if [ -x "@abs_top_builddir@/guix-daemon" ]
33 then
34 NIX_SETUID_HELPER="@abs_top_builddir@/nix-setuid-helper" # normally unused
35 NIX_STORE_DIR="@GUIX_TEST_ROOT@/store"
37 # Do that because store.scm calls `canonicalize-path' on it.
38 mkdir -p "$NIX_STORE_DIR"
40 # Canonicalize the store directory name in an attempt to avoid symlinks in
41 # it or its parent directories. See <http://bugs.gnu.org/17935>.
42 NIX_STORE_DIR="`cd "@GUIX_TEST_ROOT@/store"; pwd -P`"
44 NIX_LOCALSTATE_DIR="@GUIX_TEST_ROOT@/var"
45 NIX_LOG_DIR="@GUIX_TEST_ROOT@/var/log/guix"
46 NIX_DB_DIR="@GUIX_TEST_ROOT@/db"
47 NIX_ROOT_FINDER="@abs_top_builddir@/nix/scripts/list-runtime-roots"
49 # Choose a PID-dependent name to allow for parallel builds. Note
50 # that the directory name must be chosen so that the socket's file
51 # name is less than 108-char long (the size of `sun_path' in glibc).
52 # Currently, in Nix builds, we're at ~106 chars...
53 NIX_STATE_DIR="@GUIX_TEST_ROOT@/var/$$"
55 # We can't exit when we reach the limit, because perhaps the test doesn't
56 # actually rely on the daemon, but at least warn.
57 if test "`echo -n "$NIX_STATE_DIR/daemon-socket/socket" | wc -c`" -ge 108
58 then
59 echo "warning: exceeding socket file name limit; test may fail!" >&2
62 # The configuration directory, for import/export signing keys.
63 NIX_CONF_DIR="@GUIX_TEST_ROOT@/etc"
64 if [ ! -d "$NIX_CONF_DIR" ]
65 then
66 # Copy the keys so that the secret key has the right permissions (the
67 # daemon errors out when this is not the case.)
68 mkdir -p "$NIX_CONF_DIR"
69 cp "@abs_top_srcdir@/tests/signing-key.sec" \
70 "@abs_top_srcdir@/tests/signing-key.pub" \
71 "$NIX_CONF_DIR"
72 chmod 400 "$NIX_CONF_DIR/signing-key.sec"
75 # A place to store data of the substituter.
76 GUIX_BINARY_SUBSTITUTE_URL="file://$NIX_STATE_DIR/substituter-data"
77 rm -rf "$NIX_STATE_DIR/substituter-data"
78 mkdir -p "$NIX_STATE_DIR/substituter-data"
80 # For a number of tests, we want to allow unsigned narinfos, for
81 # simplicity.
82 GUIX_ALLOW_UNAUTHENTICATED_SUBSTITUTES=yes
84 # Place for the substituter's cache.
85 XDG_CACHE_HOME="$NIX_STATE_DIR/cache-$$"
87 export NIX_IGNORE_SYMLINK_STORE NIX_STORE_DIR \
88 NIX_LOCALSTATE_DIR NIX_LOG_DIR NIX_STATE_DIR NIX_DB_DIR \
89 NIX_ROOT_FINDER NIX_SETUID_HELPER GUIX_BINARY_SUBSTITUTE_URL \
90 GUIX_ALLOW_UNAUTHENTICATED_SUBSTITUTES \
91 NIX_CONF_DIR XDG_CACHE_HOME
93 # Launch the daemon without chroot support because is may be
94 # unavailable, for instance if we're not running as root.
95 "@abs_top_builddir@/pre-inst-env" \
96 "@abs_top_builddir@/guix-daemon" --disable-chroot \
97 --substitute-urls="$GUIX_BINARY_SUBSTITUTE_URL" &
99 daemon_pid=$!
100 trap "kill $daemon_pid ; rm -rf $NIX_STATE_DIR" EXIT
103 # Avoid issues that could stem from l10n, such as language/encoding
104 # mismatches.
105 unset LANGUAGE
106 LC_MESSAGES=C
107 export LC_MESSAGES
109 # Ignore user settings.
110 unset GUIX_PACKAGE_PATH GUIX_BUILD_OPTIONS
112 storedir="@storedir@"
113 prefix="@prefix@"
114 datarootdir="@datarootdir@"
115 datadir="@datadir@"
116 localstatedir="@localstatedir@"
117 export storedir prefix datarootdir datadir localstatedir
119 "@abs_top_builddir@/pre-inst-env" "$@"
120 exit $?