summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2018-11-24 01:58:18 +0100
committerMarius Bakke <mbakke@fastmail.com>2018-11-24 01:58:18 +0100
commit4d8f4a3f00268230f879a81f32524fd7c3576ad0 (patch)
tree59afedfc2fb422ef043e6624001290300ed6d800 /tests
parentc491f7f8de66d0f8386ba6fd7c2da5c3c0d1b24a (diff)
parentdc4851093ce6f3bd2ac71fa189ad87cd740cb656 (diff)
downloadguix-4d8f4a3f00268230f879a81f32524fd7c3576ad0.tar.gz
Merge branch 'master' into core-updates
Diffstat (limited to 'tests')
-rw-r--r--tests/guix-pack-localstatedir.sh69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/guix-pack-localstatedir.sh b/tests/guix-pack-localstatedir.sh
new file mode 100644
index 0000000000..b734b0f7e3
--- /dev/null
+++ b/tests/guix-pack-localstatedir.sh
@@ -0,0 +1,69 @@
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2018 Ludovic Courtès <ludo@gnu.org>
+#
+# This file is part of GNU Guix.
+#
+# GNU Guix is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# GNU Guix is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+#
+# Test the 'guix pack --localstatedir' command-line utility.
+#
+
+guix pack --version
+
+# 'guix pack --localstatedir' produces derivations that depend on
+# guile-sqlite3 and guile-gcrypt.  To make that relatively inexpensive, run
+# the test in the user's global store if possible, on the grounds that
+# binaries may already be there or can be built or downloaded inexpensively.
+
+NIX_STORE_DIR="`guile -c '(use-modules (guix config))(display %storedir)'`"
+localstatedir="`guile -c '(use-modules (guix config))(display %localstatedir)'`"
+GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket"
+export NIX_STORE_DIR GUIX_DAEMON_SOCKET
+
+if ! guile -c '(use-modules (guix)) (exit (false-if-exception (open-connection)))'
+then
+    exit 77
+fi
+
+# Build a tarball with '--localstatedir'
+the_pack="`guix pack -C none --localstatedir --profile-name=current-guix \
+            guile-bootstrap`"
+test_directory="`mktemp -d`"
+trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT
+
+cd "$test_directory"
+tar -xf "$the_pack"
+
+profile="`find -name current-guix`"
+test "`readlink $profile`" = "current-guix-1-link"
+test -s "`dirname $profile`/../../../db/db.sqlite"
+test -x ".`guix build guile-bootstrap`/bin/guile"
+cd -
+
+# Make sure the store database is not completely bogus.
+guile -c "(use-modules (sqlite3) (guix config) (ice-9 match))
+
+  (define db
+    (sqlite-open (string-append \"$test_directory\"
+                                %localstatedir
+                               \"/guix/db/db.sqlite\")
+                 SQLITE_OPEN_READONLY))
+
+  (define stmt
+    (sqlite-prepare db \"SELECT * FROM ValidPaths;\"))
+
+  (match (sqlite-fold cons '() stmt)
+    ((#(ids paths hashes times derivers sizes) ...)
+     (exit (member \"`guix build guile-bootstrap`\" paths))))"