diff options
author | Ludovic Courtès <ludo@gnu.org> | 2014-03-18 23:59:57 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-03-19 00:00:29 +0100 |
commit | e297d8fc565861794c7d85cf7d158a846ab25aac (patch) | |
tree | c89454ee02e7b22402d88376655e9a3a57c15810 | |
parent | dc19a986d4cba288796efe0f7ee13947a11833bd (diff) | |
download | guix-e297d8fc565861794c7d85cf7d158a846ab25aac.tar.gz |
tests: Test recovery from 'valid-path?' RPCs with an invalid parameter.
* tests/store.scm ("valid-path? live", "valid-path? false", "valid-path? error", "valid-path? recovery"): New tests.
-rw-r--r-- | tests/store.scm | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/store.scm b/tests/store.scm index 78023a423d..d23024bcbc 100644 --- a/tests/store.scm +++ b/tests/store.scm @@ -87,7 +87,39 @@ (%store-prefix) "/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7/bin/guile"))))) -(test-skip (if %store 0 11)) +(test-skip (if %store 0 13)) + +(test-assert "valid-path? live" + (let ((p (add-text-to-store %store "hello" "hello, world"))) + (valid-path? %store p))) + +(test-assert "valid-path? false" + (not (valid-path? %store + (string-append (%store-prefix) "/" + (make-string 32 #\e) "-foobar")))) + +(test-assert "valid-path? error" + (with-store s + (guard (c ((nix-protocol-error? c) #t)) + (valid-path? s "foo") + #f))) + +(test-assert "valid-path? recovery" + ;; Prior to Nix commit 51800e0 (18 Mar. 2014), the daemon would immediately + ;; close the connection after receiving a 'valid-path?' RPC with a non-store + ;; file name. See + ;; <http://article.gmane.org/gmane.linux.distributions.nixos/12411> for + ;; details. + (with-store s + (let-syntax ((true-if-error (syntax-rules () + ((_ exp) + (guard (c ((nix-protocol-error? c) #t)) + exp #f))))) + (and (true-if-error (valid-path? s "foo")) + (true-if-error (valid-path? s "bar")) + (true-if-error (valid-path? s "baz")) + (true-if-error (valid-path? s "chbouib")) + (valid-path? s (add-text-to-store s "valid" "yeah")))))) (test-assert "hash-part->path" (let ((p (add-text-to-store %store "hello" "hello, world"))) |