diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2021-12-05 19:17:41 +0100 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2021-12-05 19:17:41 +0100 |
commit | 9bc0f45df5d6aed217020b1183dca54989844fb0 (patch) | |
tree | d927e89949ff7f65b5059bc94273c53fd43d0763 /tests | |
parent | 6db3c536e89deb8a204e756f427614925a7d2582 (diff) | |
parent | 10554e0a57feeea470127a1d0441957d1776b0bd (diff) |
Merge remote-tracking branch 'origin/master' into core-updates-frozen
Diffstat (limited to 'tests')
-rw-r--r-- | tests/hackage.scm | 20 | ||||
-rw-r--r-- | tests/store.scm | 78 |
2 files changed, 82 insertions, 16 deletions
diff --git a/tests/hackage.scm b/tests/hackage.scm index 9919d54f47..189b9af173 100644 --- a/tests/hackage.scm +++ b/tests/hackage.scm @@ -171,10 +171,7 @@ library ('source ('origin ('method 'url-fetch) - ('uri ('string-append - "https://hackage.haskell.org/package/foo/foo-" - 'version - ".tar.gz")) + ('uri ('hackage-uri "foo" 'version)) ('sha256 ('base32 (? string? hash))))) @@ -214,10 +211,7 @@ library ('source ('origin ('method 'url-fetch) - ('uri ('string-append - "https://hackage.haskell.org/package/foo/foo-" - 'version - ".tar.gz")) + ('uri ('hackage-uri "foo" 'version)) ('sha256 ('base32 (? string? hash))))) @@ -337,10 +331,7 @@ executable cabal ('source ('origin ('method 'url-fetch) - ('uri ('string-append - "https://hackage.haskell.org/package/foo/foo-" - 'version - ".tar.gz")) + ('uri ('hackage-uri "foo" 'version)) ('sha256 ('base32 (? string? hash))))) @@ -401,10 +392,7 @@ executable cabal ('source ('origin ('method 'url-fetch) - ('uri ('string-append - "https://hackage.haskell.org/package/foo/foo-" - 'version - ".tar.gz")) + ('uri ('hackage-uri "foo" 'version)) ('sha256 ('base32 (? string? hash))))) diff --git a/tests/store.scm b/tests/store.scm index d5edd110dd..5df28adf0d 100644 --- a/tests/store.scm +++ b/tests/store.scm @@ -943,6 +943,84 @@ (build-derivations s (list d)) #f)))))) +(test-equal "substitute query and large size" + (+ 100 (expt 2 63)) ;<https://issues.guix.gnu.org/51983> + (with-store s + (let* ((size (+ 100 (expt 2 63))) ;does not fit in signed 'long long' + (item (string-append (%store-prefix) + "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bad-size"))) + ;; Create fake substituter data, to be read by 'guix substitute'. + (call-with-output-file (string-append (%substitute-directory) + "/" (store-path-hash-part item) + ".narinfo") + (lambda (port) + (format port "StorePath: ~a +URL: http://example.org +Compression: none +NarSize: ~a +NarHash: sha256:0fj9vhblff2997pi7qjj7lhmy7wzhnjwmkm2hmq6gr4fzmg10s0w +References: +System: x86_64-linux~%" + item size))) + + ;; Remove entry from the local cache. + (false-if-exception + (delete-file-recursively (string-append (getenv "XDG_CACHE_HOME") + "/guix/substitute"))) + + ;; Make sure 'guix substitute' correctly communicates the above + ;; data. + (set-build-options s #:use-substitutes? #t + #:substitute-urls (%test-substitute-urls)) + (match (pk 'spi (substitutable-path-info s (list item))) + (((? substitutable? s)) + (and (equal? (substitutable-path s) item) + (substitutable-nar-size s))))))) + +(test-equal "substitute and large size" + (+ 100 (expt 2 31)) ;<https://issues.guix.gnu.org/46212> + (with-store s + (let* ((size (+ 100 (expt 2 31))) ;does not fit in signed 'int' + (item (string-append (%store-prefix) + "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bad-size-" + (random-text))) + (nar (string-append (%substitute-directory) "/nar"))) + ;; Create a dummy nar to allow for substitution. + (call-with-output-file nar + (lambda (port) + (write-file-tree (store-path-package-name item) port + #:file-type+size (lambda _ + (values 'regular 12)) + #:file-port (lambda _ + (open-input-string "Hello world."))))) + + ;; Create fake substituter data, to be read by 'guix substitute'. + (call-with-output-file (string-append (%substitute-directory) + "/" (store-path-hash-part item) + ".narinfo") + (lambda (port) + (format port "StorePath: ~a +URL: file://~a +Compression: none +NarSize: ~a +NarHash: sha256:~a +References: +System: x86_64-linux~%" + item nar size + (bytevector->nix-base32-string (gcrypt:file-sha256 nar))))) + + ;; Remove entry from the local cache. + (false-if-exception + (delete-file-recursively (string-append (getenv "XDG_CACHE_HOME") + "/guix/substitute"))) + + ;; Make sure 'guix substitute' correctly communicates the above + ;; data. + (set-build-options s #:use-substitutes? #t + #:substitute-urls (%test-substitute-urls)) + (ensure-path s item) + (path-info-nar-size (query-path-info s item))))) + (test-assert "export/import several paths" (let* ((texts (unfold (cut >= <> 10) (lambda _ (random-text)) |