;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014-2021, 2024 Ludovic Courtès ;;; Copyright © 2015 David Thompson ;;; Copyright © 2020 Simon South ;;; Copyright © 2020 Mathieu Othacehe ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (test-syscalls) #:use-module (guix utils) #:use-module (guix build syscalls) #:use-module (gnu build linux-container) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (srfi srfi-64) #:use-module (srfi srfi-71) #:use-module (system foreign) #:use-module ((ice-9 ftw) #:select (scandir)) #:use-module (ice-9 match)) ;; Test the (guix build syscalls) module, although there's not much that can ;; actually be tested without being root. (define temp-file (string-append "t-utils-" (number->string (getpid)))) (test-begin "syscalls") (test-equal "mount, ENOENT" ENOENT (catch 'system-error (lambda () (mount "/dev/null" "/does-not-exist" "ext2") #f) (compose system-error-errno list))) (test-assert "umount, ENOENT/EPERM" (catch 'system-error (lambda () (umount "/does-not-exist") #f) (lambda args ;; Both return values have been encountered in the wild. (memv (system-error-errno args) (list EPERM ENOENT))))) (test-assert "mounts" ;; Check for one of the common mount points. (let ((mounts (mounts))) (any (match-lambda ((point . type) (let ((mount (find (lambda (mount) (string=? (mount-point mount) point)) mounts))) (and mount (string=? (mount-type mount) type))))) '(("/proc" . "proc") ("/sys" . "sysfs") ("/dev/shm" . "tmpfs"))))) (test-assert "mount-points" ;; Reportedly "/" is not always listed as a mount point, so check a few ;; others (see .) (any (cute member <> (mount-points)) '("/" "/proc" "/sys" "/dev"))) (false-if-exception (delete-file temp-file)) (test-equal "utime with AT_SYMLINK_NOFOLLOW" '(0 0) (begin ;; Test libguile's utime with AT_SYMLINK_NOFOLLOW, which libguile does not ;; define as of Guile 2.2.4. (symlink "/nowhere" temp-file) (utime temp-file 0 0 0 0 AT_SYMLINK_NOFOLLOW) (let ((st (lstat temp-file))) (delete-file temp-file) ;; Note: 'utimensat' does not change 'ctime'. (list (stat:mtime st) (stat:atime st))))) (test-assert "swapon, ENOSYS/ENOENT/EPERM" (catch 'system-error (lambda () (swapon "/does-not-exist") #f) (lambda args (memv (system-error-errno args) (list EPERM ENOENT ENOSYS))))) (test-assert "swapoff, ENOSYS/ENOENT/EINVAL/EPERM" (catch 'system-error (lambda () (swapoff "/does-not-exist") #f) (lambda args (memv (system-error-errno args) (list EPERM EINVAL ENOENT ENOSYS))))) (test-assert "mkdtemp!" (let* ((tmp (or (getenv "TMPDIR") "/tmp")) (dir (mkdtemp! (string-append tmp "/guix-test-XXXXXX")))) (and (file-exists? dir) (begin (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")) (d2020-12-29gnu: Add shakespeare-spl....* gnu/packages/patches/shakespeare-spl-fix-grammar.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it here. * gnu/packages/esolangs.scm (shakespeare-spl): New variable. Leo Prikler 2020-12-27gnu: audacity: Update to 2.4.2....* gnu/packages/audio.scm (audacity): Update to 2.4.2. [source]: Add patch. Don't delete portaudio-v19, since only the bundled copy can be built. [build-system]: Switch to cmake-build-system. [inputs]: Remove portaudio. [arguments]: Adjust configure flags for CMake. Remove 'fix-sbsms-check phase. Add 'comment-out-revision-ident phase. * gnu/local.mk (dist_patch_DATA): Register patch. * gnu/packages/patches/audacity-add-include.patch: New file. Kei Kebreau 2020-12-27gnu: Add hunspell-dict-it-it....* gnu/packages/hunspell.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Giacomo Leidi 2020-12-21gnu: sdcc: Move to embedded.scm....* gnu/packages/embedded.scm: Add sdcc from sdcc.scm. * gnu/packages/electronics.scm: Update #:use-module directive. * gnu/packages/sdcc.scm: Delete file. * gnu/local.mk: Remove it. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Simon South 2020-12-20gnu: libffi: Add unreleased patch to fix float128 on powerpc64le....Fixes <https://bugs.gnu.org/45252>. * gnu/packages/patches/libffi-float128-powerpc64le.patch: Import patch file from <https://github.com/libffi/libffi/pull/561.patch>. * gnu/packages/libffi.scm (libffi)[arguments]: Apply patch conditionally for powerpc64le-* systems in a phase. [inputs]: Add patch as input conditionally for powerpc64le-* systems. * gnu/local.mk (dist_patch_DATA): Add patch file to build system. Signed-off-by: Chris Marusich <cmmarusich@gmail.com> John Doe 2020-12-20gnu: bear: Update to 3.0.4....* gnu/local.mk (bear-disable-preinstall-tests.patch): Add patch. * gnu/packages/build-tools.scm (bear): Reference patch, and update. Brett Gilio 2020-12-19gnu: serf: Build with Python 3....* gnu/packages/patches/serf-python3.patch: New file. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/web.scm (serf)[source](patches): New field. [arguments]: Remove #:scons. Marius Bakke 2020-12-17gnu: sudo: Update to 1.9.4p1....* gnu/packages/admin.scm (sudo): Update to 1.9.4p1. [source]: Remove patch. * gnu/packages/patches/sudo-fix-build-without-sendmail.patch: Delete file. * gnu/local.mk (dist_patch_DATA): Remove it. Tobias Geerinckx-Rice 2020-12-17gnu: Add aws-c-event-stream....* gnu/packages/c.scm (aws-c-event-stream): New variable. * gnu/packages/patches/aws-c-event-stream-cmake-prefix.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Greg Hogan 2020-12-17gnu: Add aws-checksums....* gnu/packages/c.scm (aws-checksums): New variable. * gnu/packages/patches/aws-checksums-cmake-prefix.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Greg Hogan (inode (assoc-ref properties 'inode)) (type (assoc-ref properties 'type))) (and (= inode (stat:ino stat)) (or (eq? type 'unknown) (eq? type (stat:type stat))))))))) (scandir* directory) (scandir directory (const #t) string (termios-input-speed termios) 0) (> (termios-output-speed termios) 0)))) (test-assert "tcsetattr" (let ((first (tcgetattr 0))) (tcsetattr 0 (tcsetattr-action 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-assert "terminal-rows" (> (terminal-rows) 0)) (test-equal "terminal-string-width English" 5 (terminal-string-width "hello")) ;; The following test requires a Unicode-capable locale encoding. (test-skip (if (string=? (port-encoding (current-output-port)) "UTF-8") 0 1)) (test-equal "terminal-string-width Japanese" 6 (terminal-string-width "今日は")) (test-assert "openpty" (let ((head inferior (openpty))) (and (integer? head) (integer? inferior) (let ((port (fdopen inferior "r+0"))) (and (isatty? port) (begin (close-port port) (close-fdes head) #t)))))) (test-equal "openpty + login-tty" '(hello world) (let ((head inferior (openpty))) (match (primitive-fork) (0 (dynamic-wind (const #t) (lambda () (setvbuf (current-input-port) 'none) (close-fdes head) (login-tty inferior) (write (read)) (read)) ;this gets EIO when HEAD is closed (lambda () (primitive-_exit 42)))) (pid (close-fdes inferior) (let ((head (fdopen head "r+0"))) (write '(hello world) head) (let ((result (read head))) (close-port head) (waitpid pid) result)))))) (test-assert "utmpx-entries" (match (utmpx-entries) (((? utmpx? entries) ...) (every (lambda (entry) (match (utmpx-user entry) ((? string?) ;; Ensure we have a valid PID for those entries where it ;; makes sense. (or (not (memv (utmpx-login-type entry) (list (login-type INIT_PROCESS) (login-type LOGIN_PROCESS) (login-type USER_PROCESS)))) (> (utmpx-pid entry) 0))) (#f ;might be DEAD_PROCESS #t))) entries)))) (test-assert "read-utmpx, EOF" (eof-object? (read-utmpx (%make-void-port "r")))) (unless (access? "/var/run/utmpx" O_RDONLY) (test-skip 1)) (test-assert "read-utmpx" (let ((result (call-with-input-file "/var/run/utmpx" read-utmpx))) (or (utmpx? result) (eof-object? result)))) (when (zero? (getuid)) (test-skip 1)) (test-equal "add-to-entropy-count" EPERM (call-with-output-file "/dev/urandom" (lambda (port) (catch 'system-error (lambda () (add-to-entropy-count port 77) #f) (lambda args (system-error-errno args)))))) (test-end) (false-if-exception (delete-file temp-file))