From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id +Gv9Fj8BWmMCYwEAbAwnHQ (envelope-from ) for ; Thu, 27 Oct 2022 05:55:43 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 8P3XFj8BWmMEAQEA9RJhRA (envelope-from ) for ; Thu, 27 Oct 2022 05:55:43 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1923920050 for ; Thu, 27 Oct 2022 05:55:43 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ontwE-0002q3-Me; Wed, 26 Oct 2022 23:52:15 -0400 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 1ontw4-0002iX-Q8 for guix-patches@gnu.org; Wed, 26 Oct 2022 23:52:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ontw2-0001Qa-CO for guix-patches@gnu.org; Wed, 26 Oct 2022 23:52:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ontw2-00029a-4r for guix-patches@gnu.org; Wed, 26 Oct 2022 23:52:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 2/5] tests: Add a tests/utils.sh support file. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 27 Oct 2022 03:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58812@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16668426878187 (code B ref 58812); Thu, 27 Oct 2022 03:52:02 +0000 Received: (at 58812) by debbugs.gnu.org; 27 Oct 2022 03:51:27 +0000 Received: from localhost ([127.0.0.1]:55702 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontvS-00027z-Cz for submit@debbugs.gnu.org; Wed, 26 Oct 2022 23:51:26 -0400 Received: from mail-qt1-f174.google.com ([209.85.160.174]:41863) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ontvP-00027W-7N for 58812@debbugs.gnu.org; Wed, 26 Oct 2022 23:51:24 -0400 Received: by mail-qt1-f174.google.com with SMTP id c23so314049qtw.8 for <58812@debbugs.gnu.org>; Wed, 26 Oct 2022 20:51:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mL2gSaxFm+dcFDnNEZn/yihf6iSJmqDld5LPoFpl9Yg=; b=WL9Mx2rmp9NXC9q+Ax1iJ1Y1hu6mr0KAB/qLt6JXeuFkA1FSxWIHbxbnsBk0lAdWb5 94CAvvTmRhbpcn0hBTO39bZQvtzTSmdRGtXlDsxFzRnK/XjXOTAOCufRjpfKzR70ZkXa 8s70gnRcY4VKbENfdXWrm1lAppanAtWpHcHU1IgdgrSoi7IpxWLfHAzS1Q1E7yhCoTvT RP1+UErVk7ckb2sAhhbA4qaxfhigQjjAuKFSM5q3t7+eRz44b1bZdZfPXX5V3M8otnwe RlgU18z3onmZ1cHDN3XgJ6nMeAdnNxsMRWLOj8dwCi1DVnTdtdt0+JR3R5ueoJ5Ytu/s 0wbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mL2gSaxFm+dcFDnNEZn/yihf6iSJmqDld5LPoFpl9Yg=; b=QPODv6ivEqK0+3ejayvgNi6RX/MUjDSqCfJXmdI3iz/nR4m2BkVZwgyrFV+wqX8cuO xPOBkvnSwFAsc/XdpFGZ9c15b9bP7hU8EwTPemGBK2tjq6vmyuIZdVPdlD9q9DJ0z423 Dq5UcTvPVgthgJt0SZIe0qQ/5W+YpslZEvhidt7I8nB7AQcHKrh8Yh4pp+0BKZSIzbi6 kTcuYgIwXV5LbdazWlh/PS2Z+4TNk7h5mR74hPGVtBRyjhYF4plG8q9iZphPWSurRjoX CEetTyKRRuYBVCcXRXnzdyx8jO+LDBTnb+f/F/Sst4Np2CRm9Fwi393HY8RWvglP1fEi J90Q== X-Gm-Message-State: ACrzQf0vpuyDWSZEiYMwSCJlmwiNXWs+Qlhrqo7lgQIR8TdnNlHhlz2p hFbF3nk5JRdyyON+8a5vuLE+vii2G/Q= X-Google-Smtp-Source: AMsMyM7S/XyodqgNQYfPLhlOt/12Fo/cubSgycghtzPz5mC4FH+7etMStHXilblomOzT8VAo79yWlw== X-Received: by 2002:ac8:7e84:0:b0:39d:fd1:5a1d with SMTP id w4-20020ac87e84000000b0039d0fd15a1dmr30753751qtj.169.1666842676561; Wed, 26 Oct 2022 20:51:16 -0700 (PDT) Received: from localhost.localdomain (dsl-152-21.b2b2c.ca. [66.158.152.21]) by smtp.gmail.com with ESMTPSA id x1-20020a05620a448100b006ec771d8f89sm255488qkp.112.2022.10.26.20.51.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 20:51:16 -0700 (PDT) From: Maxim Cournoyer Date: Wed, 26 Oct 2022 23:50:57 -0400 Message-Id: <20221027035100.28852-2-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221027035100.28852-1-maxim.cournoyer@gmail.com> References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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: , Sender: "Guix-patches" Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1666842943; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=mL2gSaxFm+dcFDnNEZn/yihf6iSJmqDld5LPoFpl9Yg=; b=TJKY75quZJnj/7XER1McHGw1bKcXadDc2kLG7Ku5CoHLYLB7fonKebqZnWTdqVT8+n0F6z yC5G/VdERqTEohMjgm7fHK2JHHW2evX9FCfUZZAZVrltQ7RezA7s6vMVfLMNfyNnz9N6Io UDqP5sDXn0Ad2LRHd4LUz+Ur8c6yle9Med73HdFDzFfuhjlbztHvwCfQ2MSdwLrCYz8vl0 OJ+hOXU9Lbz2b4dVfxdoq+25G7Tlv5MF8yorboRASsGtqP4rEVKeasd77NDYICZrRsCpVf pzht3TrFhfJ70o8xXZJC6N7xd2kA+wQ7Fo+XUI+o4ruNiI7/h+Lil29hakLX6A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666842943; a=rsa-sha256; cv=none; b=YKwimuHK7tCUIbSc2uyjlC+K/78a+2CUhpRC0/EU/dXZQF5VNNHYNegoRCtey5ddN31tQW vA0ponrSut+hRTbh58PiqDqxEHNIAgSuTKTdKzEgDuG/lB+zrym5m1NAuQqMpE+3WYrOuA /qWG5z4mEKPJ6JHwOl3RGLdTUp1C9hqWPhRomhxOLmeSYX16VxGRizFBnKgpHwnJoIXeTM 5ek/qFs6rsVqSrNAT6i1nQVSWAgerCxVJZGUx7yzmuPq496/2SOwM6FR3ocQmvw6K8umdZ D+n+ggNvZtZssf4HnqSn/swrUgBH3rsDx/lMZtpEJL1knX/agnGWbAwkTbMccA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=WL9Mx2rm; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 6.78 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=WL9Mx2rm; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 1923920050 X-Spam-Score: 6.78 X-Migadu-Scanner: scn0.migadu.com X-TUID: k6XchyKRNWof The purpose of this file will be to accumulate support shell functions for the shell-authored tests. * tests/shell-utils.scm: New file. * tests/utils.sh: Likewise. * Makefile.am (EXTRA_DIST): Register them. --- Makefile.am | 3 +++ tests/shell-utils.scm | 29 +++++++++++++++++++++++++++++ tests/utils.sh | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 tests/shell-utils.scm create mode 100644 tests/utils.sh diff --git a/Makefile.am b/Makefile.am index 6cc7c0c4a0..14cbdcb011 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,6 +16,7 @@ # Copyright © 2019 Efraim Flashner # Copyright © 2021 Chris Marusich # Copyright © 2021 Andrew Tropin +# Copyright © 2021, 2022 Maxim Cournoyer # # This file is part of GNU Guix. # @@ -700,7 +701,9 @@ EXTRA_DIST += \ tests/keys/rsa.pub \ tests/keys/signing-key.pub \ tests/keys/signing-key.sec \ + tests/shell-utils.scm \ tests/test.drv \ + tests/utils.sh \ $(TESTS) if !BUILD_DAEMON_OFFLOAD diff --git a/tests/shell-utils.scm b/tests/shell-utils.scm new file mode 100644 index 0000000000..3ae9a414cd --- /dev/null +++ b/tests/shell-utils.scm @@ -0,0 +1,29 @@ +;; GNU Guix --- Functional package management for GNU +;; Copyright © 2022 Maxim Cournoyer +;; +;; 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 . +;; +;; Commentary: +;; +;; This file contains procedures that support the shell functions defined in +;; tests/utils.sh. +(use-modules (gnu build linux-container)) + +(define (container-support?) + (unless (and (user-namespace-supported?) + (unprivileged-user-namespace-supported?) + (setgroups-supported?)) + (exit 1))) diff --git a/tests/utils.sh b/tests/utils.sh new file mode 100644 index 0000000000..ba17f0de15 --- /dev/null +++ b/tests/utils.sh @@ -0,0 +1,33 @@ +# GNU Guix --- Functional package management for GNU +# Copyright © 2022 Maxim Cournoyer +# +# 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 . +# +# Commentary: +# +# This file provides utility shell functions that can be used in the shell +# test scripts. The file is intended to be sourced as a shell library. + +BASEDIR=$(dirname "$0") + +HAS_CONTAINER_SUPPORT= +has_container_support() { + if [ -z "$HAS_CONTAINER_SUPPORT" ]; then + guile -l "$BASEDIR/shell-utils.scm" -c '(container-support?)' + HAS_CONTAINER_SUPPORT=$? + fi + return "$HAS_CONTAINER_SUPPORT" +} -- 2.37.3