%%%% Starting test nar Group begin: nar Test begin: test-name: "write-file supports non-file output ports" source-file: "tests/nar.scm" source-line: 166 source-form: (test-assert "write-file supports non-file output ports" (let ((input (string-append (dirname (search-path %load-path "guix.scm")) "/guix")) (output (%make-void-port "w"))) (write-file input output) #t)) Test end: result-kind: pass actual-value: #t Test begin: test-name: "write-file puts file in C locale collation order" source-file: "tests/nar.scm" source-line: 173 source-form: (test-equal "write-file puts file in C locale collation order" (base32 "0sfn5r63k88w9ls4hivnvscg82bqg8a0w7955l6xlk4g96jnb2z3") (let ((input (string-append %test-dir ".input"))) (dynamic-wind (lambda () (define (touch file) (call-with-output-file (string-append input "/" file) (const #t))) (mkdir input) (touch "B") (touch "Z") (touch "a") (symlink "B" (string-append input "/z"))) (lambda () (let-values (((port get-hash) (open-sha256-port))) (write-file input port) (get-hash))) (lambda () (rm-rf input))))) Test end: result-kind: pass actual-value: #vu8(227 139 101 165 73 143 76 218 13 45 37 29 14 20 122 120 9 244 152 222 118 71 72 52 77 28 161 57 76 46 214 105) expected-value: #vu8(227 139 101 165 73 143 76 218 13 45 37 29 14 20 122 120 9 244 152 222 118 71 72 52 77 28 161 57 76 46 214 105) Test begin: test-name: "restore-file with incomplete input" source-file: "tests/nar.scm" source-line: 194 source-form: (test-equal "restore-file with incomplete input" (string-append %test-dir "/foo") (let ((port (open-bytevector-input-port #vu8(1 2 3)))) (guard (c ((nar-error? c) (and (eq? port (nar-error-port c)) (nar-error-file c)))) (restore-file port (string-append %test-dir "/foo")) #f))) Test end: result-kind: pass actual-value: "./test-nar-9241/foo" expected-value: "./test-nar-9241/foo" Test begin: test-name: "write-file + restore-file" source-file: "tests/nar.scm" source-line: 203 source-form: (test-assert "write-file + restore-file" (let* ((input (string-append (dirname (search-path %load-path "guix.scm")) "/guix")) (output %test-dir) (nar (string-append output ".nar"))) (dynamic-wind (lambda () #t) (lambda () (call-with-output-file nar (cut write-file input <>)) (call-with-input-file nar (cut restore-file <> output)) (file-tree-equal? input output)) (lambda () (false-if-exception (delete-file nar)) (false-if-exception (rm-rf output)))))) Test end: result-kind: fail actual-value: #f Test begin: test-name: "write-file + restore-file with symlinks" source-file: "tests/nar.scm" source-line: 220 source-form: (test-assert "write-file + restore-file with symlinks" (let ((input (string-append %test-dir ".input"))) (mkdir input) (dynamic-wind (const #t) (lambda () (with-file-tree input (directory "root" (("reg") ("exe" 511) ("sym" -> "reg"))) (let* ((output %test-dir) (nar (string-append output ".nar"))) (dynamic-wind (lambda () #t) (lambda () (call-with-output-file nar (cut write-file input <>)) (call-with-input-file nar (cut restore-file <> output)) (file-tree-equal? input output)) (lambda () (false-if-exception (delete-file nar)) (false-if-exception (rm-rf output))))))) (lambda () (rmdir input))))) Test end: result-kind: fail actual-value: #f Test begin: test-name: "restore-file-set (signed, valid)" source-file: "tests/nar.scm" source-line: 252 source-form: (test-assert "restore-file-set (signed, valid)" (with-store store (let* ((texts (unfold (cut >= <> 10) (lambda _ (random-text)) #{1+}# 0)) (files (map (cut add-text-to-store store "text" <>) texts)) (dump (call-with-bytevector-output-port (cut export-paths store files <>)))) (delete-paths store files) (and (every (negate file-exists?) files) (let* ((source (open-bytevector-input-port dump)) (imported (restore-file-set source))) (and (equal? imported files) (every (lambda (file) (and (file-exists? file) (valid-path? store file))) files) (equal? texts (map (lambda (file) (call-with-input-file file get-string-all)) files)))))))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "restore-file-set (missing signature)" source-file: "tests/nar.scm" source-line: 276 source-form: (test-assert "restore-file-set (missing signature)" (let/ec return (with-store store (let* ((file (add-text-to-store store "foo" (random-text))) (dump (call-with-bytevector-output-port (cute export-paths store (list file) <> #:sign? #f)))) (delete-paths store (list file)) (and (not (file-exists? file)) (let ((source (open-bytevector-input-port dump))) (guard (c ((nar-signature-error? c) (let ((message (condition-message c)) (port (nar-error-port c))) (return (and (string-match "lacks.*signature" message) (string=? file (nar-error-file c)) (eq? source port)))))) (restore-file-set source)) #f)))))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "restore-file-set (corrupt)" source-file: "tests/nar.scm" source-line: 296 source-form: (test-assert "restore-file-set (corrupt)" (let/ec return (with-store store (let* ((file (add-text-to-store store "foo" (random-text))) (dump (call-with-bytevector-output-port (cute export-paths store (list file) <>)))) (delete-paths store (list file)) (let* ((index 120) (byte (bytevector-u8-ref dump index))) (bytevector-u8-set! dump index (logxor 255 byte))) (and (not (file-exists? file)) (let ((source (open-bytevector-input-port dump))) (guard (c ((nar-invalid-hash-error? c) (let ((message (condition-message c)) (port (nar-error-port c))) (return (and (string-contains message "hash") (string=? file (nar-error-file c)) (eq? source port)))))) (restore-file-set source)) #f)))))) Test end: result-kind: pass actual-value: #t Group end: nar # of expected passes 6 # of unexpected failures 2