;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès ;;; Copyright © 2015 David Thompson ;;; ;;; 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 (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 "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, ENOENT/EPERM" (catch 'system-error (lambda () (swapon "/does-not-exist") #f) (lambda args (memv (system-error-errno args) (list EPERM ENOENT))))) (test-assert "swapoff, ENOENT/EINVAL/EPERM" (catch 'system-error (lambda () (swapoff "/does-not-exist") #f) (lambda args (memv (system-error-errno args) (list EPERM EINVAL ENOENT))))) (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")) (define perform-container-tests? (and (user-namespace-supported?) (unprivileged-user-namespace-supported?))) (unless perform-container-tests? (test-skip 1)) (test-assert "clone" (match (clone (logior CLONE_NEWUSER SIGCHLD)) (0 (primitive-exit 42)) (pid ;; Check if user namespaces are different. (and (not (equal? (readlink (user-namespace pid)) (readlink (user-namespace (getpid))))) (match (waitpid pid) ((_ . status) (= 42 (status:exit-val status)))))))) (unless perform-container-tests? (test-skip 1)) (test-assert "setns" (match (clone (logior CLONE_NEWUSER SIGCHLD)) (0 (primitive-exit 0)) (clone-pid (match (pipe) ((in . out) (match (primitive-fork) (0 (close in) ;; Join the user namespace. (call-with-input-file (user-namespace clone-pid) (lambda (port) (setns (port->fdes port) 0))) (write 'done out) (close out) (primitive-exit 0)) (fork-pid (close out) ;; Wait for the child process to join the namespace. (read in) (let ((result (and (equal? (readlink (user-namespace clone-pid)) (readlink (user-namespace fork-pid)))))) ;; Clean up. (waitpid clone-pid) (waitpid fork-pid) result)))))))) ;; XXX: Skip this test when running Linux > 4.7.5 to work around ;; . (when (or (not perform-container-tests?) (version>? (utsname:release (uname)) "4.7.5") ;; Skip on Ubuntu's 4.4 kernels, which contain a backport of the ;; faulty code: . (member (utsname:release (uname)) '("4.4.0-21-generic" "4.4.0-59-generic" "4.4.0-116-generic"))) (test-skip 1)) (test-equal "pivot-root" #t (match (pipe) ((in . out) (match (clone (logior CLONE_NEWUSER CLONE_NEWNS SIGCHLD)) (0 (dynamic-wind (const #t) (lambda () (close in) (call-with-temporary-directory (lambda (root) (let ((put-old (string-append root "/real-root"))) (mount "none" root "tmpfs") (mkdir put-old) (call-with-output-file (string-append root "/test") (lambda (port) (display "testing\n" port))) (pivot-root root put-old) ;; The test file should now be located inside the root directory. (write (file-exists? "/test") out) (close out))))) (lambda () (primitive-exit 0)))) (pid (close out) (let ((result (read in))) (close in) (and (zero? (match (waitpid pid) ((_ . status) (status:exit-val status)))) (eq? #t result)))))))) (test-equal "scandir*, ENOENT" ENOENT (catch 'system-error (lambda () (scandir* "/does/not/exist")) (lambda args (system-error-errno args)))) (test-equal "scandir*, ASCII file names" (scandir (dirname (search-path %load-path "guix/base32.scm")) (const #t) stringprocedure int (dynamic-func "creat" (dynamic-link)) (list '* int)))) (creat (string->pointer (string-append directory "/α") "UTF-8") #o644) (creat (string->pointer (string-append directory "/λ") "UTF-8") #o644) (let ((locale (setlocale LC_ALL))) (dynamic-wind (lambda () ;; Make sure that even in a C locale we get the right result. (setlocale LC_ALL "C")) (lambda () (match (scandir* directory) (((names . properties) ...) names))) (lambda () (setlocale LC_ALL locale)))))))) (test-assert "scandir*, properties" (let ((directory (dirname (search-path %load-path "guix/base32.scm")))) (every (lambda (entry name) (match entry ((name2 . properties) (and (string=? name2 name) (let* ((full (string-append directory "/" name)) 2016-04-14gnu: packages: Use 'search-patches' everywhere....* gnu/packages/abiword.scm: Use 'search-patches' for 'patches' field. * gnu/packages/acl.scm: Likewise. * gnu/packages/admin.scm: Likewise. * gnu/packages/algebra.scm: Likewise. * gnu/packages/animation.scm: Likewise. * gnu/packages/apr.scm: Likewise. * gnu/packages/audacity.scm: Likewise. * gnu/packages/audio.scm: Likewise. * gnu/packages/autotools.scm: Likewise. * gnu/packages/avahi.scm: Likewise. * gnu/packages/backup.scm: Likewise. * gnu/packages/base.scm: Likewise. * gnu/packages/bash.scm: Likewise. * gnu/packages/bioinformatics.scm: Likewise. * gnu/packages/cdrom.scm: Likewise. * gnu/packages/ci.scm: Likewise. * gnu/packages/cmake.scm: Likewise. * gnu/packages/cpio.scm: Likewise. * gnu/packages/cross-base.scm: Likewise. * gnu/packages/dico.scm: Likewise. * gnu/packages/doxygen.scm: Likewise. * gnu/packages/ebook.scm: Likewise. * gnu/packages/elf.scm: Likewise. * gnu/packages/emacs.scm: Likewise. * gnu/packages/engineering.scm: Likewise. * gnu/packages/firmware.scm: Likewise. * gnu/packages/flashing-tools.scm: Likewise. * gnu/packages/fltk.scm: Likewise. * gnu/packages/ftp.scm: Likewise. * gnu/packages/games.scm: Likewise. * gnu/packages/gawk.scm: Likewise. * gnu/packages/gcc.scm: Likewise. * gnu/packages/gd.scm: Likewise. * gnu/packages/ghostscript.scm: Likewise. * gnu/packages/glib.scm: Likewise. * gnu/packages/gnome.scm: Likewise. * gnu/packages/gnucash.scm: Likewise. * gnu/packages/gnunet.scm: Likewise. * gnu/packages/gnupg.scm: Likewise. * gnu/packages/gnuzilla.scm: Likewise. * gnu/packages/graphics.scm: Likewise. * gnu/packages/grub.scm: Likewise. * gnu/packages/gtk.scm: Likewise. * gnu/packages/guile.scm: Likewise. * gnu/packages/icu4c.scm: Likewise. * gnu/packages/idutils.scm: Likewise. * gnu/packages/image.scm: Likewise. * gnu/packages/imagemagick.scm: Likewise. * gnu/packages/irc.scm: Likewise. * gnu/packages/ldc.scm: Likewise. * gnu/packages/libcanberra.scm: Likewise. * gnu/packages/libevent.scm: Likewise. * gnu/packages/libreoffice.scm: Likewise. * gnu/packages/libunwind.scm: Likewise. * gnu/packages/libusb.scm: Likewise. * gnu/packages/linux.scm: Likewise. * gnu/packages/lirc.scm: Likewise. * gnu/packages/llvm.scm: Likewise. * gnu/packages/lsh.scm: Likewise. * gnu/packages/lua.scm: Likewise. * gnu/packages/lxqt.scm: Likewise. * gnu/packages/mail.scm: Likewise. * gnu/packages/maths.scm: Likewise. * gnu/packages/mcrypt.scm: Likewise. * gnu/packages/messaging.scm: Likewise. * gnu/packages/mit-krb5.scm: Likewise. * gnu/packages/mp3.scm: Likewise. * gnu/packages/multiprecision.scm: Likewise. * gnu/packages/music.scm: Likewise. * gnu/packages/ninja.scm: Likewise. * gnu/packages/nvi.scm: Likewise. * gnu/packages/ocaml.scm: Likewise. * gnu/packages/orpheus.scm: Likewise. * gnu/packages/ots.scm: Likewise. * gnu/packages/parallel.scm: Likewise. * gnu/packages/patchutils.scm: Likewise. * gnu/packages/pcre.scm: Likewise. * gnu/packages/pdf.scm: Likewise. * gnu/packages/perl.scm: Likewise. * gnu/packages/plotutils.scm: Likewise. * gnu/packages/polkit.scm: Likewise. * gnu/packages/pulseaudio.scm: Likewise. * gnu/packages/python.scm: Likewise. * gnu/packages/qemu.scm: Likewise. * gnu/packages/qt.scm: Likewise. * gnu/packages/ratpoison.scm: Likewise. * gnu/packages/rdf.scm: Likewise. * gnu/packages/readline.scm: Likewise. * gnu/packages/rush.scm: Likewise. * gnu/packages/scheme.scm: Likewise. * gnu/packages/screen.scm: Likewise. * gnu/packages/sdl.scm: Likewise. * gnu/packages/slim.scm: Likewise. * gnu/packages/ssh.scm: Likewise. * gnu/packages/tcl.scm: Likewise. * gnu/packages/tcsh.scm: Likewise. * gnu/packages/texinfo.scm: Likewise. * gnu/packages/tls.scm: Likewise. * gnu/packages/tor.scm: Likewise. * gnu/packages/tv.scm: Likewise. * gnu/packages/valgrind.scm: Likewise. * gnu/packages/version-control.scm: Likewise. * gnu/packages/video.scm: Likewise. * gnu/packages/vpn.scm: Likewise. * gnu/packages/vtk.scm: Likewise. * gnu/packages/w3m.scm: Likewise. * gnu/packages/web.scm: Likewise. * gnu/packages/wicd.scm: Likewise. * gnu/packages/wm.scm: Likewise. * gnu/packages/xdisorg.scm: Likewise. * gnu/packages/xfce.scm: Likewise. * gnu/packages/xiph.scm: Likewise. * gnu/packages/xml.scm: Likewise. * gnu/packages/xorg.scm: Likewise. * gnu/packages/zip.scm: Likewise. Alex Kost 2015-11-04gnu: clang-runtime: Mark MIPS as unsupported....* gnu/packages/llvm.scm (clang-runtime-from-llvm): Add 'supported-systems' field. Ludovic Courtès 2015-08-24gnu: llvm: Update to 3.6.2....* gnu/packages/llvm.scm (llvm, clang-runtime, clang): Update to 3.6.2. Andy Wingo 2015-08-24gnu: clang-runtime: New package, propagated by clang....* gnu/packages/llvm.scm (clang-runtime-from-llvm): New function. (clang-from-llvm): Add clang-runtime argument and propagate clang-runtime input. (clang-runtime, clang-runtime-3.5): New variables. (clang, clang-3.5): Adapt to propagate clang-runtime modules. Andy Wingo 2015-08-24gnu: Simplify LLVM build....* gnu/packages/llvm.scm (llvm)[arguments]: Remove phases argument. Add to configure-flags "-DCMAKE_SKIP_BUILD_RPATH=FALSE" and "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE". Andy Wingo 2015-07-18gnu packages: Clean up synopses and descriptions....* gnu/packages/admin.scm, gnu/packages/algebra.scm, gnu/packages/audio.scm, gnu/packages/backup.scm, gnu/packages/base.scm, gnu/packages/bittorrent.scm, gnu/packages/code.scm, gnu/packages/compression.scm, gnu/packages/databases.scm, gnu/packages/enchant.scm, gnu/packages/firmware.scm, gnu/packages/fonts.scm, gnu/packages/freedesktop.scm, gnu/packages/games.scm, gnu/packages/gd.scm, gnu/packages/gl.scm, gnu/packages/gnome.scm, gnu/packages/gsasl.scm, gnu/packages/gstreamer.scm, gnu/packages/gtk.scm, gnu/packages/guile.scm, gnu/packages/haskell.scm, gnu/packages/language.scm, gnu/packages/lesstif.scm, gnu/packages/libreoffice.scm, gnu/packages/linux.scm, gnu/packages/llvm.scm, gnu/packages/maths.scm, gnu/packages/mcrypt.scm, gnu/packages/mit-krb5.scm, gnu/packages/mp3.scm, gnu/packages/ncdu.scm, gnu/packages/networking.scm, gnu/packages/ntp.scm, gnu/packages/ocaml.scm, gnu/packages/openbox.scm, gnu/packages/pdf.scm, gnu/packages/perl.scm, gnu/packages/pretty-print.scm, gnu/packages/pulseaudio.scm, gnu/packages/python.scm, gnu/packages/rdesktop.scm, gnu/packages/rdf.scm, gnu/packages/ruby.scm, gnu/packages/slang.scm, gnu/packages/slim.scm, gnu/packages/telephony.scm, gnu/packages/tls.scm, gnu/packages/tmux.scm, gnu/packages/tre.scm, gnu/packages/unrtf.scm, gnu/packages/version-control.scm, gnu/packages/vpn.scm, gnu/packages/web.scm, gnu/packages/wget.scm, gnu/packages/xdisorg.scm, gnu/packages/xfce.scm, gnu/packages/xiph.scm: Fix typos. Trim long lines. Add missing periods in the end of sentences. Use double spaces between sentences. Remove trailing whitespaces. Alex Kost 2015-06-26gnu: Refer to 'gcc' instead of 'gcc-4.9'....* gnu/packages/commencement.scm (gcc-boot0, cross-gcc-wrapper, libstdc++, gcc-final): Refer to GCC instead of GCC-4.9. * gnu/packages/cross-base.scm (%xgcc): New variable. (cross-gcc-arguments, cross-gcc): Refer to %XGCC instead of GCC-4.9. * gnu/packages/llvm.scm (clang-from-llvm): Refer to GCC instead of GCC-4.9. * gnu/packages/make-bootstrap.scm (package-with-relocatable-glibc, %gcc-static, %gcc-stripped): Likewise. Ludovic Courtès 2015-06-19gnu: clang: Build without debugging symbols....* gnu/packages/llvm.scm (clang-from-llvm)[arguments]: Add #:build-type. Ludovic Courtès 2015-06-19gnu: clang: Allow 'clang' to link executables....* gnu/packages/patches/clang-libc-search-path.patch: New file. * gnu-system.am (dist_patch_DATA): Add it. * gnu/packages/llvm.scm (clang-from-llvm)[source]: Use it. [inputs]: Add "gcc-lib". [arguments]. Add -DGCC_INSTALL_PREFIX and -DC_INCLUDE_DIRS to #:configure-flags. Add #:phases argument. Ludovic Courtès 2015-06-19gnu: clang: Add search path specifications....* gnu/packages/llvm.scm (clang-from-llvm)[native-search-paths]: New field. Ludovic Courtès 2015-03-02gnu: Add llvm-3.6.0 and clang-3.6.0....* gnu/packages/llvm.scm (llvm): Update to 3.