summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMathieu Othacehe <othacehe@gnu.org>2020-07-27 16:36:39 +0200
committerMathieu Othacehe <othacehe@gnu.org>2020-08-24 13:35:24 +0200
commit4c0c65acfade63ce0549115d19db4b639c1e9992 (patch)
treea0ff270d0e480bb6b875413f8ca269f6d6d9568e /tests
parent5abbf435fce8c2245175dcb9b62e5722cfaadc26 (diff)
Use "guile-zlib" and "guile-lzlib" instead of (guix config).
* Makefile.am (MODULES): Remove guix/zlib.scm and guix/lzlib.scm, (SCM_TESTS): remove tests/zlib.scm, tests/lzlib.scm. * build-aux/build-self.scm (make-config.scm): Remove unused %libz variable. * configure.ac: Remove LIBZ and LIBLZ variables and check instead for Guile-zlib and Guile-lzlib. * doc/guix.texi ("Requirements"): Remove zlib requirement and add Guile-zlib and Guile-lzlib instead. * gnu/packages/package-management.scm (guix)[native-inputs]: Add "guile-zlib" and "guile-lzlib", [inputs]: remove "zlib" and "lzlib", [propagated-inputs]: ditto, [arguments]: add "guile-zlib" and "guile-lzlib" to Guile load path. * guix/config.scm.in (%libz, %liblz): Remove them. * guix/lzlib.scm: Remove it. * guix/man-db.scm: Use (zlib) instead of (guix zlib). * guix/profiles.scm (manual-database): Do not stub (guix config) in imported modules list, instead add "guile-zlib" to the extension list. * guix/scripts/publish.scm: Use (zlib) instead of (guix zlib) and (lzlib) instead of (guix lzlib), (string->compression-type, effective-compression): do not check for zlib and lzlib availability. * guix/scripts/substitute.scm (%compression-methods): Do not check for lzlib availability. * guix/self.scm (specification->package): Add "guile-zlib" and "guile-lzlib" and remove "zlib" and "lzlib", (compiled-guix): remove "zlib" and "lzlib" arguments and add guile-zlib and guile-lzlib to the dependencies, also do not pass "zlib" and "lzlib" to "make-config.scm" procedure, (make-config.scm): remove "zlib" and "lzlib" arguments as well as %libz and %liblz variables. * guix/utils.scm (lzip-port): Use (lzlib) instead of (guix lzlib) and do not check for lzlib availability. * guix/zlib.scm: Remove it. * m4/guix.m4 (GUIX_LIBZ_LIBDIR, GUIX_LIBLZ_FILE_NAME): Remove them. * tests/lzlib.scm: Use (zlib) instead of (guix zlib) and (lzlib) instead of (guix lzlib), and do not check for zlib and lzlib availability. * tests/publish.scm: Ditto. * tests/substitute.scm: Do not check for lzlib availability. * tests/utils.scm: Ditto. * tests/zlib.scm: Remove it.
Diffstat (limited to 'tests')
-rw-r--r--tests/lzlib.scm120
-rw-r--r--tests/publish.scm28
-rw-r--r--tests/substitute.scm4
-rw-r--r--tests/utils.scm3
-rw-r--r--tests/zlib.scm62
5 files changed, 5 insertions, 212 deletions
diff --git a/tests/lzlib.scm b/tests/lzlib.scm
deleted file mode 100644
index 63d1e156419..00000000000
--- a/tests/lzlib.scm
+++ /dev/null
@@ -1,120 +0,0 @@
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2019 Pierre Neidhardt <mail@ambrevar.xyz>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (test-lzlib)
20 #:use-module (guix lzlib)
21 #:use-module (guix tests)
22 #:use-module (srfi srfi-64)
23 #:use-module (rnrs bytevectors)
24 #:use-module (rnrs io ports)
25 #:use-module (ice-9 match))
26
27;; Test the (guix lzlib) module.
28
29(define-syntax-rule (test-assert* description exp)
30 (begin
31 (unless (lzlib-available?)
32 (test-skip 1))
33 (test-assert description exp)))
34
35(test-begin "lzlib")
36
37(define (compress-and-decompress data)
38 "DATA must be a bytevector."
39 (pk "Uncompressed bytes:" (bytevector-length data))
40 (match (pipe)
41 ((parent . child)
42 (match (primitive-fork)
43 (0 ;compress
44 (dynamic-wind
45 (const #t)
46 (lambda ()
47 (close-port parent)
48 (call-with-lzip-output-port child
49 (lambda (port)
50 (put-bytevector port data))))
51 (lambda ()
52 (primitive-exit 0))))
53 (pid ;decompress
54 (begin
55 (close-port child)
56 (let ((received (call-with-lzip-input-port parent
57 (lambda (port)
58 (get-bytevector-all port)))))
59 (match (waitpid pid)
60 ((_ . status)
61 (pk "Status" status)
62 (pk "Length data" (bytevector-length data) "received" (bytevector-length received))
63 ;; The following loop is a debug helper.
64 (let loop ((i 0))
65 (if (and (< i (bytevector-length received))
66 (= (bytevector-u8-ref received i)
67 (bytevector-u8-ref data i)))
68 (loop (+ 1 i))
69 (pk "First diff at index" i)))
70 (and (zero? status)
71 (port-closed? parent)
72 (bytevector=? received data)))))))))))
73
74(test-assert* "null bytevector"
75 (compress-and-decompress (make-bytevector (+ (random 100000)
76 (* 20 1024)))))
77
78(test-assert* "random bytevector"
79 (compress-and-decompress (random-bytevector (+ (random 100000)
80 (* 20 1024)))))
81(test-assert* "small bytevector"
82 (compress-and-decompress (random-bytevector 127)))
83
84(test-assert* "1 bytevector"
85 (compress-and-decompress (random-bytevector 1)))
86
87(test-assert* "Bytevector of size relative to Lzip internal buffers (2 * dictionary)"
88 (compress-and-decompress
89 (random-bytevector
90 (* 2 (dictionary-size+match-length-limit %default-compression-level)))))
91
92(test-assert* "Bytevector of size relative to Lzip internal buffers (64KiB)"
93 (compress-and-decompress (random-bytevector (* 64 1024))))
94
95(test-assert* "Bytevector of size relative to Lzip internal buffers (64KiB-1)"
96 (compress-and-decompress (random-bytevector (1- (* 64 1024)))))
97
98(test-assert* "Bytevector of size relative to Lzip internal buffers (64KiB+1)"
99 (compress-and-decompress (random-bytevector (1+ (* 64 1024)))))
100
101(test-assert* "Bytevector of size relative to Lzip internal buffers (1MiB)"
102 (compress-and-decompress (random-bytevector (* 1024 1024))))
103
104(test-assert* "Bytevector of size relative to Lzip internal buffers (1MiB-1)"
105 (compress-and-decompress (random-bytevector (1- (* 1024 1024)))))
106
107(test-assert* "Bytevector of size relative to Lzip internal buffers (1MiB+1)"
108 (compress-and-decompress (random-bytevector (1+ (* 1024 1024)))))
109
110(test-assert* "make-lzip-input-port/compressed"
111 (let* ((len (pk 'len (+ 10 (random 4000 %seed))))
112 (data (random-bytevector len))
113 (compressed (make-lzip-input-port/compressed
114 (open-bytevector-input-port data)))
115 (result (call-with-lzip-input-port compressed
116 get-bytevector-all)))
117 (pk (bytevector-length result) (bytevector-length data))
118 (bytevector=? result data)))
119
120(test-end)
diff --git a/tests/publish.scm b/tests/publish.scm
index e43310ef00a..1c3b2785fbf 100644
--- a/tests/publish.scm
+++ b/tests/publish.scm
@@ -35,8 +35,8 @@
35 #:use-module ((guix serialization) #:select (restore-file)) 35 #:use-module ((guix serialization) #:select (restore-file))
36 #:use-module (gcrypt pk-crypto) 36 #:use-module (gcrypt pk-crypto)
37 #:use-module ((guix pki) #:select (%public-key-file %private-key-file)) 37 #:use-module ((guix pki) #:select (%public-key-file %private-key-file))
38 #:use-module (guix zlib) 38 #:use-module (zlib)
39 #:use-module (guix lzlib) 39 #:use-module (lzlib)
40 #:use-module (web uri) 40 #:use-module (web uri)
41 #:use-module (web client) 41 #:use-module (web client)
42 #:use-module (web response) 42 #:use-module (web response)
@@ -204,8 +204,6 @@ References: ~%"
204 (call-with-input-string nar (cut restore-file <> temp))) 204 (call-with-input-string nar (cut restore-file <> temp)))
205 (call-with-input-file temp read-string)))) 205 (call-with-input-file temp read-string))))
206 206
207(unless (zlib-available?)
208 (test-skip 1))
209(test-equal "/nar/gzip/*" 207(test-equal "/nar/gzip/*"
210 "bar" 208 "bar"
211 (call-with-temporary-output-file 209 (call-with-temporary-output-file
@@ -217,8 +215,6 @@ References: ~%"
217 (cut restore-file <> temp))) 215 (cut restore-file <> temp)))
218 (call-with-input-file temp read-string)))) 216 (call-with-input-file temp read-string))))
219 217
220(unless (zlib-available?)
221 (test-skip 1))
222(test-equal "/nar/gzip/* is really gzip" 218(test-equal "/nar/gzip/* is really gzip"
223 %gzip-magic-bytes 219 %gzip-magic-bytes
224 ;; Since 'gzdopen' (aka. 'call-with-gzip-input-port') transparently reads 220 ;; Since 'gzdopen' (aka. 'call-with-gzip-input-port') transparently reads
@@ -229,8 +225,6 @@ References: ~%"
229 (string-append "/nar/gzip/" (basename %item)))))) 225 (string-append "/nar/gzip/" (basename %item))))))
230 (get-bytevector-n nar (bytevector-length %gzip-magic-bytes)))) 226 (get-bytevector-n nar (bytevector-length %gzip-magic-bytes))))
231 227
232(unless (lzlib-available?)
233 (test-skip 1))
234(test-equal "/nar/lzip/*" 228(test-equal "/nar/lzip/*"
235 "bar" 229 "bar"
236 (call-with-temporary-output-file 230 (call-with-temporary-output-file
@@ -242,8 +236,6 @@ References: ~%"
242 (cut restore-file <> temp))) 236 (cut restore-file <> temp)))
243 (call-with-input-file temp read-string)))) 237 (call-with-input-file temp read-string))))
244 238
245(unless (zlib-available?)
246 (test-skip 1))
247(test-equal "/*.narinfo with compression" 239(test-equal "/*.narinfo with compression"
248 `(("StorePath" . ,%item) 240 `(("StorePath" . ,%item)
249 ("URL" . ,(string-append "nar/gzip/" (basename %item))) 241 ("URL" . ,(string-append "nar/gzip/" (basename %item)))
@@ -264,8 +256,6 @@ References: ~%"
264 (_ #f))) 256 (_ #f)))
265 (recutils->alist body))))) 257 (recutils->alist body)))))
266 258
267(unless (lzlib-available?)
268 (test-skip 1))
269(test-equal "/*.narinfo with lzip compression" 259(test-equal "/*.narinfo with lzip compression"
270 `(("StorePath" . ,%item) 260 `(("StorePath" . ,%item)
271 ("URL" . ,(string-append "nar/lzip/" (basename %item))) 261 ("URL" . ,(string-append "nar/lzip/" (basename %item)))
@@ -286,8 +276,6 @@ References: ~%"
286 (_ #f))) 276 (_ #f)))
287 (recutils->alist body))))) 277 (recutils->alist body)))))
288 278
289(unless (zlib-available?)
290 (test-skip 1))
291(test-equal "/*.narinfo for a compressed file" 279(test-equal "/*.narinfo for a compressed file"
292 '("none" "nar") ;compression-less nar 280 '("none" "nar") ;compression-less nar
293 ;; Assume 'guix publish -C' is already running on port 6799. 281 ;; Assume 'guix publish -C' is already running on port 6799.
@@ -300,8 +288,6 @@ References: ~%"
300 (list (assoc-ref info "Compression") 288 (list (assoc-ref info "Compression")
301 (dirname (assoc-ref info "URL"))))) 289 (dirname (assoc-ref info "URL")))))
302 290
303(unless (and (zlib-available?) (lzlib-available?))
304 (test-skip 1))
305(test-equal "/*.narinfo with lzip + gzip" 291(test-equal "/*.narinfo with lzip + gzip"
306 `((("StorePath" . ,%item) 292 `((("StorePath" . ,%item)
307 ("URL" . ,(string-append "nar/gzip/" (basename %item))) 293 ("URL" . ,(string-append "nar/gzip/" (basename %item)))
@@ -411,8 +397,6 @@ References: ~%"
411 (call-with-input-string "" port-sha256)))))) 397 (call-with-input-string "" port-sha256))))))
412 (response-code (http-get uri)))) 398 (response-code (http-get uri))))
413 399
414(unless (zlib-available?)
415 (test-skip 1))
416(test-equal "with cache" 400(test-equal "with cache"
417 (list #t 401 (list #t
418 `(("StorePath" . ,%item) 402 `(("StorePath" . ,%item)
@@ -469,8 +453,6 @@ References: ~%"
469 (stat:size (stat nar))) 453 (stat:size (stat nar)))
470 (response-code uncompressed))))))))) 454 (response-code uncompressed)))))))))
471 455
472(unless (and (zlib-available?) (lzlib-available?))
473 (test-skip 1))
474(test-equal "with cache, lzip + gzip" 456(test-equal "with cache, lzip + gzip"
475 '(200 200 404) 457 '(200 200 404)
476 (call-with-temporary-directory 458 (call-with-temporary-directory
@@ -515,8 +497,6 @@ References: ~%"
515 (response-code 497 (response-code
516 (http-get uncompressed)))))))))) 498 (http-get uncompressed))))))))))
517 499
518(unless (zlib-available?)
519 (test-skip 1))
520(let ((item (add-text-to-store %store "fake-compressed-thing.tar.gz" 500(let ((item (add-text-to-store %store "fake-compressed-thing.tar.gz"
521 (random-text)))) 501 (random-text))))
522 (test-equal "with cache, uncompressed" 502 (test-equal "with cache, uncompressed"
@@ -596,9 +576,7 @@ References: ~%"
596 (item (add-text-to-store %store "random" (random-text))) 576 (item (add-text-to-store %store "random" (random-text)))
597 (part (store-path-hash-part item)) 577 (part (store-path-hash-part item))
598 (url (string-append base part ".narinfo")) 578 (url (string-append base part ".narinfo"))
599 (cached (string-append cache 579 (cached (string-append cache "/gzip/"
600 (if (zlib-available?)
601 "/gzip/" "/none/")
602 (basename item) 580 (basename item)
603 ".narinfo")) 581 ".narinfo"))
604 (response (http-get url))) 582 (response (http-get url)))
diff --git a/tests/substitute.scm b/tests/substitute.scm
index a4246aff824..6560612c403 100644
--- a/tests/substitute.scm
+++ b/tests/substitute.scm
@@ -29,7 +29,6 @@
29 #:use-module ((guix store) #:select (%store-prefix)) 29 #:use-module ((guix store) #:select (%store-prefix))
30 #:use-module ((guix ui) #:select (guix-warning-port)) 30 #:use-module ((guix ui) #:select (guix-warning-port))
31 #:use-module ((guix utils) #:select (call-with-compressed-output-port)) 31 #:use-module ((guix utils) #:select (call-with-compressed-output-port))
32 #:use-module ((guix lzlib) #:select (lzlib-available?))
33 #:use-module ((guix build utils) 32 #:use-module ((guix build utils)
34 #:select (mkdir-p delete-file-recursively dump-port)) 33 #:select (mkdir-p delete-file-recursively dump-port))
35 #:use-module (guix tests http) 34 #:use-module (guix tests http)
@@ -508,8 +507,7 @@ System: mips64el-linux\n")))
508 (let ((nar (string-append %main-substitute-directory 507 (let ((nar (string-append %main-substitute-directory
509 "/example.nar"))) 508 "/example.nar")))
510 (compress nar (string-append nar ".gz") 'gzip) 509 (compress nar (string-append nar ".gz") 'gzip)
511 (when (lzlib-available?) 510 (compress nar (string-append nar ".lz") 'lzip))
512 (compress nar (string-append nar ".lz") 'lzip)))
513 511
514 (parameterize ((substitute-urls 512 (parameterize ((substitute-urls
515 (list (string-append "file://" 513 (list (string-append "file://"
diff --git a/tests/utils.scm b/tests/utils.scm
index f78ec356bd2..009e2121aba 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -23,7 +23,6 @@
23 #:use-module (guix utils) 23 #:use-module (guix utils)
24 #:use-module ((guix store) #:select (%store-prefix store-path-package-name)) 24 #:use-module ((guix store) #:select (%store-prefix store-path-package-name))
25 #:use-module ((guix search-paths) #:select (string-tokenize*)) 25 #:use-module ((guix search-paths) #:select (string-tokenize*))
26 #:use-module ((guix lzlib) #:select (lzlib-available?))
27 #:use-module (srfi srfi-1) 26 #:use-module (srfi srfi-1)
28 #:use-module (srfi srfi-11) 27 #:use-module (srfi srfi-11)
29 #:use-module (srfi srfi-64) 28 #:use-module (srfi srfi-64)
@@ -215,7 +214,7 @@ skip these tests."
215 214
216(for-each test-compression/decompression 215(for-each test-compression/decompression
217 '(gzip xz lzip) 216 '(gzip xz lzip)
218 (list (const #t) (const #t) lzlib-available?)) 217 (list (const #t) (const #t) (const #t)))
219 218
220;; This is actually in (guix store). 219;; This is actually in (guix store).
221(test-equal "store-path-package-name" 220(test-equal "store-path-package-name"
diff --git a/tests/zlib.scm b/tests/zlib.scm
deleted file mode 100644
index 7c595a422c3..00000000000
--- a/tests/zlib.scm
+++ /dev/null
@@ -1,62 +0,0 @@
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016, 2019 Ludovic Courtès <ludo@gnu.org>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (test-zlib)
20 #:use-module (guix zlib)
21 #:use-module (guix tests)
22 #:use-module (srfi srfi-64)
23 #:use-module (rnrs bytevectors)
24 #:use-module (rnrs io ports)
25 #:use-module (ice-9 match))
26
27;; Test the (guix zlib) module.
28
29(test-begin "zlib")
30
31(unless (zlib-available?)
32 (test-skip 1))
33(test-assert "compression/decompression pipe"
34 (let ((data (random-bytevector (+ (random 10000)
35 (* 20 1024)))))
36 (match (pipe)
37 ((parent . child)
38 (match (primitive-fork)
39 (0 ;compress
40 (dynamic-wind
41 (const #t)
42 (lambda ()
43 (close-port parent)
44 (call-with-gzip-output-port child
45 (lambda (port)
46 (put-bytevector port data))))
47 (lambda ()
48 (primitive-exit 0))))
49 (pid ;decompress
50 (begin
51 (close-port child)
52 (let ((received (call-with-gzip-input-port parent
53 (lambda (port)
54 (get-bytevector-all port))
55 #:buffer-size (* 64 1024))))
56 (match (waitpid pid)
57 ((_ . status)
58 (and (zero? status)
59 (port-closed? parent)
60 (bytevector=? received data))))))))))))
61
62(test-end)