summary refs log tree commit diff
path: root/gnu/tests/base.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-01-24 00:45:11 +0100
committerLudovic Courtès <ludo@gnu.org>2017-01-24 00:46:37 +0100
commit2986995b85e76f12741fcdda8dd0e1a636620dec (patch)
treee7d55a20163edad515c6fbd199cddc17a8287ee9 /gnu/tests/base.scm
parent3483f004a98f103acff96effe1309cc620372e79 (diff)
downloadguix-2986995b85e76f12741fcdda8dd0e1a636620dec.tar.gz
services: Create /var/log/wtmp upon activation.
This fixes a bug whereby /var/log/wtmp would never be created, and thus
accounting information would be lost.

* gnu/services.scm (activation-script): Create /var/log/wtmp.
* gnu/tests/base.scm (run-basic-test)["wtmp entry"]: New test.
Diffstat (limited to 'gnu/tests/base.scm')
-rw-r--r--gnu/tests/base.scm23
1 files changed, 23 insertions, 0 deletions
diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm
index 2687a6cdb8..a725ca90f3 100644
--- a/gnu/tests/base.scm
+++ b/gnu/tests/base.scm
@@ -194,6 +194,29 @@ info --version")
                             (utmpx-entries)))
              marionette))
 
+          ;; Likewise for /var/log/wtmp (used by 'last').
+          (test-assert "wtmp entry"
+            (match (marionette-eval
+                    '(begin
+                       (use-modules (guix build syscalls)
+                                    (srfi srfi-1))
+
+                       (define (entry->list entry)
+                         (list (utmpx-user entry) (utmpx-line entry)
+                               (utmpx-host entry) (utmpx-login-type entry)))
+
+                       (call-with-input-file "/var/log/wtmp"
+                         (lambda (port)
+                           (let loop ((result '()))
+                             (if (eof-object? (peek-char port))
+                                 (map entry->list (reverse result))
+                                 (loop (cons (read-utmpx port) result)))))))
+                    marionette)
+              (((users lines hosts types) ..1)
+               (every (lambda (type)
+                        (eqv? type (login-type LOGIN_PROCESS)))
+                      types))))
+
           (test-assert "host name resolution"
             (match (marionette-eval
                     '(begin