diff options
Diffstat (limited to 'guix/tests.scm')
-rw-r--r-- | guix/tests.scm | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/guix/tests.scm b/guix/tests.scm index 451c1ba4bb..0896e842da 100644 --- a/guix/tests.scm +++ b/guix/tests.scm @@ -23,6 +23,7 @@ #:use-module (guix base32) #:use-module (guix serialization) #:use-module (guix hash) + #:use-module (guix build-system gnu) #:use-module (gnu packages bootstrap) #:use-module (srfi srfi-34) #:use-module (rnrs bytevectors) @@ -30,6 +31,8 @@ #:export (open-connection-for-tests random-text random-bytevector + network-reachable? + shebang-too-long? mock %substitute-directory with-derivation-narinfo @@ -76,6 +79,10 @@ (loop (1+ i))) bv)))) +(define (network-reachable?) + "Return true if we can reach the Internet." + (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV))) + (define-syntax-rule (mock (module proc replacement) body ...) "Within BODY, replace the definition of PROC from MODULE with the definition given by REPLACEMENT." @@ -179,6 +186,17 @@ CONTENTS." (delete-file (string-append dir "/example.out")) (delete-file (string-append dir "/example.nar"))))) +(define (shebang-too-long?) + "Return true if the typical shebang in the current store would exceed +Linux's static limit---the BINPRM_BUF_SIZE constant, normally 128 characters +all included." + (define shebang + (string-append "#!" (%store-prefix) "/" + (make-string 32 #\a) + "-bootstrap-binaries-0/bin/bash\0")) + + (> (string-length shebang) 128)) + (define-syntax with-derivation-substitute (syntax-rules (sha256 =>) "Evaluate BODY in a context where DRV is substitutable with the given |