| 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net> |
| 3 | ;;; |
| 4 | ;;; This file is part of GNU Guix. |
| 5 | ;;; |
| 6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
| 7 | ;;; under the terms of the GNU General Public License as published by |
| 8 | ;;; the Free Software Foundation; either version 3 of the License, or (at |
| 9 | ;;; your option) any later version. |
| 10 | ;;; |
| 11 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
| 12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | ;;; GNU General Public License for more details. |
| 15 | ;;; |
| 16 | ;;; You should have received a copy of the GNU General Public License |
| 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
| 18 | |
| 19 | (define-module (gnu tests security-token) |
| 20 | #:use-module (gnu tests) |
| 21 | #:use-module (gnu system vm) |
| 22 | #:use-module (gnu services) |
| 23 | #:use-module (gnu services security-token) |
| 24 | #:use-module (guix gexp) |
| 25 | #:export (%test-pcscd)) |
| 26 | |
| 27 | (define %pcscd-os |
| 28 | (simple-operating-system |
| 29 | (service pcscd-service-type))) |
| 30 | |
| 31 | (define* (run-pcscd-test) |
| 32 | "Run tests of 'pcscd-service-type'." |
| 33 | (define os |
| 34 | (marionette-operating-system |
| 35 | %pcscd-os |
| 36 | #:imported-modules '((gnu services herd)) |
| 37 | #:requirements '(pcscd))) |
| 38 | |
| 39 | (define test |
| 40 | (with-imported-modules '((gnu build marionette)) |
| 41 | #~(begin |
| 42 | (use-modules (srfi srfi-64) |
| 43 | (gnu build marionette)) |
| 44 | (define marionette |
| 45 | (make-marionette (list #$(virtual-machine os)))) |
| 46 | |
| 47 | (mkdir #$output) |
| 48 | (chdir #$output) |
| 49 | |
| 50 | (test-begin "pcscd") |
| 51 | |
| 52 | (test-assert "pcscd is alive" |
| 53 | (marionette-eval |
| 54 | '(begin |
| 55 | (use-modules (gnu services herd)) |
| 56 | (live-service-running |
| 57 | (find (lambda (live) |
| 58 | (memq 'pcscd (live-service-provision live))) |
| 59 | (current-services)))) |
| 60 | marionette)) |
| 61 | |
| 62 | (test-end) |
| 63 | (exit (= (test-runner-fail-count (test-runner-current)) 0))))) |
| 64 | |
| 65 | (gexp->derivation "pcscd" test)) |
| 66 | |
| 67 | (define %test-pcscd |
| 68 | (system-test |
| 69 | (name "pcscd") |
| 70 | (description "Test a running pcscd daemon.") |
| 71 | (value (run-pcscd-test)))) |