summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMathieu Lirzin <mthl@gnu.org>2016-05-02 17:53:40 +0200
committerMathieu Lirzin <mthl@gnu.org>2016-05-02 17:53:40 +0200
commitc3052d6bcd2193b258fb92b99291a4918931fe36 (patch)
tree0e0cbbc019e68f4f1c865b4d2f5e341eb45d96ee /tests
parent0bfb9b439953b755a510974e51e651f79526a5a4 (diff)
parentb74f64a960542b0679ab13de0dd28adc496cf084 (diff)
downloadguix-c3052d6bcd2193b258fb92b99291a4918931fe36.tar.gz
Merge branch 'master' into core-updates
Diffstat (limited to 'tests')
-rw-r--r--tests/lint.scm35
-rw-r--r--tests/syscalls.scm58
-rw-r--r--tests/utils.scm13
3 files changed, 106 insertions, 0 deletions
diff --git a/tests/lint.scm b/tests/lint.scm
index 4f0196491d..1f1b0c95e9 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -138,6 +138,14 @@ requests."
 (define-syntax-rule (with-warnings body ...)
   (call-with-warnings (lambda () body ...)))
 
+(test-assert "description: not a string"
+  (->bool
+   (string-contains (with-warnings
+                      (let ((pkg (dummy-package "x"
+                                   (description 'foobar))))
+                        (check-description-style pkg)))
+                    "invalid description")))
+
 (test-assert "description: not empty"
   (->bool
    (string-contains (with-warnings
@@ -191,6 +199,14 @@ requests."
                    "E.g. Foo, i.e. Bar resp. Baz (a.k.a. DVD)."))))
        (check-description-style pkg)))))
 
+(test-assert "synopsis: not a string"
+  (->bool
+   (string-contains (with-warnings
+                      (let ((pkg (dummy-package "x"
+                                   (synopsis #f))))
+                        (check-synopsis-style pkg)))
+                    "invalid synopsis")))
+
 (test-assert "synopsis: not empty"
   (->bool
    (string-contains (with-warnings
@@ -543,6 +559,25 @@ requests."
                              (patches
                               (list "/a/b/pi-CVE-2015-1234.patch"))))))))))
 
+(test-assert "cve: patched vulnerability in replacement"
+  (mock ((guix scripts lint) package-vulnerabilities
+         (lambda (package)
+           (list (make-struct (@@ (guix cve) <vulnerability>) 0
+                              "CVE-2015-1234"
+                              (list (cons (package-name package)
+                                          (package-version package)))))))
+        (string-null?
+         (with-warnings
+           (check-vulnerabilities
+            (dummy-package
+             "pi" (version "3.14") (source (dummy-origin))
+             (replacement (dummy-package
+                           "pi" (version "3.14")
+                           (source
+                            (dummy-origin
+                             (patches
+                              (list "/a/b/pi-CVE-2015-1234.patch"))))))))))))
+
 (test-assert "formatting: lonely parentheses"
   (string-contains
    (with-warnings
diff --git a/tests/syscalls.scm b/tests/syscalls.scm
index 8e24184fe2..ab1e13984d 100644
--- a/tests/syscalls.scm
+++ b/tests/syscalls.scm
@@ -78,6 +78,21 @@
            (rmdir dir)
            #t))))
 
+(test-equal "statfs, ENOENT"
+  ENOENT
+  (catch 'system-error
+    (lambda ()
+      (statfs "/does-not-exist"))
+    (compose system-error-errno list)))
+
+(test-assert "statfs"
+  (let ((fs (statfs "/")))
+    (and (file-system? fs)
+         (> (file-system-block-size fs) 0)
+         (>= (file-system-blocks-available fs) 0)
+         (>= (file-system-blocks-free fs)
+             (file-system-blocks-available fs)))))
+
 (define (user-namespace pid)
   (string-append "/proc/" (number->string pid) "/ns/user"))
 
@@ -244,4 +259,47 @@
              (#f #f)
              (lo (interface-address lo)))))))
 
+(test-equal "tcgetattr ENOTTY"
+  ENOTTY
+  (catch 'system-error
+    (lambda ()
+      (call-with-input-file "/dev/null"
+        (lambda (port)
+          (tcgetattr (fileno port)))))
+    (compose system-error-errno list)))
+
+(test-skip (if (and (file-exists? "/proc/self/fd/0")
+                    (string-prefix? "/dev/pts/" (readlink "/proc/self/fd/0")))
+               0
+               2))
+
+(test-assert "tcgetattr"
+  (let ((termios (tcgetattr 0)))
+    (and (termios? termios)
+         (> (termios-input-speed termios) 0)
+         (> (termios-output-speed termios) 0))))
+
+(test-assert "tcsetattr"
+  (let ((first (tcgetattr 0)))
+    (tcsetattr 0 TCSANOW first)
+    (equal? first (tcgetattr 0))))
+
+(test-assert "terminal-window-size ENOTTY"
+  (call-with-input-file "/dev/null"
+    (lambda (port)
+      (catch 'system-error
+        (lambda ()
+          (terminal-window-size port))
+        (lambda args
+          ;; Accept EINVAL, which some old Linux versions might return.
+          (memv (system-error-errno args)
+                (list ENOTTY EINVAL)))))))
+
+(test-assert "terminal-columns"
+  (> (terminal-columns) 0))
+
+(test-assert "terminal-columns non-file port"
+  (> (terminal-columns (open-input-string "Join us now, share the software!"))
+     0))
+
 (test-end)
diff --git a/tests/utils.scm b/tests/utils.scm
index 6b7725554f..d0ee02a1cf 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -333,6 +333,19 @@
                "This is a journey\r\nInto the sound\r\nA journey ...\n")))
     (get-string-all (canonical-newline-port port))))
 
+
+(test-equal "edit-expression"
+  "(display \"GNU Guix\")\n(newline)\n"
+  (begin
+    (call-with-output-file temp-file
+      (lambda (port)
+        (display "(display \"xiuG UNG\")\n(newline)\n" port)))
+    (edit-expression `((filename . ,temp-file)
+                       (line     . 0)
+                       (column   . 9))
+                     string-reverse)
+    (call-with-input-file temp-file get-string-all)))
+
 (test-end)
 
 (false-if-exception (delete-file temp-file))