diff options
author | Marius Bakke <mbakke@fastmail.com> | 2018-09-09 17:40:35 +0200 |
---|---|---|
committer | Marius Bakke <mbakke@fastmail.com> | 2018-09-09 17:40:35 +0200 |
commit | 0aeb13485055975d71ec8283040f007c79599bba (patch) | |
tree | a06139136c809b00d166d6d66bdf757f20566704 /tests | |
parent | b03f270e3d5ab5315b50ef3ebac35735cc28d4a2 (diff) | |
parent | 0084744b3af0a6f8e125120143f57567902339a8 (diff) | |
download | guix-0aeb13485055975d71ec8283040f007c79599bba.tar.gz |
Merge branch 'master' into core-updates
Diffstat (limited to 'tests')
-rw-r--r-- | tests/base32.scm | 2 | ||||
-rw-r--r-- | tests/builders.scm | 2 | ||||
-rw-r--r-- | tests/challenge.scm | 2 | ||||
-rw-r--r-- | tests/cpan.scm | 2 | ||||
-rw-r--r-- | tests/crate.scm | 2 | ||||
-rw-r--r-- | tests/derivations.scm | 2 | ||||
-rw-r--r-- | tests/gem.scm | 2 | ||||
-rw-r--r-- | tests/gexp.scm | 18 | ||||
-rw-r--r-- | tests/guix-describe.sh | 47 | ||||
-rw-r--r-- | tests/guix-system.sh | 8 | ||||
-rw-r--r-- | tests/hash.scm | 128 | ||||
-rw-r--r-- | tests/inferior.scm | 26 | ||||
-rw-r--r-- | tests/nar.scm | 2 | ||||
-rw-r--r-- | tests/opam.scm | 2 | ||||
-rw-r--r-- | tests/packages.scm | 2 | ||||
-rw-r--r-- | tests/pk-crypto.scm | 290 | ||||
-rw-r--r-- | tests/pki.scm | 4 | ||||
-rw-r--r-- | tests/publish.scm | 4 | ||||
-rw-r--r-- | tests/pypi.scm | 2 | ||||
-rw-r--r-- | tests/services.scm | 25 | ||||
-rw-r--r-- | tests/store-deduplication.scm | 2 | ||||
-rw-r--r-- | tests/store.scm | 10 | ||||
-rw-r--r-- | tests/substitute.scm | 4 |
23 files changed, 139 insertions, 449 deletions
diff --git a/tests/base32.scm b/tests/base32.scm index 194f8da96b..134e578633 100644 --- a/tests/base32.scm +++ b/tests/base32.scm @@ -17,7 +17,7 @@ ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (test-base32) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix base32) #:use-module (guix utils) #:use-module (srfi srfi-1) diff --git a/tests/builders.scm b/tests/builders.scm index bb9e0fa85b..8b8ef013e7 100644 --- a/tests/builders.scm +++ b/tests/builders.scm @@ -25,7 +25,7 @@ #:use-module (guix utils) #:use-module (guix base32) #:use-module (guix derivations) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix tests) #:use-module ((guix packages) #:select (package-derivation package-native-search-paths)) diff --git a/tests/challenge.scm b/tests/challenge.scm index 387d205a64..4b13ec278e 100644 --- a/tests/challenge.scm +++ b/tests/challenge.scm @@ -18,7 +18,7 @@ (define-module (test-challenge) #:use-module (guix tests) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix store) #:use-module (guix monads) #:use-module (guix derivations) diff --git a/tests/cpan.scm b/tests/cpan.scm index 396744e529..189dd027e6 100644 --- a/tests/cpan.scm +++ b/tests/cpan.scm @@ -20,7 +20,7 @@ (define-module (test-cpan) #:use-module (guix import cpan) #:use-module (guix base32) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix tests) #:use-module (guix grafts) #:use-module (srfi srfi-64) diff --git a/tests/crate.scm b/tests/crate.scm index eb93822bbb..a1dcfd5e52 100644 --- a/tests/crate.scm +++ b/tests/crate.scm @@ -21,7 +21,7 @@ #:use-module (guix import crate) #:use-module (guix base32) #:use-module (guix build-system cargo) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix tests) #:use-module (ice-9 iconv) #:use-module (ice-9 match) diff --git a/tests/derivations.scm b/tests/derivations.scm index 5d83529183..159a6971b3 100644 --- a/tests/derivations.scm +++ b/tests/derivations.scm @@ -23,7 +23,7 @@ #:use-module (guix grafts) #:use-module (guix store) #:use-module (guix utils) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix base32) #:use-module (guix tests) #:use-module (guix tests http) diff --git a/tests/gem.scm b/tests/gem.scm index 4220170ff0..a12edb294c 100644 --- a/tests/gem.scm +++ b/tests/gem.scm @@ -21,7 +21,7 @@ (define-module (test-gem) #:use-module (guix import gem) #:use-module (guix base32) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix tests) #:use-module ((guix build utils) #:select (delete-file-recursively)) #:use-module (srfi srfi-41) diff --git a/tests/gexp.scm b/tests/gexp.scm index a0ed34aa6d..380b83509a 100644 --- a/tests/gexp.scm +++ b/tests/gexp.scm @@ -1093,6 +1093,24 @@ (call-with-input-file out get-string-all)) (equal? refs (list guile)))))))) +(test-assertm "file-union" + (mlet* %store-monad ((union -> (file-union "union" + `(("a" ,(plain-file "a" "1")) + ("b/c/d" ,(plain-file "d" "2")) + ("e" ,(plain-file "e" "3"))))) + (drv (lower-object union)) + (out -> (derivation->output-path drv))) + (define (contents=? file str) + (string=? (call-with-input-file (string-append out "/" file) + get-string-all) + str)) + + (mbegin %store-monad + (built-derivations (list drv)) + (return (and (contents=? "a" "1") + (contents=? "b/c/d" "2") + (contents=? "e" "3")))))) + (test-assert "gexp->derivation vs. %current-target-system" (let ((mval (gexp->derivation "foo" #~(begin diff --git a/tests/guix-describe.sh b/tests/guix-describe.sh new file mode 100644 index 0000000000..af523f0a0b --- /dev/null +++ b/tests/guix-describe.sh @@ -0,0 +1,47 @@ +# 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 'guix describe'. +# + +guix describe --version + +tmpfile="t-guix-describe-$$" +trap "rm -f $tmpfile" EXIT +rm -f "$tmpfile" + +if [ -d "$abs_top_srcdir/.git" ] +then + # Since we're in a Git checkout, we can at least check that these things + # work. + guix describe | grep -i "checkout" + if git --version > /dev/null 2>&1 + then + result="`guix describe | grep commit: | cut -d : -f 2-`" + commit="`git log | head -1 | cut -c 7-`" + test "x$result" = "x$commit" + fi + guix describe -f channels + case "`guix describe -f channels | grep url`" in + *"(url \"$abs_top_srcdir\")") true;; + *) false;; + esac +else + exit 77 +fi diff --git a/tests/guix-system.sh b/tests/guix-system.sh index 36ba5fbd5f..a129efdfcb 100644 --- a/tests/guix-system.sh +++ b/tests/guix-system.sh @@ -232,6 +232,14 @@ guix system build "$tmpfile" -d | grep '\.drv$' guix system vm "$tmpfile" -d # succeeds guix system vm "$tmpfile" -d | grep '\.drv$' +# Make sure the behavior is deterministic (<https://bugs.gnu.org/32652>). +drv1="`guix system vm "$tmpfile" -d`" +drv2="`guix system vm "$tmpfile" -d`" +test "$drv1" = "$drv2" +drv1="`guix system disk-image --file-system-type=iso9660 "$tmpfile" -d`" +drv2="`guix system disk-image --file-system-type=iso9660 "$tmpfile" -d`" +test "$drv1" = "$drv2" + make_user_config "group-that-does-not-exist" "users" if guix system build "$tmpfile" -n 2> "$errorfile" then false diff --git a/tests/hash.scm b/tests/hash.scm deleted file mode 100644 index 47dff3915b..0000000000 --- a/tests/hash.scm +++ /dev/null @@ -1,128 +0,0 @@ -;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2017, 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/>. - -(define-module (test-hash) - #:use-module (guix hash) - #:use-module (guix base16) - #:use-module (srfi srfi-1) - #:use-module (srfi srfi-11) - #:use-module (srfi srfi-64) - #:use-module (rnrs bytevectors) - #:use-module (rnrs io ports)) - -;; Test the (guix hash) module. - -(define %empty-sha256 - ;; SHA256 hash of the empty string. - (base16-string->bytevector - "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")) - -(define %hello-sha256 - ;; SHA256 hash of "hello world" - (base16-string->bytevector - "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9")) - - -(test-begin "hash") - -(test-equal "sha1, empty" - (base16-string->bytevector "da39a3ee5e6b4b0d3255bfef95601890afd80709") - (sha1 #vu8())) - -(test-equal "sha1, hello" - (base16-string->bytevector "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed") - (sha1 (string->utf8 "hello world"))) - -(test-equal "sha256, empty" - %empty-sha256 - (sha256 #vu8())) - -(test-equal "sha256, hello" - %hello-sha256 - (sha256 (string->utf8 "hello world"))) - -(test-equal "open-sha256-port, empty" - %empty-sha256 - (let-values (((port get) - (open-sha256-port))) - (close-port port) - (get))) - -(test-equal "open-sha256-port, hello" - (list %hello-sha256 (string-length "hello world")) - (let-values (((port get) - (open-sha256-port))) - (put-bytevector port (string->utf8 "hello world")) - (force-output port) - (list (get) (port-position port)))) - -(test-assert "port-sha256" - (let* ((file (search-path %load-path "ice-9/psyntax.scm")) - (size (stat:size (stat file))) - (contents (call-with-input-file file get-bytevector-all))) - (equal? (sha256 contents) - (call-with-input-file file port-sha256)))) - -(test-equal "open-sha256-input-port, empty" - `("" ,%empty-sha256) - (let-values (((port get) - (open-sha256-input-port (open-string-input-port "")))) - (let ((str (get-string-all port))) - (list str (get))))) - -(test-equal "open-sha256-input-port, hello" - `("hello world" ,%hello-sha256) - (let-values (((port get) - (open-sha256-input-port - (open-bytevector-input-port - (string->utf8 "hello world"))))) - (let ((str (get-string-all port))) - (list str (get))))) - -(test-equal "open-sha256-input-port, hello, one two" - (list (string->utf8 "hel") (string->utf8 "lo") - (base16-string->bytevector ; echo -n hello | sha256sum - "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824") - " world") - (let-values (((port get) - (open-sha256-input-port - (open-bytevector-input-port (string->utf8 "hello world"))))) - (let* ((one (get-bytevector-n port 3)) - (two (get-bytevector-n port 2)) - (hash (get)) - (three (get-string-all port))) - (list one two hash three)))) - -(test-equal "open-sha256-input-port, hello, read from wrapped port" - (list (string->utf8 "hello") - (base16-string->bytevector ; echo -n hello | sha256sum - "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824") - " world") - (let*-values (((wrapped) - (open-bytevector-input-port (string->utf8 "hello world"))) - ((port get) - (open-sha256-input-port wrapped))) - (let* ((hello (get-bytevector-n port 5)) - (hash (get)) - - ;; Now read from WRAPPED to make sure its current position is - ;; correct. - (world (get-string-all wrapped))) - (list hello hash world)))) - -(test-end) diff --git a/tests/inferior.scm b/tests/inferior.scm index 5e0f8ae66e..ff5cad4210 100644 --- a/tests/inferior.scm +++ b/tests/inferior.scm @@ -45,9 +45,11 @@ (test-equal "inferior-packages" (take (sort (fold-packages (lambda (package lst) - (alist-cons (package-name package) + (cons (list (package-name package) (package-version package) - lst)) + (package-home-page package) + (package-location package)) + lst)) '()) (lambda (x y) (string<? (car x) (car y)))) @@ -56,14 +58,18 @@ #:command "scripts/guix")) (packages (inferior-packages inferior))) (and (every string? (map inferior-package-synopsis packages)) - (begin + (let () + (define result + (take (sort (map (lambda (package) + (list (inferior-package-name package) + (inferior-package-version package) + (inferior-package-home-page package) + (inferior-package-location package))) + packages) + (lambda (x y) + (string<? (car x) (car y)))) + 10)) (close-inferior inferior) - (take (sort (map (lambda (package) - (cons (inferior-package-name package) - (inferior-package-version package))) - packages) - (lambda (x y) - (string<? (car x) (car y)))) - 10))))) + result)))) (test-end "inferior") diff --git a/tests/nar.scm b/tests/nar.scm index 9b5fb984b4..d610ea53f7 100644 --- a/tests/nar.scm +++ b/tests/nar.scm @@ -21,7 +21,7 @@ #:use-module (guix nar) #:use-module (guix serialization) #:use-module (guix store) - #:use-module ((guix hash) + #:use-module ((gcrypt hash) #:select (open-sha256-port open-sha256-input-port)) #:use-module ((guix packages) #:select (base32)) diff --git a/tests/opam.scm b/tests/opam.scm index 26832174a8..a1320abfdc 100644 --- a/tests/opam.scm +++ b/tests/opam.scm @@ -19,7 +19,7 @@ (define-module (test-opam) #:use-module (guix import opam) #:use-module (guix base32) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix tests) #:use-module ((guix build utils) #:select (delete-file-recursively mkdir-p which)) #:use-module (srfi srfi-64) diff --git a/tests/packages.scm b/tests/packages.scm index 65ccb14889..237feb7aba 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -28,7 +28,7 @@ #:renamer (lambda (name) (cond ((eq? name 'location) 'make-location) (else name)))) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix derivations) #:use-module (guix packages) #:use-module (guix grafts) diff --git a/tests/pk-crypto.scm b/tests/pk-crypto.scm deleted file mode 100644 index fe33a6f7b5..0000000000 --- a/tests/pk-crypto.scm +++ /dev/null @@ -1,290 +0,0 @@ -;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2017 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/>. - -(define-module (test-pk-crypto) - #:use-module (guix pk-crypto) - #:use-module (guix utils) - #:use-module (guix base16) - #:use-module (guix hash) - #:use-module (srfi srfi-1) - #:use-module (srfi srfi-11) - #:use-module (srfi srfi-26) - #:use-module (srfi srfi-64) - #:use-module (rnrs bytevectors) - #:use-module (rnrs io ports) - #:use-module (ice-9 match)) - -;; Test the (guix pk-crypto) module. - -(define %key-pair - ;; RSA key pair that was generated with: - ;; (generate-key (string->canonical-sexp "(genkey (rsa (nbits 4:1024)))")) - ;; which takes a bit of time. - "(key-data - (public-key - (rsa - (n #00C1F764069F54FFE93A126B02328903E984E4AE3AF6DF402B5B6B3907911B88C385F1BA76A002EC9DEA109A5228EF0E62EE31A06D1A5861CAB474F6C857AC66EB65A1905F25BBA1869579E73A3B7FED13AF5A1667326F88CDFC2FF24B03C14FD1384AA7E73CA89572880B606E3A974E15347963FC7B6378574936A47580DBCB45#) - (e #010001#))) - (private-key - (rsa - (n #00C1F764069F54FFE93A126B02328903E984E4AE3AF6DF402B5B6B3907911B88C385F1BA76A002EC9DEA109A5228EF0E62EE31A06D1A5861CAB474F6C857AC66EB65A1905F25BBA1869579E73A3B7FED13AF5A1667326F88CDFC2FF24B03C14FD1384AA7E73CA89572880B606E3A974E15347963FC7B6378574936A47580DBCB45#) - (e #010001#) - (d #58CAD84653D0046A8EC3F9AA82D9C829B145422109FC3F12DA01A694B92FA296E70D366FB166454D30E632CEE3A033B4C41781BA10325F69FCDC0250CA19C8EEB352FA085992494098DB133E682ED38A931701F0DED1A1E508F4341A4FB446A04F019427C7CB3C44F251EEA9D386100DA80F125E0FD5CE1B0DFEC6D21516EACD#) - (p #00D47F185147EC39393CCDA4E7323FFC20FC8B8073E2A54DD63BA392A66975E4204CA48572496A9DFD7522436B852C07472A5AB25B7706F7C14E6F33FBC420FF3B#) - (q #00E9AD22F158060BC9AE3601DA623AFC60FFF3058795802CA92371C00097335CF9A23D7782DE353C9DBA93D7BB99E6A24A411107605E722481C5C191F80D7EB77F#) - (u #59B45B95AE01A7A7370FAFDB08FE73A4793CE37F228961B09B1B1E7DDAD9F8D3E28F5C5E8B4B067E6B8E0BBF3F690B42991A79E46108DDCDA2514323A66964DE#))))") - -(define %ecc-key-pair - ;; Ed25519 key pair generated with: - ;; (generate-key (string->canonical-sexp "(genkey (ecdsa (curve Ed25519) (flags rfc6979 transient)))")) - "(key-data - (public-key - (ecc - (curve Ed25519) - (q #94869C1B9E69DB8DD910B7F7F4D6E56A63A964A59AE8F90F6703ACDDF6F50C81#))) - (private-key - (ecc - (curve Ed25519) - (q #94869C1B9E69DB8DD910B7F7F4D6E56A63A964A59AE8F90F6703ACDDF6F50C81#) - (d #6EFB32D0B4EC6B3237B523539F1979379B82726AAA605EB2FBA6775B2B777B78#))))") - -(test-begin "pk-crypto") - -(test-assert "version" - (gcrypt-version)) - -(let ((sexps '("(foo bar)" - - ;; In Libgcrypt 1.5.3 the following integer is rendered as - ;; binary, whereas in 1.6.0 it's rendered as is (hexadecimal.) - ;;"#C0FFEE#" - - "(genkey \n (rsa \n (nbits \"1024\")\n )\n )"))) - (test-equal "string->canonical-sexp->string" - sexps - (let ((sexps (map string->canonical-sexp sexps))) - (and (every canonical-sexp? sexps) - (map (compose string-trim-both canonical-sexp->string) sexps))))) - -(gc) ; stress test! - -(let ((sexps `(("(foo bar)" foo -> "(foo bar)") - ("(foo (bar (baz 3:123)))" baz -> "(baz \"123\")") - ("(foo (bar 3:123))" baz -> #f)))) - (test-equal "find-sexp-token" - (map (match-lambda - ((_ _ '-> expected) - expected)) - sexps) - (map (match-lambda - ((input token '-> _) - (let ((sexp (find-sexp-token (string->canonical-sexp input) token))) - (and sexp - (string-trim-both (canonical-sexp->string sexp)))))) - sexps))) - -(gc) - -(test-equal "canonical-sexp-length" - '(0 1 2 4 0 0) - (map (compose canonical-sexp-length string->canonical-sexp) - '("()" "(a)" "(a b)" "(a #616263# b #C001#)" "a" "#123456#"))) - -(test-equal "canonical-sexp-list?" - '(#t #f #t #f) - (map (compose canonical-sexp-list? string->canonical-sexp) - '("()" "\"abc\"" "(a b c)" "#123456#"))) - -(gc) - -(test-equal "canonical-sexp-car + cdr" - '("(b \n (c xyz)\n )") - (let ((lst (string->canonical-sexp "(a (b (c xyz)))"))) - (map (lambda (sexp) - (and sexp (string-trim-both (canonical-sexp->string sexp)))) - ;; Note: 'car' returns #f when the first element is an atom. - (list (canonical-sexp-car (canonical-sexp-cdr lst)))))) - -(gc) - -(test-equal "canonical-sexp-nth" - '("(b pqr)" "(c \"456\")" "(d xyz)" #f #f) - - (let ((lst (string->canonical-sexp "(a (b 3:pqr) (c 3:456) (d 3:xyz))"))) - ;; XXX: In Libgcrypt 1.5.3, (canonical-sexp-nth lst 0) returns LST, whereas in - ;; 1.6.0 it returns #f. - (map (lambda (sexp) - (and sexp (string-trim-both (canonical-sexp->string sexp)))) - (unfold (cut > <> 5) - (cut canonical-sexp-nth lst <>) - 1+ - 1)))) - -(gc) - -(test-equal "canonical-sexp-nth-data" - `(Name Otto Meier #f ,(base16-string->bytevector "123456") #f) - (let ((lst (string->canonical-sexp - "(Name Otto Meier (address Burgplatz) #123456#)"))) - (unfold (cut > <> 5) - (cut canonical-sexp-nth-data lst <>) - 1+ - 0))) - -(let ((bv (base16-string->bytevector - "5eff0b55c9c5f5e87b4e34cd60a2d5654ca1eb78c7b3c67c3179fed1cff07b4c"))) - (test-equal "hash corrupt due to restrictive locale encoding" - bv - - ;; In Guix up to 0.6 included this test would fail because at some point - ;; the hash value would be cropped to ASCII. In practice 'guix - ;; authenticate' would produce invalid signatures that would fail - ;; signature verification. See <http://bugs.gnu.org/17312>. - (let ((locale (setlocale LC_ALL))) - (dynamic-wind - (lambda () - (setlocale LC_ALL "C")) - (lambda () - (hash-data->bytevector - (string->canonical-sexp - (canonical-sexp->string - (bytevector->hash-data bv "sha256"))))) - (lambda () - (setlocale LC_ALL locale)))))) - -(gc) - -;; XXX: The test below is typically too long as it needs to gather enough entropy. - -;; (test-assert "generate-key" -;; (let ((key (generate-key (string->canonical-sexp -;; "(genkey (rsa (nbits 3:128)))")))) -;; (and (canonical-sexp? key) -;; (find-sexp-token key 'key-data) -;; (find-sexp-token key 'public-key) -;; (find-sexp-token key 'private-key)))) - -(test-assert "bytevector->hash-data->bytevector" - (let* ((bv (sha256 (string->utf8 "Hello, world."))) - (data (bytevector->hash-data bv "sha256"))) - (and (canonical-sexp? data) - (let-values (((value algo) (hash-data->bytevector data))) - (and (string=? algo "sha256") - (bytevector=? value bv)))))) - -(test-equal "key-type" - '(rsa ecc) - (map (compose key-type - (cut find-sexp-token <> 'public-key) - string->canonical-sexp) - (list %key-pair %ecc-key-pair))) - -(test-assert "sign + verify" - (let* ((pair (string->canonical-sexp %key-pair)) - (secret (find-sexp-token pair 'private-key)) - (public (find-sexp-token pair 'public-key)) - (data (bytevector->hash-data - (sha256 (string->utf8 "Hello, world.")) - #:key-type (key-type public))) - (sig (sign data secret))) - (and (verify sig data public) - (not (verify sig - (bytevector->hash-data - (sha256 (string->utf8 "Hi!")) - #:key-type (key-type public)) - public))))) - -;; Ed25519 appeared in libgcrypt 1.6.0. -(test-skip (if (version>? (gcrypt-version) "1.6.0") 0 1)) -(test-assert "sign + verify, Ed25519" - (let* ((pair (string->canonical-sexp %ecc-key-pair)) - (secret (find-sexp-token pair 'private-key)) - (public (find-sexp-token pair 'public-key)) - (data (bytevector->hash-data - (sha256 (string->utf8 "Hello, world.")))) - (sig (sign data secret))) - (and (verify sig data public) - (not (verify sig - (bytevector->hash-data - (sha256 (string->utf8 "Hi!"))) - public))))) - -(gc) - -(test-equal "canonical-sexp->sexp" - `((data - (flags pkcs1) - (hash sha256 - ,(base16-string->bytevector - "2749f0ea9f26c6c7be746a9cff8fa4c2f2a02b000070dba78429e9a11f87c6eb"))) - - (public-key - (rsa - (n ,(base16-string->bytevector - (string-downcase - "00C1F764069F54FFE93A126B02328903E984E4AE3AF6DF402B5B6B3907911B88C385F1BA76A002EC9DEA109A5228EF0E62EE31A06D1A5861CAB474F6C857AC66EB65A1905F25BBA1869579E73A3B7FED13AF5A1667326F88CDFC2FF24B03C14FD1384AA7E73CA89572880B606E3A974E15347963FC7B6378574936A47580DBCB45"))) - (e ,(base16-string->bytevector - "010001"))))) - - (list (canonical-sexp->sexp - (string->canonical-sexp - "(data - (flags pkcs1) - (hash \"sha256\" - #2749f0ea9f26c6c7be746a9cff8fa4c2f2a02b000070dba78429e9a11f87c6eb#))")) - - (canonical-sexp->sexp - (find-sexp-token (string->canonical-sexp %key-pair) - 'public-key)))) - - -(let ((lst - `((data - (flags pkcs1) - (hash sha256 - ,(base16-string->bytevector - "2749f0ea9f26c6c7be746a9cff8fa4c2f2a02b000070dba78429e9a11f87c6eb"))) - - (public-key - (rsa - (n ,(base16-string->bytevector - (string-downcase - "00C1F764069F54FFE93A126B02328903E984E4AE3AF6DF402B5B6B3907911B88C385F1BA76A002EC9DEA109A5228EF0E62EE31A06D1A5861CAB474F6C857AC66EB65A1905F25BBA1869579E73A3B7FED13AF5A1667326F88CDFC2FF24B03C14FD1384AA7E73CA89572880B606E3A974E15347963FC7B6378574936A47580DBCB45"))) - (e ,(base16-string->bytevector - "010001")))) - - ,(base16-string->bytevector - "2749f0ea9f26c6c7be746a9cff8fa4c2f2a02b000070dba78429e9a11f87c6eb")))) - (test-equal "sexp->canonical-sexp->sexp" - lst - (map (compose canonical-sexp->sexp sexp->canonical-sexp) - lst))) - -(let ((sexp `(signature - (public-key - (rsa - (n ,(make-bytevector 1024 1)) - (e ,(base16-string->bytevector "010001"))))))) - (test-equal "https://bugs.g10code.com/gnupg/issue1594" - ;; The gcrypt bug above was primarily affecting our uses in - ;; 'canonical-sexp->sexp', typically when applied to a signature sexp (in - ;; 'guix authenticate -verify') with a "big" RSA key, such as 4096 bits. - sexp - (canonical-sexp->sexp (sexp->canonical-sexp sexp)))) - -(test-end) diff --git a/tests/pki.scm b/tests/pki.scm index 876ad98d73..d6a6b476c7 100644 --- a/tests/pki.scm +++ b/tests/pki.scm @@ -18,8 +18,8 @@ (define-module (test-pki) #:use-module (guix pki) - #:use-module (guix pk-crypto) - #:use-module (guix hash) + #:use-module (gcrypt pk-crypto) + #:use-module (gcrypt hash) #:use-module (rnrs io ports) #:use-module (srfi srfi-64)) diff --git a/tests/publish.scm b/tests/publish.scm index 1ed8308076..0e793c1ee5 100644 --- a/tests/publish.scm +++ b/tests/publish.scm @@ -25,7 +25,7 @@ #:use-module (guix tests) #:use-module (guix config) #:use-module (guix utils) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix store) #:use-module (guix derivations) #:use-module (guix gexp) @@ -33,7 +33,7 @@ #:use-module (guix base64) #:use-module ((guix records) #:select (recutils->alist)) #:use-module ((guix serialization) #:select (restore-file)) - #:use-module (guix pk-crypto) + #:use-module (gcrypt pk-crypto) #:use-module ((guix pki) #:select (%public-key-file %private-key-file)) #:use-module (guix zlib) #:use-module (web uri) diff --git a/tests/pypi.scm b/tests/pypi.scm index 310c6c8f29..616ec191f5 100644 --- a/tests/pypi.scm +++ b/tests/pypi.scm @@ -20,7 +20,7 @@ (define-module (test-pypi) #:use-module (guix import pypi) #:use-module (guix base32) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix tests) #:use-module (guix build-system python) #:use-module ((guix build utils) #:select (delete-file-recursively which)) diff --git a/tests/services.scm b/tests/services.scm index b146a0dec2..1ad577e601 100644 --- a/tests/services.scm +++ b/tests/services.scm @@ -138,6 +138,31 @@ (equal? (list s1 s2) (instantiate-missing-services (list s1 s2)))))) +(test-assert "instantiate-missing-services, indirect" + (let* ((t1 (service-type (name 't1) (extensions '()) + (default-value 'dflt) + (compose concatenate) + (extend cons))) + (t2 (service-type (name 't2) (extensions '()) + (default-value 'dflt2) + (compose concatenate) + (extend cons) + (extensions + (list (service-extension t1 list))))) + (t3 (service-type (name 't3) + (extensions + (list (service-extension t2 list))))) + (s1 (service t1)) + (s2 (service t2)) + (s3 (service t3 42)) + (== (cut lset= equal? <...>))) + (and (== (list s1 s2 s3) + (instantiate-missing-services (list s3))) + (== (list s1 s2 s3) + (instantiate-missing-services (list s1 s3))) + (== (list s1 s2 s3) + (instantiate-missing-services (list s2 s3)))))) + (test-assert "instantiate-missing-services, no default value" (let* ((t1 (service-type (name 't1) (extensions '()))) (t2 (service-type (name 't2) diff --git a/tests/store-deduplication.scm b/tests/store-deduplication.scm index 4ca2ec0f61..e438aa84c6 100644 --- a/tests/store-deduplication.scm +++ b/tests/store-deduplication.scm @@ -19,7 +19,7 @@ (define-module (test-store-deduplication) #:use-module (guix tests) #:use-module (guix store deduplication) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module ((guix utils) #:select (call-with-temporary-directory)) #:use-module (guix build utils) #:use-module (rnrs bytevectors) diff --git a/tests/store.scm b/tests/store.scm index 47fab0df18..2858369706 100644 --- a/tests/store.scm +++ b/tests/store.scm @@ -21,7 +21,7 @@ #:use-module (guix store) #:use-module (guix utils) #:use-module (guix monads) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix base32) #:use-module (guix packages) #:use-module (guix derivations) @@ -45,6 +45,9 @@ (define %store (open-connection-for-tests)) +(define %shell + (or (getenv "SHELL") (getenv "CONFIG_SHELL"))) + (test-begin "store") @@ -220,7 +223,8 @@ ("./foo/c" directory #t) ("./foo/c/p" regular "file p") ("./foo/c/q" directory #t) - ("./foo/c/q/x" regular "#!/bin/sh\nexit 42") + ("./foo/c/q/x" regular + ,(string-append "#!" %shell "\nexit 42")) ("./foo/c/q/y" symlink "..") ("./foo/c/q/z" directory #t)) (let* ((tree `("file-tree" directory @@ -231,7 +235,7 @@ ("p" regular (data ,(string->utf8 "file p"))) ("q" directory ("x" executable - (data "#!/bin/sh\nexit 42")) + (data ,(string-append "#!" %shell "\nexit 42"))) ("y" symlink "..") ("z" directory)))) ("bar" directory))) diff --git a/tests/substitute.scm b/tests/substitute.scm index 0ad6247954..964a57f30b 100644 --- a/tests/substitute.scm +++ b/tests/substitute.scm @@ -20,9 +20,9 @@ (define-module (test-substitute) #:use-module (guix scripts substitute) #:use-module (guix base64) - #:use-module (guix hash) + #:use-module (gcrypt hash) #:use-module (guix serialization) - #:use-module (guix pk-crypto) + #:use-module (gcrypt pk-crypto) #:use-module (guix pki) #:use-module (guix config) #:use-module (guix base32) |