You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

66 lines
2.5 KiB

  1. #!/bin/sh
  2. # GNU Guix --- Functional package management for GNU
  3. # Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
  4. #
  5. # This file is part of GNU Guix.
  6. #
  7. # GNU Guix is free software; you can redistribute it and/or modify it
  8. # under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 3 of the License, or (at
  10. # your option) any later version.
  11. #
  12. # GNU Guix is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  19. # Usage: ./test-env COMMAND ARG...
  20. #
  21. # Run the daemon in the build directory, and run COMMAND within
  22. # `pre-inst-env'. This is used to run unit tests with the just-built
  23. # daemon, unless `--disable-daemon' was passed at configure time.
  24. if [ -x "@abs_top_builddir@/guix-daemon" ]
  25. then
  26. NIX_SETUID_HELPER="@abs_top_builddir@/nix-setuid-helper" # normally unused
  27. NIX_IGNORE_SYMLINK_STORE=1 # in case the store is a symlink
  28. NIX_STORE_DIR="@GUIX_TEST_ROOT@/store"
  29. NIX_LOCALSTATE_DIR="@GUIX_TEST_ROOT@/var"
  30. NIX_LOG_DIR="@GUIX_TEST_ROOT@/var/log/nix"
  31. NIX_DB_DIR="@GUIX_TEST_ROOT@/db"
  32. NIX_ROOT_FINDER="@abs_top_builddir@/nix/scripts/list-runtime-roots"
  33. # Choose a PID-dependent name to allow for parallel builds. Note
  34. # that the directory name must be chosen so that the socket's file
  35. # name is less than 108-char long (the size of `sun_path' in glibc).
  36. # Currently, in Nix builds, we're at ~106 chars...
  37. NIX_STATE_DIR="@GUIX_TEST_ROOT@/var/$$"
  38. # A place to store data of the substituter.
  39. GUIX_BINARY_SUBSTITUTE_URL="file://$NIX_STATE_DIR/substituter-data"
  40. rm -rf "$NIX_STATE_DIR/substituter-data"
  41. mkdir -p "$NIX_STATE_DIR/substituter-data"
  42. export NIX_IGNORE_SYMLINK_STORE NIX_STORE_DIR \
  43. NIX_LOCALSTATE_DIR NIX_LOG_DIR NIX_STATE_DIR NIX_DB_DIR \
  44. NIX_ROOT_FINDER NIX_SETUID_HELPER GUIX_BINARY_SUBSTITUTE_URL
  45. # Do that because store.scm calls `canonicalize-path' on it.
  46. mkdir -p "$NIX_STORE_DIR"
  47. # Launch the daemon without chroot support because is may be
  48. # unavailable, for instance if we're not running as root.
  49. "@abs_top_builddir@/pre-inst-env" \
  50. "@abs_top_builddir@/guix-daemon" --disable-chroot &
  51. daemon_pid=$!
  52. trap "kill $daemon_pid ; rm -rf $NIX_STATE_DIR" EXIT
  53. fi
  54. "@abs_top_builddir@/pre-inst-env" "$@"
  55. exit $?