From 150309726f221c9b982e594466d35f5b895391d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 19 Jan 2017 23:21:25 +0100 Subject: syscalls: Add utmpx procedures and data structure. * guix/build/syscalls.scm (): New record type. (%utmpx): New C struct. (login-type): New bits. (setutxent, endutxent, getutxent, utmpx-entries): New procedures. --- tests/syscalls.scm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests/syscalls.scm') diff --git a/tests/syscalls.scm b/tests/syscalls.scm index e4ef32c522..fb2c8e7100 100644 --- a/tests/syscalls.scm +++ b/tests/syscalls.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014, 2015, 2016 Ludovic Courtès +;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès ;;; Copyright © 2015 David Thompson ;;; ;;; This file is part of GNU Guix. @@ -441,6 +441,17 @@ (> (terminal-columns (open-input-string "Join us now, share the software!")) 0)) +(test-assert "utmpx-entries" + (match (utmpx-entries) + (((? utmpx? entries) ...) + (every (lambda (entry) + (match (utmpx-user entry) + ((? string?) + (> (utmpx-pid entry) 0)) + (#f ;might be DEAD_PROCESS + #t))) + entries)))) + (test-end) (false-if-exception (delete-file temp-file)) -- cgit v1.2.3 From 3483f004a98f103acff96effe1309cc620372e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 24 Jan 2017 00:35:16 +0100 Subject: syscalls: Export 'read-utmpx'. * guix/build/syscalls.scm (read-utmpx-from-port): New procedure. * tests/syscalls.scm ("read-utmpx, EOF") ("read-utmpx"): New tests. --- tests/syscalls.scm | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/syscalls.scm') diff --git a/tests/syscalls.scm b/tests/syscalls.scm index fb2c8e7100..92e02f3303 100644 --- a/tests/syscalls.scm +++ b/tests/syscalls.scm @@ -452,6 +452,15 @@ #t))) entries)))) +(test-assert "read-utmpx, EOF" + (eof-object? (read-utmpx (%make-void-port "r")))) + +(unless (access? "/var/run/utmpx" O_RDONLY) + (tes-skip 1)) +(test-assert "read-utmpx" + (let ((result (call-with-input-file "/var/run/utmpx" read-utmpx))) + (or (utmpx? result) (eof-object? result)))) + (test-end) (false-if-exception (delete-file temp-file)) -- cgit v1.2.3 From f18eded8ec4df75444e4feaeb92b3cc1236c2253 Mon Sep 17 00:00:00 2001 From: Paul Garlick Date: Mon, 30 Jan 2017 14:48:37 +0000 Subject: tests: Really skip /var/run/utmpx test when needed. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * tests/syscalls.scm: Change 'test-ski' to 'test-skip'. Signed-off-by: Ludovic Courtès --- tests/syscalls.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/syscalls.scm') diff --git a/tests/syscalls.scm b/tests/syscalls.scm index 92e02f3303..1934704375 100644 --- a/tests/syscalls.scm +++ b/tests/syscalls.scm @@ -456,7 +456,7 @@ (eof-object? (read-utmpx (%make-void-port "r")))) (unless (access? "/var/run/utmpx" O_RDONLY) - (tes-skip 1)) + (test-skip 1)) (test-assert "read-utmpx" (let ((result (call-with-input-file "/var/run/utmpx" read-utmpx))) (or (utmpx? result) (eof-object? result)))) -- cgit v1.2.3 From a1a8b7f2e20513a3ad968e74e7ec52546404e3c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sat, 11 Feb 2017 22:26:36 +0100 Subject: tests: Relax test on utmpx entries. Partly fixes . Reported by Paul Garlick . * tests/syscalls.scm ("utmpx-entries"): Check whether ENTRY is of type 'BOOT_TIME', in which case PID may be 0. --- tests/syscalls.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/syscalls.scm') diff --git a/tests/syscalls.scm b/tests/syscalls.scm index 1934704375..8db45b41b6 100644 --- a/tests/syscalls.scm +++ b/tests/syscalls.scm @@ -447,7 +447,8 @@ (every (lambda (entry) (match (utmpx-user entry) ((? string?) - (> (utmpx-pid entry) 0)) + (or (eqv? (login-type BOOT_TIME) (utmpx-login-type entry)) + (> (utmpx-pid entry) 0))) (#f ;might be DEAD_PROCESS #t))) entries)))) -- cgit v1.2.3