From patchwork Fri Feb 28 10:04:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 39433 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id E1B6D27BBEA; Fri, 28 Feb 2025 10:06:30 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1C49627BBE2 for ; Fri, 28 Feb 2025 10:06:30 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tnxG0-0003SA-S6; Fri, 28 Feb 2025 05:06:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnxFs-0003MV-8n for guix-patches@gnu.org; Fri, 28 Feb 2025 05:06:05 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tnxFr-0000Ov-Cz for guix-patches@gnu.org; Fri, 28 Feb 2025 05:06:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=x19cj3Atco4/NwVa4HfCMrsgqZhNqnUTTDM+c/beV/k=; b=TIyHlgm09aGXKzrgv6VC7Rr620J8I1c9PqWp5VeXtt2mi1oUc6d3Uoz4Sai1t4s6gkdiL34LKxKR+KPX7xxMbrnOsp7lTq4VnImI7dP1Ytn2kbokbwVtVAIP6eQbw8PFjkbhqIj9toA18d02ndIuKBhK0PjyV3NMInbv2gNvVtU39FRHopJ0HOCWtQYD011fY7jjdT2WbJPvNgjncgGBSURz3NcfMu9c2CIkn+YVrgjDsgCrvdLsvVQPLBlxpTkBKGTBai5ajfHND3vSprVVG00/pq82xp9iduXmNEgeTnrGVQE5T6Peeb4ER5VnvuxNdzY8eNTFJbjk1a5EeEcBFQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tnxFr-0001PQ-85 for guix-patches@gnu.org; Fri, 28 Feb 2025 05:06:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#76636] [PATCH 1/5] tests: Move mcron test to its own file. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 28 Feb 2025 10:06:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 76636 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 76636@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 76636-submit@debbugs.gnu.org id=B76636.17407371295232 (code B ref 76636); Fri, 28 Feb 2025 10:06:03 +0000 Received: (at 76636) by debbugs.gnu.org; 28 Feb 2025 10:05:29 +0000 Received: from localhost ([127.0.0.1]:45363 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tnxFH-0001M8-Jb for submit@debbugs.gnu.org; Fri, 28 Feb 2025 05:05:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48060) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tnxFA-0001KW-AP for 76636@debbugs.gnu.org; Fri, 28 Feb 2025 05:05:22 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnxF1-0000JY-IA; Fri, 28 Feb 2025 05:05:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=x19cj3Atco4/NwVa4HfCMrsgqZhNqnUTTDM+c/beV/k=; b=knYtbh+3j0H6Bx17sSOk pPYDWVdAu1Eukm5xS1S+sw5DXzMylb31XrAqkfMS1++kxitHv+/Fi50zWtU/itZ5kQhnw3XQkufTI qQn4CMSzVIwJDco03Ev9CQSWoG9342ky4lfFAp6UojqYNAuTyDY5kdZyclYG888jfdgML0Vs02EbT jvYhU4R9uodCPHJ1RUOkVKa8E9K7YN/DnYADlBhGLbJy+kfwsq04yza+bXGk2GeewXmrDwf4o2HMi 0HzaNONXrQsFCLIkrhAtl2ERW5LybT3Um+K7Q+OfdIWnjTTB3E3mnXcU/nbXm+dzBbh8fqcBtM2Tn ZXRMaVeEcMHvow==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Fri, 28 Feb 2025 11:04:28 +0100 Message-ID: <72781f922736d543f55abe13d439b91d16815dd7.1740736327.git.ludo@gnu.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches This mirrors the (gnu services mcron) module. * gnu/tests/base.scm (%mcron-os, run-mcron-test, %test-mcron): Move to… * gnu/tests/mcron.scm: … here. New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. Change-Id: Id2830d08d8e797e008c5fec7964fb5f6a5ea2fad --- gnu/local.mk | 1 + gnu/tests/base.scm | 92 ---------------------------------- gnu/tests/mcron.scm | 118 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 92 deletions(-) create mode 100644 gnu/tests/mcron.scm diff --git a/gnu/local.mk b/gnu/local.mk index b5c8c1a4665..4b31f8a4a0b 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -862,6 +862,7 @@ GNU_SYSTEM_MODULES = \ %D%/tests/lightdm.scm \ %D%/tests/linux-modules.scm \ %D%/tests/mail.scm \ + %D%/tests/mcron.scm \ %D%/tests/messaging.scm \ %D%/tests/networking.scm \ %D%/tests/package-management.scm \ diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm index d9e30e9b1de..c3040002d37 100644 --- a/gnu/tests/base.scm +++ b/gnu/tests/base.scm @@ -33,7 +33,6 @@ (define-module (gnu tests base) #: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) @@ -60,7 +59,6 @@ (define-module (gnu tests base) %test-halt %test-root-unmount %test-cleanup - %test-mcron %test-nss-mdns %test-activation)) @@ -872,96 +870,6 @@ (define %test-cleanup non-ASCII names from /tmp.") (value (run-cleanup-test name)))) - -;;; -;;; Mcron. -;;; - -(define %mcron-os - ;; System with an mcron service, with one mcron job for "root" and one mcron - ;; job for an unprivileged user. - (let ((job1 #~(job '(next-second '(0 5 10 15 20 25 30 35 40 45 50 55)) - (lambda () - (unless (file-exists? "witness") - (call-with-output-file "witness" - (lambda (port) - (display (list (getuid) (getgid)) port))))))) - (job2 #~(job next-second-from - (lambda () - (call-with-output-file "witness" - (lambda (port) - (display (list (getuid) (getgid)) port)))) - #:user "alice")) - (job3 #~(job next-second-from ;to test $PATH - "touch witness-touch"))) - (simple-operating-system - (service mcron-service-type - (mcron-configuration (jobs (list job1 job2 job3))))))) - -(define (run-mcron-test name) - (define os - (marionette-operating-system - %mcron-os - #:imported-modules '((gnu services herd) - (guix combinators)))) - - (define test - (with-imported-modules '((gnu build marionette)) - #~(begin - (use-modules (gnu build marionette) - (srfi srfi-64) - (ice-9 match)) - - (define marionette - (make-marionette (list #$(virtual-machine os)))) - - (test-runner-current (system-test-runner #$output)) - (test-begin "mcron") - - (test-assert "service running" - (marionette-eval - '(begin - (use-modules (gnu services herd)) - (start-service 'mcron)) - marionette)) - - ;; Make sure root's mcron job runs, has its cwd set to "/root", and - ;; runs with the right UID/GID. - (test-equal "root's job" - '(0 0) - (wait-for-file "/root/witness" marionette)) - - ;; Likewise for Alice's job. We cannot know what its GID is since - ;; it's chosen by 'groupadd', but it's strictly positive. - (test-assert "alice's job" - (match (wait-for-file "/home/alice/witness" marionette) - ((1000 gid) - (>= gid 100)))) - - ;; Last, the job that uses a command; allows us to test whether - ;; $PATH is sane. - (test-equal "root's job with command" - "" - (wait-for-file "/root/witness-touch" marionette - #:read '(@ (ice-9 rdelim) read-string))) - - ;; Make sure the 'schedule' action is accepted. - (test-equal "schedule action" - '(#t) ;one value, #t - (marionette-eval '(with-shepherd-action 'mcron ('schedule) result - result) - marionette)) - - (test-end)))) - - (gexp->derivation name test)) - -(define %test-mcron - (system-test - (name "mcron") - (description "Make sure the mcron service works as advertised.") - (value (run-mcron-test name)))) - ;;; ;;; Avahi and NSS-mDNS. diff --git a/gnu/tests/mcron.scm b/gnu/tests/mcron.scm new file mode 100644 index 00000000000..052c8439cc7 --- /dev/null +++ b/gnu/tests/mcron.scm @@ -0,0 +1,118 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2016-2020, 2022, 2024 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 mcron) + #:use-module (gnu tests) + #:use-module (gnu system) + #:use-module (gnu system vm) + #:use-module (gnu services) + #:use-module (gnu services mcron) + #:use-module (guix gexp) + #:use-module (guix store) + #:use-module (guix monads) + #:export (%test-mcron)) + +;;; +;;; Mcron. +;;; + +(define %mcron-os + ;; System with an mcron service, with one mcron job for "root" and one mcron + ;; job for an unprivileged user. + (let ((job1 #~(job '(next-second '(0 5 10 15 20 25 30 35 40 45 50 55)) + (lambda () + (unless (file-exists? "witness") + (call-with-output-file "witness" + (lambda (port) + (display (list (getuid) (getgid)) port))))))) + (job2 #~(job next-second-from + (lambda () + (call-with-output-file "witness" + (lambda (port) + (display (list (getuid) (getgid)) port)))) + #:user "alice")) + (job3 #~(job next-second-from ;to test $PATH + "touch witness-touch"))) + (simple-operating-system + (service mcron-service-type + (mcron-configuration (jobs (list job1 job2 job3))))))) + +(define (run-mcron-test name) + (define os + (marionette-operating-system + %mcron-os + #:imported-modules '((gnu services herd) + (guix combinators)))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (gnu build marionette) + (srfi srfi-64) + (ice-9 match)) + + (define marionette + (make-marionette (list #$(virtual-machine os)))) + + (test-runner-current (system-test-runner #$output)) + (test-begin "mcron") + + (test-assert "service running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'mcron)) + marionette)) + + ;; Make sure root's mcron job runs, has its cwd set to "/root", and + ;; runs with the right UID/GID. + (test-equal "root's job" + '(0 0) + (wait-for-file "/root/witness" marionette)) + + ;; Likewise for Alice's job. We cannot know what its GID is since + ;; it's chosen by 'groupadd', but it's strictly positive. + (test-assert "alice's job" + (match (wait-for-file "/home/alice/witness" marionette) + ((1000 gid) + (>= gid 100)))) + + ;; Last, the job that uses a command; allows us to test whether + ;; $PATH is sane. + (test-equal "root's job with command" + "" + (wait-for-file "/root/witness-touch" marionette + #:read '(@ (ice-9 rdelim) read-string))) + + ;; Make sure the 'schedule' action is accepted. + (test-equal "schedule action" + '(#t) ;one value, #t + (marionette-eval '(with-shepherd-action 'mcron ('schedule) result + result) + marionette)) + + (test-end)))) + + (gexp->derivation name test)) + +(define %test-mcron + (system-test + (name "mcron") + (description "Make sure the mcron service works as advertised.") + (value (run-mcron-test name)))) From patchwork Fri Feb 28 10:04:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 39432 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 4F53227BBEA; Fri, 28 Feb 2025 10:06:25 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 92BD527BBE2 for ; Fri, 28 Feb 2025 10:06:24 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tnxG0-0003S8-SP; Fri, 28 Feb 2025 05:06:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnxFr-0003Lr-Ja for guix-patches@gnu.org; Fri, 28 Feb 2025 05:06:03 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tnxFr-0000Op-4O for guix-patches@gnu.org; Fri, 28 Feb 2025 05:06:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=kWvnlf0qJ2dzqk6bonLH1W3O754L6xbEWQp/LXgoynk=; b=AlC95c2GcfSJfA6+6EbPfAe9TmvQnCPXeZNUGO3FSnWcGzu9S2Esy4cQ4cjWLjIbnenF9cr82ofP2Wxxt6jGT/NOj+ZEtdmaiVPg9bpDEdxij7fdrBVD9yS0EQXlA6yjhuZ6puYDGOC5d+PDQzGFsY+YuDPjllfpXGf2Fz3Xvw4tQUqTNF2rTRrf4tPTnJyBx5dU3/fGAux2nzOzfsX7POW9feOvNvrkMI3VsWzZEmyaIo42IZl0o0xCxEleFXkC/Mhao7Z8xaSVs5FIIOLypAvMXVkBm4AEbkr4Dat3uvsmaR7Qg577OwIQi/IWK9WJZb7vZtmaqQtVH0PzFLIcTA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tnxFq-0001PJ-Oc for guix-patches@gnu.org; Fri, 28 Feb 2025 05:06:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#76636] [PATCH 2/5] tests: Move Avahi test to its own file. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 28 Feb 2025 10:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 76636 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 76636@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 76636-submit@debbugs.gnu.org id=B76636.17407371275214 (code B ref 76636); Fri, 28 Feb 2025 10:06:02 +0000 Received: (at 76636) by debbugs.gnu.org; 28 Feb 2025 10:05:27 +0000 Received: from localhost ([127.0.0.1]:45359 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tnxFE-0001Ll-Ly for submit@debbugs.gnu.org; Fri, 28 Feb 2025 05:05:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48066) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tnxFA-0001KX-AR for 76636@debbugs.gnu.org; Fri, 28 Feb 2025 05:05:21 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnxF3-0000Js-Jr; Fri, 28 Feb 2025 05:05:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=kWvnlf0qJ2dzqk6bonLH1W3O754L6xbEWQp/LXgoynk=; b=nqbXh3KU6PFqRythN3SR GDtIms5Zq9KAbiZnY+uThrNTYQqlo7okhnGJO5Uck2Rvn1zK+EhJElYIoVxgMzfhZJF+CZUmFs3hu rg6k74sdiQxmX5GMYlB7xnq3Rt7EOmKx9NFWu1vFphFO/t0qA+VU1A1vTB3fbFazjI5m5Ue4SpG/H PrrDxiZecYi9bqBr5QwT7uiZ/Q+cb8IIjh7QmEUxQbUWKXv0CPb3qJMNtNcqqzNZrbfSJrLDbK9rf /enB8JEz7N5pmSzs4CDcZcX2t8iy8KGQ0Kks+8fR0H1bd8JO4S5l1fUVoTB84dOXAIzbqWumL+eBI UM/ChRmGHyKJUg==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Fri, 28 Feb 2025 11:04:29 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches This mirrors the (gnu services avahi) module. * gnu/tests/base.scm (%avahi-os, run-nss-mdns-test, %test-nss-mdns): Move to… * gnu/tests/avahi.scm: … here. New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. Change-Id: I04705e57408619d948c928873c40c470aa4e949d --- gnu/local.mk | 1 + gnu/tests/avahi.scm | 183 ++++++++++++++++++++++++++++++++++++++++++++ gnu/tests/base.scm | 156 ------------------------------------- 3 files changed, 184 insertions(+), 156 deletions(-) create mode 100644 gnu/tests/avahi.scm diff --git a/gnu/local.mk b/gnu/local.mk index 4b31f8a4a0b..d923afd633e 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -838,6 +838,7 @@ GNU_SYSTEM_MODULES = \ \ %D%/tests.scm \ %D%/tests/audio.scm \ + %D%/tests/avahi.scm \ %D%/tests/base.scm \ %D%/tests/cachefilesd.scm \ %D%/tests/ci.scm \ diff --git a/gnu/tests/avahi.scm b/gnu/tests/avahi.scm new file mode 100644 index 00000000000..261ec8a7312 --- /dev/null +++ b/gnu/tests/avahi.scm @@ -0,0 +1,183 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2016-2020, 2022, 2024 Ludovic Courtès +;;; +;;; 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 avahi) + #:use-module (gnu tests) + #:use-module (gnu system) + #: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 networking) + #:use-module (guix gexp) + #:use-module (guix store) + #:use-module (guix monads) + #:export (%test-nss-mdns)) + +;;; +;;; Avahi and NSS-mDNS. +;;; + +(define %avahi-os + (operating-system + (inherit (simple-operating-system)) + (name-service-switch %mdns-host-lookup-nss) + (services (cons* (service avahi-service-type + (avahi-configuration (debug? #t))) + (service dbus-root-service-type) + (service dhcp-client-service-type) ;needed for multicast + + ;; Enable heavyweight debugging output. + (modify-services (operating-system-user-services + %simple-os) + (nscd-service-type config + => (nscd-configuration + (inherit config) + (debug-level 3) + (log-file "/dev/console"))) + (syslog-service-type config + => + (syslog-configuration + (inherit config) + (config-file + (plain-file + "syslog.conf" + "*.* /dev/console\n"))))))))) + +(define (run-nss-mdns-test) + ;; Test resolution of '.local' names via libc. Start the marionette service + ;; *after* nscd. Failing to do that, libc will try to connect to nscd, + ;; fail, then never try again (see '__nss_not_use_nscd_hosts' in libc), + ;; leading to '.local' resolution failures. + (define os + (marionette-operating-system + %avahi-os + #:requirements '(nscd) + #:imported-modules '((gnu services herd) + (guix combinators)))) + + (define mdns-host-name + (string-append (operating-system-host-name os) + ".local")) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (gnu build marionette) + (srfi srfi-1) + (srfi srfi-64) + (ice-9 match)) + + (define marionette + (make-marionette (list #$(virtual-machine os)))) + + (mkdir #$output) + (chdir #$output) + + (test-runner-current (system-test-runner)) + (test-begin "avahi") + + (test-assert "nscd PID file is created" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'nscd)) + marionette)) + + (test-assert "nscd is listening on its socket" + (marionette-eval + ;; XXX: Work around a race condition in nscd: nscd creates its + ;; PID file before it is listening on its socket. + '(let ((sock (socket PF_UNIX SOCK_STREAM 0))) + (let try () + (catch 'system-error + (lambda () + (connect sock AF_UNIX "/var/run/nscd/socket") + (close-port sock) + (format #t "nscd is ready~%") + #t) + (lambda args + (format #t "waiting for nscd...~%") + (usleep 500000) + (try))))) + marionette)) + + (test-assert "avahi is running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'avahi-daemon)) + marionette)) + + (test-assert "network is up" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'networking)) + marionette)) + + (test-equal "avahi-resolve-host-name" + 0 + (marionette-eval + '(system* + "/run/current-system/profile/bin/avahi-resolve-host-name" + "-v" #$mdns-host-name) + marionette)) + + (test-equal "avahi-browse" + 0 + (marionette-eval + '(system* "/run/current-system/profile/bin/avahi-browse" "-avt") + marionette)) + + (test-assert "getaddrinfo .local" + ;; Wait for the 'avahi-daemon' service and perform a resolution. + (match (marionette-eval + '(getaddrinfo #$mdns-host-name) + marionette) + (((? vector? addrinfos) ..1) + (pk 'getaddrinfo addrinfos) + (and (any (lambda (ai) + (= AF_INET (addrinfo:fam ai))) + addrinfos) + (any (lambda (ai) + (= AF_INET6 (addrinfo:fam ai))) + addrinfos))))) + + (test-assert "gethostbyname .local" + (match (pk 'gethostbyname + (marionette-eval '(gethostbyname #$mdns-host-name) + marionette)) + ((? vector? result) + (and (string=? (hostent:name result) #$mdns-host-name) + (= (hostent:addrtype result) AF_INET))))) + + + (test-end)))) + + (gexp->derivation "nss-mdns" test)) + +(define %test-nss-mdns + (system-test + (name "nss-mdns") + (description + "Test Avahi's multicast-DNS implementation, and in particular, test its +glibc name service switch (NSS) module.") + (value (run-nss-mdns-test)))) diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm index c3040002d37..89e797259dc 100644 --- a/gnu/tests/base.scm +++ b/gnu/tests/base.scm @@ -27,12 +27,9 @@ (define-module (gnu tests base) #:autoload (gnu system image) (system-image) #:use-module (gnu system privilege) #: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 shepherd) #:use-module (gnu services networking) #:use-module (gnu packages base) @@ -59,7 +56,6 @@ (define-module (gnu tests base) %test-halt %test-root-unmount %test-cleanup - %test-nss-mdns %test-activation)) (define %simple-os @@ -870,158 +866,6 @@ (define %test-cleanup non-ASCII names from /tmp.") (value (run-cleanup-test name)))) - -;;; -;;; Avahi and NSS-mDNS. -;;; - -(define %avahi-os - (operating-system - (inherit %simple-os) - (name-service-switch %mdns-host-lookup-nss) - (services (cons* (service avahi-service-type - (avahi-configuration (debug? #t))) - (service dbus-root-service-type) - (service dhcp-client-service-type) ;needed for multicast - - ;; Enable heavyweight debugging output. - (modify-services (operating-system-user-services - %simple-os) - (nscd-service-type config - => (nscd-configuration - (inherit config) - (debug-level 3) - (log-file "/dev/console"))) - (syslog-service-type config - => - (syslog-configuration - (inherit config) - (config-file - (plain-file - "syslog.conf" - "*.* /dev/console\n"))))))))) - -(define (run-nss-mdns-test) - ;; Test resolution of '.local' names via libc. Start the marionette service - ;; *after* nscd. Failing to do that, libc will try to connect to nscd, - ;; fail, then never try again (see '__nss_not_use_nscd_hosts' in libc), - ;; leading to '.local' resolution failures. - (define os - (marionette-operating-system - %avahi-os - #:requirements '(nscd) - #:imported-modules '((gnu services herd) - (guix combinators)))) - - (define mdns-host-name - (string-append (operating-system-host-name os) - ".local")) - - (define test - (with-imported-modules '((gnu build marionette)) - #~(begin - (use-modules (gnu build marionette) - (srfi srfi-1) - (srfi srfi-64) - (ice-9 match)) - - (define marionette - (make-marionette (list #$(virtual-machine os)))) - - (mkdir #$output) - (chdir #$output) - - (test-runner-current (system-test-runner)) - (test-begin "avahi") - - (test-assert "nscd PID file is created" - (marionette-eval - '(begin - (use-modules (gnu services herd)) - (start-service 'nscd)) - marionette)) - - (test-assert "nscd is listening on its socket" - (marionette-eval - ;; XXX: Work around a race condition in nscd: nscd creates its - ;; PID file before it is listening on its socket. - '(let ((sock (socket PF_UNIX SOCK_STREAM 0))) - (let try () - (catch 'system-error - (lambda () - (connect sock AF_UNIX "/var/run/nscd/socket") - (close-port sock) - (format #t "nscd is ready~%") - #t) - (lambda args - (format #t "waiting for nscd...~%") - (usleep 500000) - (try))))) - marionette)) - - (test-assert "avahi is running" - (marionette-eval - '(begin - (use-modules (gnu services herd)) - (start-service 'avahi-daemon)) - marionette)) - - (test-assert "network is up" - (marionette-eval - '(begin - (use-modules (gnu services herd)) - (start-service 'networking)) - marionette)) - - (test-equal "avahi-resolve-host-name" - 0 - (marionette-eval - '(system* - "/run/current-system/profile/bin/avahi-resolve-host-name" - "-v" #$mdns-host-name) - marionette)) - - (test-equal "avahi-browse" - 0 - (marionette-eval - '(system* "/run/current-system/profile/bin/avahi-browse" "-avt") - marionette)) - - (test-assert "getaddrinfo .local" - ;; Wait for the 'avahi-daemon' service and perform a resolution. - (match (marionette-eval - '(getaddrinfo #$mdns-host-name) - marionette) - (((? vector? addrinfos) ..1) - (pk 'getaddrinfo addrinfos) - (and (any (lambda (ai) - (= AF_INET (addrinfo:fam ai))) - addrinfos) - (any (lambda (ai) - (= AF_INET6 (addrinfo:fam ai))) - addrinfos))))) - - (test-assert "gethostbyname .local" - (match (pk 'gethostbyname - (marionette-eval '(gethostbyname #$mdns-host-name) - marionette)) - ((? vector? result) - (and (string=? (hostent:name result) #$mdns-host-name) - (= (hostent:addrtype result) AF_INET))))) - - - (test-end)))) - - (gexp->derivation "nss-mdns" test)) - -(define %test-nss-mdns - (system-test - (name "nss-mdns") - (description - "Test Avahi's multicast-DNS implementation, and in particular, test its -glibc name service switch (NSS) module.") - (value (run-nss-mdns-test)))) - ;;; ;;; Activation: Order of activation scripts From patchwork Fri Feb 28 10:04:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 39431 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 8ADCE27BBEA; Fri, 28 Feb 2025 10:06:24 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8AEF627BBE2 for ; Fri, 28 Feb 2025 10:06:23 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tnxFx-0003PF-8E; Fri, 28 Feb 2025 05:06:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnxFs-0003Mc-Bc for guix-patches@gnu.org; Fri, 28 Feb 2025 05:06:05 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tnxFr-0000P2-QO for guix-patches@gnu.org; Fri, 28 Feb 2025 05:06:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=gslXYDTp9tnGvjUo9kYgOxdttde8RkSNbU5gOnh8fec=; b=ZA+EHg9BnVaUCiTtgM1JGUkhSkTee19YaJASxt6ExRPG2Xc4G4nc0zk0saHzLw3G8PEApxAZnErfZeN+kXzl8ABaTyNLdoYm4l3Usega9m7dCTgObXt8QMK0wOV46SPR4/6sRPn2hQqb7orgdZAOz7N7QvCcx1doQTADfpOSC2hdiegtIvgZDLQFq5EXtO5ZpyGPM6mru1gwj2jDh2CtR3ZO8tmsYLLjhBEM4EL22IBwaLpDf0pfDkgdJuMb+AsjrB2OJ/B3pImF8IDmzGAEDANp00XnqDhDdnZ1lahY//Wc5ObOQf8aLVQNnLFuCxmpZvlapuHaD+/NfBDAeCPbFg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tnxFr-0001PY-Mm for guix-patches@gnu.org; Fri, 28 Feb 2025 05:06:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#76636] [PATCH 3/5] tests: Add =?utf-8?b?4oCYZ3VpeC1kYWVtb24=?= =?utf-8?b?4oCZ?= test. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 28 Feb 2025 10:06:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 76636 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 76636@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 76636-submit@debbugs.gnu.org id=B76636.17407371315246 (code B ref 76636); Fri, 28 Feb 2025 10:06:03 +0000 Received: (at 76636) by debbugs.gnu.org; 28 Feb 2025 10:05:31 +0000 Received: from localhost ([127.0.0.1]:45367 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tnxFJ-0001MS-S5 for submit@debbugs.gnu.org; Fri, 28 Feb 2025 05:05:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48068) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tnxFA-0001KY-Eh for 76636@debbugs.gnu.org; Fri, 28 Feb 2025 05:05:23 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnxF4-0000K2-Gx; Fri, 28 Feb 2025 05:05:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=gslXYDTp9tnGvjUo9kYgOxdttde8RkSNbU5gOnh8fec=; b=U9p0vJQLqADd4eFyOOTR S0Qb51sPsJmsok1MoWwgd7PcNP4ljCk66WRgThziGv/+b07id3TkfnQKUEgR0APrz58xParAwETi1 bwme8R0aRhRN/WVLbcK5SOWIOXNIPv17Heqpka0SA9N9DcztmSMXge6ZDluifFbYFjU9Yi3/zdev4 gewEotmInZ1/2ESErvpuBJG2zyIKrMj6Q+abUJbVSsneIn/vWUXRZc6NsWFMh24TeluqvsnC8VX/2 WNRWPtZdKsSBpu5v96g0Azo/pXjYt/wW5ITu1/OPqSzLGk7InBnfz7VLyPmp/V6wbkrXztP7yyZEN C9lZoEIMnd5g3Q==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Fri, 28 Feb 2025 11:04:30 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/tests/base.scm (manifest-entry-without-grafts): New procedure. (%hello-dependencies-manifest): New variable. (run-guix-daemon-test): New procedure. (%test-guix-daemon): New variable. Change-Id: Ia37966de1f61fb428e6fb2244271bf389a74af6d --- gnu/tests/base.scm | 191 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 190 insertions(+), 1 deletion(-) diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm index 89e797259dc..38bd1e687fc 100644 --- a/gnu/tests/base.scm +++ b/gnu/tests/base.scm @@ -34,6 +34,8 @@ (define-module (gnu tests base) #:use-module (gnu services networking) #:use-module (gnu packages base) #:use-module (gnu packages bash) + #:use-module (gnu packages bootstrap) + #:use-module (gnu packages guile) #:use-module (gnu packages imagemagick) #:use-module (gnu packages linux) #:use-module (gnu packages ocr) @@ -45,6 +47,7 @@ (define-module (gnu tests base) #:use-module (guix monads) #:use-module (guix modules) #:use-module (guix packages) + #:use-module (guix profiles) #:use-module (guix utils) #:use-module ((srfi srfi-1) #:hide (partition)) #:use-module (ice-9 match) @@ -56,7 +59,8 @@ (define-module (gnu tests base) %test-halt %test-root-unmount %test-cleanup - %test-activation)) + %test-activation + %test-guix-daemon)) (define %simple-os (simple-operating-system)) @@ -981,3 +985,188 @@ (define %test-activation (name "activation") (description "Test that activation scripts are run in the correct order") (value (run-activation-test name)))) + + +;;; +;;; Build daemon. +;;; + +(define (manifest-entry-without-grafts entry) + "Return ENTRY with grafts disabled on its contents." + (manifest-entry + (inherit entry) + (item (with-parameters ((%graft? #f)) + (manifest-entry-item entry))))) + +(define %hello-dependencies-manifest ;TODO: Share with (gnu tests foreign). + ;; Build dependencies of 'hello' needed to test 'guix build hello'. + (concatenate-manifests + (list (map-manifest-entries + manifest-entry-without-grafts + (package->development-manifest hello)) + + ;; Add the source of 'hello'. + (manifest + (list (manifest-entry + (name "hello-source") + (version (package-version hello)) + (item (let ((file (origin-actual-file-name + (package-source hello)))) + (computed-file + "hello-source" + #~(begin + ;; Put the tarball in a subdirectory since + ;; profile union crashes otherwise. + (mkdir #$output) + (mkdir (in-vicinity #$output "src")) + (symlink #$(package-source hello) + (in-vicinity #$output + (string-append "src/" + #$file)))))))))) + + ;; Include 'guile-final', which is needed when building derivations + ;; such as that of 'hello' but missing from the development manifest. + ;; Add '%bootstrap-guile', used by 'guix install --bootstrap'. + (map-manifest-entries + manifest-entry-without-grafts + (packages->manifest (list (canonical-package guile-3.0) + %bootstrap-guile)))))) + +(define (run-guix-daemon-test os) + (define test-image + (image (operating-system os) + (format 'compressed-qcow2) + (volatile-root? #f) + (shared-store? #f) + (partition-table-type 'mbr) + (partitions + (list (partition + (size (* 4 (expt 2 30))) + (offset (* 512 2048)) ;leave room for GRUB + (flags '(boot)) + (label "root")))))) + + (define test + (with-imported-modules (source-module-closure + '((gnu build marionette) + (guix build utils))) + #~(begin + (use-modules (gnu build marionette) + (guix build utils) + (srfi srfi-64)) + + (define marionette + (make-marionette + (list (string-append #$qemu-minimal "/bin/" (qemu-command)) + #$@(common-qemu-options (system-image test-image) '() + #:image-format "qcow2" + #:rw-image? #t) + "-m" "512" + "-nographic" "-serial" "stdio" + "-snapshot"))) + + (test-runner-current (system-test-runner #$output)) + (test-begin "guix-daemon") + + (test-equal "guix describe" + 0 + (marionette-eval '(system* "guix" "describe") + marionette)) + + ;; XXX: What follows is largely copied form (gnu tests foreign). + + (test-equal "hello not already built" + #f + ;; Check that the next test will really build 'hello'. + (marionette-eval '(file-exists? + #$(with-parameters ((%graft? #f)) + hello)) + marionette)) + + (test-equal "guix build hello" + 0 + ;; Check that guix-daemon is up and running and that the build + ;; environment is properly set up (build users, etc.). + (marionette-eval '(system* "guix" "build" "hello" "--no-grafts") + marionette)) + + (test-assert "hello indeed built" + (marionette-eval '(file-exists? + #$(with-parameters ((%graft? #f)) + hello)) + marionette)) + + (test-equal "guix install hello" + 0 + ;; Check that ~/.guix-profile & co. are properly created. + (marionette-eval '(let ((pw (getpwuid (getuid)))) + (setenv "USER" (passwd:name pw)) + (setenv "HOME" (pk 'home (passwd:dir pw))) + (system* "guix" "install" "hello" + "--no-grafts" "--bootstrap")) + marionette)) + + (test-equal "user profile created" + 0 + (marionette-eval '(system "ls -lad ~/.guix-profile") + marionette)) + + (test-equal "hello" + 0 + (marionette-eval '(system "~/.guix-profile/bin/hello") + marionette)) + + (test-equal "guix install hello, unprivileged user" + 0 + ;; Check that 'guix' is in $PATH for new users and that + ;; ~user/.guix-profile also gets created. + (marionette-eval '(system "su - user -c \ +'guix install hello --no-grafts --bootstrap'") + marionette)) + + (test-equal "user hello" + 0 + (marionette-eval '(system "~user/.guix-profile/bin/hello") + marionette)) + + (test-equal "unprivileged user profile created" + 0 + (marionette-eval '(system "ls -lad ~user/.guix-profile") + marionette)) + + (test-equal "store is read-only" + EROFS + (marionette-eval '(catch 'system-error + (lambda () + (mkdir (in-vicinity #$(%store-prefix) + "whatever")) + 0) + (lambda args + (system-error-errno args))) + marionette)) + + (test-end)))) + + (gexp->derivation "guix-daemon-test" test)) + +(define %test-guix-daemon + (system-test + (name "guix-daemon") + (description + "Test 'guix-daemon' behavior on a multi-user system.") + (value + (let ((os (marionette-operating-system + (operating-system + (inherit (operating-system-with-gc-roots + %simple-os + (list (profile + (name "hello-build-dependencies") + (content %hello-dependencies-manifest))))) + (kernel-arguments '("console=ttyS0")) + (users (cons (user-account + (name "user") + (group "users")) + %base-user-accounts))) + #:imported-modules '((gnu services herd) + (guix combinators))))) + (run-guix-daemon-test os))))) From patchwork Fri Feb 28 10:04:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 39434 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 039E527BBE9; Fri, 28 Feb 2025 10:06:41 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 71B8027BBE2 for ; Fri, 28 Feb 2025 10:06:39 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tnxG1-0003Sc-7H; Fri, 28 Feb 2025 05:06:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnxFs-0003Mg-KV for guix-patches@gnu.org; Fri, 28 Feb 2025 05:06:05 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tnxFs-0000PD-9J for guix-patches@gnu.org; Fri, 28 Feb 2025 05:06:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=m1uEZM6XXlCQrDi9/s/CwLH4H2k+qPpdwRRRmjqqZ4s=; b=hJnHxxHDVONM3mNi2jwLYh4UbagpTgYDizxZV4xiNLJCEav/x9V5jzkoaOJLiSEZMEzdlMbMxaSZCXliQZ7c8hWqHe5IM8tV4wqEzd10oTYZwL0AZXymO7YIZn68vMlB4pQDw6P2YUswtIffYr34e6RTyx726tnIM89jgyDsOTom3We7ZbJ7xCFB+slsdNaHqsED9KrD9g32hIHchCI5CPfU/n0RUV6aQDiBSSyrGIfep/52eZGo9c+BlhqVfTVxh1XeheTpOFLS+87XSEWdgIZyTxq4ndk4ya6nD9uikMNuM0ZXHNEeG1ZBZiA9OKRLJd4jCEfhg2vIwMl8tG7g4A==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tnxFs-0001Pf-5Q for guix-patches@gnu.org; Fri, 28 Feb 2025 05:06:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#76636] [PATCH 4/5] tests: Factorize =?utf-8?b?4oCYJWhlbGxvLWRl?= =?utf-8?b?cGVuZGVuY2llcy1tYW5pZmVzdOKAmS4=?= Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 28 Feb 2025 10:06:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 76636 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 76636@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 76636-submit@debbugs.gnu.org id=B76636.17407371325254 (code B ref 76636); Fri, 28 Feb 2025 10:06:04 +0000 Received: (at 76636) by debbugs.gnu.org; 28 Feb 2025 10:05:32 +0000 Received: from localhost ([127.0.0.1]:45369 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tnxFL-0001Mg-Dz for submit@debbugs.gnu.org; Fri, 28 Feb 2025 05:05:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48072) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tnxFB-0001Ka-9K for 76636@debbugs.gnu.org; Fri, 28 Feb 2025 05:05:25 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnxF5-0000KY-VU; Fri, 28 Feb 2025 05:05:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=m1uEZM6XXlCQrDi9/s/CwLH4H2k+qPpdwRRRmjqqZ4s=; b=jl2Vj4ka5Tj6g7SN3l4g WHw4u+umZ0+FHZJae2JbdOhFW5Hb4lI+wQykPF9tQ3uMrAIf1bbinVIMjtg70Xdj06PG2iad0YwWm hUTK+u9YNuxSfPoWGgLUv0ROKEqj/7CSYNlleGkcF1t63GmTRRhSoi5leczvzt93ZTWy2rFlZfCph gkpevlJ+Lm8Pi98gQODi0iczFg42o1bbvsMzlatxmYnYDFwZGju6L+teoxZNsWNpik+Gx713R7QjC P3hSJE/xBKbOZzWplyVvnbYLMah4KbYvoYwUUuUrXSole4Fcwghm1+/oWnJxo+vXI04908GHbccKQ mNZeUfaI37hrBQ==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Fri, 28 Feb 2025 11:04:31 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/tests/base.scm (%hello-dependencies-manifest): Export. * gnu/tests/foreign.scm (%installation-tarball-manifest): Use it. Change-Id: Id92232f479ab5d1f0c48036b0546e3745aa63e52 --- gnu/tests/base.scm | 4 +++- gnu/tests/foreign.scm | 36 +++--------------------------------- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm index 38bd1e687fc..f2122d7d0a5 100644 --- a/gnu/tests/base.scm +++ b/gnu/tests/base.scm @@ -60,6 +60,8 @@ (define-module (gnu tests base) %test-root-unmount %test-cleanup %test-activation + + %hello-dependencies-manifest %test-guix-daemon)) (define %simple-os @@ -998,7 +1000,7 @@ (define (manifest-entry-without-grafts entry) (item (with-parameters ((%graft? #f)) (manifest-entry-item entry))))) -(define %hello-dependencies-manifest ;TODO: Share with (gnu tests foreign). +(define %hello-dependencies-manifest ;; Build dependencies of 'hello' needed to test 'guix build hello'. (concatenate-manifests (list (map-manifest-entries diff --git a/gnu/tests/foreign.scm b/gnu/tests/foreign.scm index a08622424a7..9aba803c4d8 100644 --- a/gnu/tests/foreign.scm +++ b/gnu/tests/foreign.scm @@ -26,6 +26,8 @@ (define-module (gnu tests foreign) #:autoload (guix store) (%store-prefix %store-monad %graft?) #:use-module (gnu compression) #:use-module (gnu tests) + #:use-module ((gnu tests base) + #:select (%hello-dependencies-manifest)) #:use-module (gnu packages base) #:use-module (gnu packages bootstrap) #:use-module (gnu packages guile) @@ -140,39 +142,7 @@ (define %installation-tarball-manifest ;; Manifest of the Guix installation tarball. (concatenate-manifests (list (packages->manifest (list guix)) - - ;; Include the dependencies of 'hello' in addition to 'guix' so that - ;; we can test 'guix build hello'. - (map-manifest-entries - manifest-entry-without-grafts - (package->development-manifest hello)) - - ;; Add the source of 'hello'. - (manifest - (list (manifest-entry - (name "hello-source") - (version (package-version hello)) - (item (let ((file (origin-actual-file-name - (package-source hello)))) - (computed-file - "hello-source" - #~(begin - ;; Put the tarball in a subdirectory since - ;; profile union crashes otherwise. - (mkdir #$output) - (mkdir (in-vicinity #$output "src")) - (symlink #$(package-source hello) - (in-vicinity #$output - (string-append "src/" - #$file)))))))))) - - ;; Include 'guile-final', which is needed when building derivations - ;; such as that of 'hello' but missing from the development manifest. - ;; Add '%bootstrap-guile', used by 'guix install --bootstrap'. - (map-manifest-entries - manifest-entry-without-grafts - (packages->manifest (list (canonical-package guile-3.0) - %bootstrap-guile)))))) + %hello-dependencies-manifest))) (define %guix-install-script ;; The 'guix-install.sh' script. From patchwork Fri Feb 28 10:04:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 39435 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B4F5527BBEA; Fri, 28 Feb 2025 10:07:31 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 79D4027BBE2 for ; Fri, 28 Feb 2025 10:07:30 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tnxGv-0004sR-5h; Fri, 28 Feb 2025 05:07:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnxGp-0004mn-LL for guix-patches@gnu.org; Fri, 28 Feb 2025 05:07:03 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tnxGo-0000Xx-JL for guix-patches@gnu.org; Fri, 28 Feb 2025 05:07:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=lwuQYiTpeZi7OItVNgMQD3X3hOHjZylSlYKGfYSLZt8=; b=pAlvVHqM3zFXrqLw6R82poS+nWAJjOtCllYE7WrEbHqU7rE4DSF9J+G7QWvVMlHfQ9MAdn4d9QIK9Gvg7oN2Imy4uhrps1A001hOpwB2QJWQf7TI1BabIyQmFVgxUrMyLNHC+YhaGZFswnTobcQs4aov7p2hHvIbYnInNevcLN91MmAwL1Bjoajd2/1SLwSZfmIih+24zDO10xiEPCrYd7yoV6ArZCcuWKWi/t0OuBOQNYefmJXo7hY5yDSlRtWmVdi2rkAqmCS48XODTj7fos93PNWwJuWml0YEHA4m+9qjW/YSOgxydk/kAVJgJ++oCu9FpzzrdnTiW80Nx+ANFQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tnxGo-0001UI-Bx for guix-patches@gnu.org; Fri, 28 Feb 2025 05:07:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#76636] [PATCH 5/5] tests: Factorize =?utf-8?b?4oCYZ3VpeC1kYWVt?= =?utf-8?b?b27igJk=?= test cases. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 28 Feb 2025 10:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 76636 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 76636@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 76636-submit@debbugs.gnu.org id=B76636.17407371765510 (code B ref 76636); Fri, 28 Feb 2025 10:07:02 +0000 Received: (at 76636) by debbugs.gnu.org; 28 Feb 2025 10:06:16 +0000 Received: from localhost ([127.0.0.1]:45379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tnxG3-0001Qm-PH for submit@debbugs.gnu.org; Fri, 28 Feb 2025 05:06:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47084) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tnxFJ-0001Lj-Ie for 76636@debbugs.gnu.org; Fri, 28 Feb 2025 05:05:30 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnxFE-0000LX-3S; Fri, 28 Feb 2025 05:05:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=lwuQYiTpeZi7OItVNgMQD3X3hOHjZylSlYKGfYSLZt8=; b=qUwJQUTOnRFAU9oWNizh JQyY/ZUgq2MjciplcN8jp4N0jKglMro1h2Uj/yQqZh9as0qajvwJNU8AeL1gRjVfLJ3pZ9994mt0n 5pByP2T8XD0JQVRR9XlLt2dNkL4KmLMpQ8uiJdSRfpsfiQIw1FeP9IJExtgH/onMjiOtT5UHtlEQ1 kpcqZ0+fQmAKgD52rrQLO2OkdvsOIHkACwOJRFBjt8P38h3VXhH1hnJdoDSshhREYxvGnIZLNZo/I vDVygTS4gGjNoTxWmwXUULYmSqJcf6SQX+BjPpX3H9xa4g3+yIcdTtzCpq51Wzj/j1Wnf13//OCzp MxaKL3bxg24e7g==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Fri, 28 Feb 2025 11:04:32 +0100 Message-ID: <15770d6384520d287f96d53047c799bfe51b6624.1740736327.git.ludo@gnu.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/tests/base.scm (guix-daemon-test-cases): New procedure, with code moved from… (run-guix-daemon-test): … here. Use it. * gnu/tests/foreign.scm (run-foreign-install-test): Likewise. Change-Id: I6f2d03d30d7b7648b6eb7e77e36c3da54f80d79c --- gnu/tests/base.scm | 160 ++++++++++++++++++++++-------------------- gnu/tests/foreign.scm | 73 +------------------ 2 files changed, 87 insertions(+), 146 deletions(-) diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm index f2122d7d0a5..a7f8a5bf7c6 100644 --- a/gnu/tests/base.scm +++ b/gnu/tests/base.scm @@ -62,6 +62,7 @@ (define-module (gnu tests base) %test-activation %hello-dependencies-manifest + guix-daemon-test-cases %test-guix-daemon)) (define %simple-os @@ -1034,6 +1035,88 @@ (define %hello-dependencies-manifest (packages->manifest (list (canonical-package guile-3.0) %bootstrap-guile)))))) +(define (guix-daemon-test-cases marionette) + "Return a gexp with SRFI-64 test cases testing guix-daemon. Those test are +evaluated in MARIONETTE, a gexp denoting a marionette (system under test). +Assume that an unprivileged account for 'user' exists on the system under +test." + #~(begin + (test-equal "guix describe" + 0 + (marionette-eval '(system* "guix" "describe") + #$marionette)) + + (test-equal "hello not already built" + #f + ;; Check that the next test will really build 'hello'. + (marionette-eval '(file-exists? + #$(with-parameters ((%graft? #f)) + hello)) + #$marionette)) + + (test-equal "guix build hello" + 0 + ;; Check that guix-daemon is up and running and that the build + ;; environment is properly set up (build users, etc.). + (marionette-eval '(system* "guix" "build" "hello" "--no-grafts") + #$marionette)) + + (test-assert "hello indeed built" + (marionette-eval '(file-exists? + #$(with-parameters ((%graft? #f)) + hello)) + #$marionette)) + + (test-equal "guix install hello" + 0 + ;; Check that ~/.guix-profile & co. are properly created. + (marionette-eval '(let ((pw (getpwuid (getuid)))) + (setenv "USER" (passwd:name pw)) + (setenv "HOME" (pk 'home (passwd:dir pw))) + (system* "guix" "install" "hello" + "--no-grafts" "--bootstrap")) + #$marionette)) + + (test-equal "user profile created" + 0 + (marionette-eval '(system "ls -lad ~/.guix-profile") + #$marionette)) + + (test-equal "hello" + 0 + (marionette-eval '(system "~/.guix-profile/bin/hello") + #$marionette)) + + (test-equal "guix install hello, unprivileged user" + 0 + ;; Check that 'guix' is in $PATH for new users and that + ;; ~user/.guix-profile also gets created, assuming that 'user' exists + ;; as an unprivileged user account. + (marionette-eval '(system "su - user -c \ +'guix install hello --no-grafts --bootstrap'") + #$marionette)) + + (test-equal "user hello" + 0 + (marionette-eval '(system "~user/.guix-profile/bin/hello") + #$marionette)) + + (test-equal "unprivileged user profile created" + 0 + (marionette-eval '(system "ls -lad ~user/.guix-profile") + #$marionette)) + + (test-equal "store is read-only" + EROFS + (marionette-eval '(catch 'system-error + (lambda () + (mkdir (in-vicinity #$(%store-prefix) + "whatever")) + 0) + (lambda args + (system-error-errno args))) + #$marionette)))) + (define (run-guix-daemon-test os) (define test-image (image (operating-system os) @@ -1070,82 +1153,7 @@ (define (run-guix-daemon-test os) (test-runner-current (system-test-runner #$output)) (test-begin "guix-daemon") - (test-equal "guix describe" - 0 - (marionette-eval '(system* "guix" "describe") - marionette)) - - ;; XXX: What follows is largely copied form (gnu tests foreign). - - (test-equal "hello not already built" - #f - ;; Check that the next test will really build 'hello'. - (marionette-eval '(file-exists? - #$(with-parameters ((%graft? #f)) - hello)) - marionette)) - - (test-equal "guix build hello" - 0 - ;; Check that guix-daemon is up and running and that the build - ;; environment is properly set up (build users, etc.). - (marionette-eval '(system* "guix" "build" "hello" "--no-grafts") - marionette)) - - (test-assert "hello indeed built" - (marionette-eval '(file-exists? - #$(with-parameters ((%graft? #f)) - hello)) - marionette)) - - (test-equal "guix install hello" - 0 - ;; Check that ~/.guix-profile & co. are properly created. - (marionette-eval '(let ((pw (getpwuid (getuid)))) - (setenv "USER" (passwd:name pw)) - (setenv "HOME" (pk 'home (passwd:dir pw))) - (system* "guix" "install" "hello" - "--no-grafts" "--bootstrap")) - marionette)) - - (test-equal "user profile created" - 0 - (marionette-eval '(system "ls -lad ~/.guix-profile") - marionette)) - - (test-equal "hello" - 0 - (marionette-eval '(system "~/.guix-profile/bin/hello") - marionette)) - - (test-equal "guix install hello, unprivileged user" - 0 - ;; Check that 'guix' is in $PATH for new users and that - ;; ~user/.guix-profile also gets created. - (marionette-eval '(system "su - user -c \ -'guix install hello --no-grafts --bootstrap'") - marionette)) - - (test-equal "user hello" - 0 - (marionette-eval '(system "~user/.guix-profile/bin/hello") - marionette)) - - (test-equal "unprivileged user profile created" - 0 - (marionette-eval '(system "ls -lad ~user/.guix-profile") - marionette)) - - (test-equal "store is read-only" - EROFS - (marionette-eval '(catch 'system-error - (lambda () - (mkdir (in-vicinity #$(%store-prefix) - "whatever")) - 0) - (lambda args - (system-error-errno args))) - marionette)) + #$(guix-daemon-test-cases #~marionette) (test-end)))) diff --git a/gnu/tests/foreign.scm b/gnu/tests/foreign.scm index 9aba803c4d8..79436bf5f24 100644 --- a/gnu/tests/foreign.scm +++ b/gnu/tests/foreign.scm @@ -27,7 +27,8 @@ (define-module (gnu tests foreign) #:use-module (gnu compression) #:use-module (gnu tests) #:use-module ((gnu tests base) - #:select (%hello-dependencies-manifest)) + #:select (%hello-dependencies-manifest + guix-daemon-test-cases)) #:use-module (gnu packages base) #:use-module (gnu packages bootstrap) #:use-module (gnu packages guile) @@ -237,81 +238,13 @@ (define (run-foreign-install-test image name) (%store-prefix)))))) marionette)) - (test-equal "hello not already built" - #f - ;; Check that the next test will really build 'hello'. - (marionette-eval '(file-exists? - #$(with-parameters ((%graft? #f)) - hello)) - marionette)) - - (test-equal "guix build hello" - 0 - ;; Check that guix-daemon is up and running and that the build - ;; environment is properly set up (build users, etc.). - (marionette-eval '(system* "guix" "build" "hello" "--no-grafts") - marionette)) - - (test-assert "hello indeed built" - (marionette-eval '(file-exists? - #$(with-parameters ((%graft? #f)) - hello)) - marionette)) - - (test-equal "guix install hello" - 0 - ;; Check that ~/.guix-profile & co. are properly created. - (marionette-eval '(let ((pw (getpwuid (getuid)))) - (setenv "USER" (passwd:name pw)) - (setenv "HOME" (pk 'home (passwd:dir pw))) - (system* "guix" "install" "hello" - "--no-grafts" "--bootstrap")) - marionette)) - - (test-equal "user profile created" - 0 - (marionette-eval '(system "ls -lad ~/.guix-profile") - marionette)) - - (test-equal "hello" - 0 - (marionette-eval '(system "~/.guix-profile/bin/hello") - marionette)) - (test-equal "create user account" 0 (marionette-eval '(system* "useradd" "-d" "/home/user" "-m" "user") marionette)) - (test-equal "guix install hello, unprivileged user" - 0 - ;; Check that 'guix' is in $PATH for new users and that - ;; ~user/.guix-profile also gets created. - (marionette-eval '(system "su - user -c \ -'guix install hello --no-grafts --bootstrap'") - marionette)) - - (test-equal "user hello" - 0 - (marionette-eval '(system "~user/.guix-profile/bin/hello") - marionette)) - - (test-equal "unprivileged user profile created" - 0 - (marionette-eval '(system "ls -lad ~user/.guix-profile") - marionette)) - - (test-equal "store is read-only" - EROFS - (marionette-eval '(catch 'system-error - (lambda () - (mkdir (in-vicinity #$(%store-prefix) - "whatever")) - 0) - (lambda args - (system-error-errno args))) - marionette)) + #$(guix-daemon-test-cases #~marionette) (test-assert "screenshot after" (marionette-control (string-append "screendump " #$output