;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016, 2017, 2018, 2019, 2020 Ludovic Courtès ;;; Copyright © 2018 Clément Lassieur ;;; ;;; 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 (gnu tests base) #:use-module (gnu tests) #:use-module (gnu system) #:use-module (gnu system shadow) #:use-module (gnu system nss) #:use-module (gnu system vm) #:use-module (gnu services) #:use-module (gnu services base) #:use-module (gnu services dbus) #:use-module (gnu services avahi) #:use-module (gnu services mcron) #:use-module (gnu services shepherd) #:use-module (gnu services networking) #:use-module (gnu packages base) #:use-module (gnu packages bash) #:use-module (gnu packages imagemagick) #:use-module (gnu packages ocr) #:use-module (gnu packages package-management) #:use-module (gnu packages linux) #:use-module (gnu packages tmux) #:use-module (guix gexp) #:use-module (guix store) #:use-module (guix monads) #:use-module (guix packages) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (run-basic-test %test-basic-os %test-halt %test-cleanup %test-mcron %test-nss-mdns)) (define %simple-os (simple-operating-system)) (define* (run-basic-test os command #:optional (name "basic") #:key initialization root-password) "Return a derivation called NAME that tests basic features of the OS started using COMMAND, a gexp that evaluates to a list of strings. Compare some properties of running system to what's declared in OS, an . When INITIALIZATION is true, it must be a one-argument procedure that is passed a gexp denoting the marionette, and it must return gexp that is inserted before the first test. This is used to introduce an extra initialization step, such as entering a LUKS passphrase. When ROOT-PASSWORD is true, enter it as the root password when logging in. Otherwise assume that there is no password for root." (define special-files (service-value (fold-services (operating-system-services os) #:target-type special-files-service-type))) (define guix&co (match (package-transitive-propagated-inputs guix) (((labels packages) ...) (cons guix packages)))) (define test (with-imported-modules '((gnu build marionette) (guix build syscalls)) #~(begin (use-modules (gnu build marionette) (guix build syscalls) (srfi srfi-1) (srfi srfi-26) (srfi srfi-64) (ice-9 match)) (define marionette (make-marionette #$command)) (mkdir #$output) (chdir #$output) (test-begin "basic") #$(and initialization (initialization #~marionette)) (test-assert "uname" (match (marionette-eval '(uname) marionette) (#("Linux" host-name version _ architecture) (and (string=? host-name #$(operating-system-host-nam