unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Vagrant Cascadian <vagrant@debian.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 44491@debbugs.gnu.org
Subject: bug#44491: Support GUIX_DISABLE_NETWORK_TESTS environment variable
Date: Tue, 10 Nov 2020 19:39:25 -0800	[thread overview]
Message-ID: <87h7pwtvde.fsf@yucca> (raw)
In-Reply-To: <87wnysnbs6.fsf@gnu.org>


[-- Attachment #1.1: Type: text/plain, Size: 1331 bytes --]

On 2020-11-10, Ludovic Courtès wrote:
> Vagrant Cascadian <vagrant@debian.org> skribis:
>> On 2020-11-08, Ludovic Courtès wrote:
>>> Vagrant Cascadian <vagrant@debian.org> skribis:
>>>
>>>> If this could be considered for the upcoming 1.2 release, that would be
>>>> appreciated, though I can also carry the patches in Debian...
>>>
>>> Yay!  It should be doable, let’s see.
>>
>> It seems like a simpler workaround is to pass RES_OPTIONS=attempts:0,
>> which should disable name resolution, and thus the network checks will
>> fail.
>>
>> With the RES_OPTIONS workaround, the changes to guix/tests.scm
>> network-reachable are no longer needed ... i think. :)
>
> Oooh nice, the wonders of glibc!
>
>> Might still be worth refactoring some of *.sh tests to use common
>> functions, since the code is basically copied and pasted in several
>> different places.
>
> Yes, that’s still a good idea.  Would you like to adjust your patch
> accordingly?

Thanks for the review!

Updated patch attached, with changes:

* Copyright header added to common.sh.
* New function skip_if_network_unreachable in common.sh
* Dropped GUIX_DISABLE_NETWORK_TESTS in favor of using
  RES_OPTIONS=attempts:0.
* Updated tests to use skip_if_network_unreachable or network_reachable.


live well,
  vagrant


[-- Attachment #1.2: 0001-tests-Add-common-functions-for-to-check-for-network-.patch --]
[-- Type: text/x-diff, Size: 4731 bytes --]

From 3fd93fec957491450639c647e05a5f72f1e787fd Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <vagrant@debian.org>
Date: Tue, 10 Nov 2020 19:26:04 -0800
Subject: [PATCH] tests: Add common functions for to check for network
 reachability.

* tests/common.sh: New file.
* tests/guix-build-branch.sh, tests/guix-pack.sh,
  tests/guix-package-net.sh: Use skip_if_network_unreachable function
  from common.sh.
* tests/guix-environment.sh: Use network_reachable function from
  common.sh.
---
 Makefile.am                |  1 +
 tests/common.sh            | 30 ++++++++++++++++++++++++++++++
 tests/guix-build-branch.sh |  8 ++------
 tests/guix-environment.sh  |  5 ++---
 tests/guix-pack.sh         |  5 ++---
 tests/guix-package-net.sh  |  9 ++-------
 6 files changed, 39 insertions(+), 19 deletions(-)
 create mode 100644 tests/common.sh

diff --git a/Makefile.am b/Makefile.am
index e7053ee4f4..7dbe41201c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -599,6 +599,7 @@ EXTRA_DIST +=						\
   tests/test.drv					\
   tests/signing-key.pub					\
   tests/signing-key.sec					\
+  tests/common.sh					\
   tests/cve-sample.json					\
   tests/civodul.key					\
   tests/rsa.key						\
diff --git a/tests/common.sh b/tests/common.sh
new file mode 100644
index 0000000000..f9dd3c2c59
--- /dev/null
+++ b/tests/common.sh
@@ -0,0 +1,30 @@
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2020 Vagrant Cascadian <vagrant@debian.org>
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+network_reachable() {
+    if ! guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null; then
+        return 0
+    fi
+}
+
+skip_if_network_unreachable() {
+	if ! network_reachable ; then
+		exit 77
+	fi
+}
diff --git a/tests/guix-build-branch.sh b/tests/guix-build-branch.sh
index 79aa06a58f..89f7ea4a08 100644
--- a/tests/guix-build-branch.sh
+++ b/tests/guix-build-branch.sh
@@ -24,12 +24,8 @@ guix build --version
 
 # 'guix build --with-branch' requires access to the network to clone the
 # Git repository below.
-
-if ! guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null
-then
-    # Skipping.
-    exit 77
-fi
+. $(dirname $0)/common.sh
+skip_if_network_unreachable
 
 orig_drv="`guix build guile-gcrypt -d`"
 latest_drv="`guix build guile-gcrypt --with-branch=guile-gcrypt=master -d`"
diff --git a/tests/guix-environment.sh b/tests/guix-environment.sh
index f8be48f0c0..ce01ac04be 100644
--- a/tests/guix-environment.sh
+++ b/tests/guix-environment.sh
@@ -174,9 +174,8 @@ case "$transformed_drv" in
     *)           false;;
 esac
 
-
-if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null
-then
+. $(dirname $0)/common.sh
+if network_reachable ; then
     # Compute the build environment for the initial GNU Make.
     guix environment --bootstrap --no-substitutes --search-paths --pure \
          -e '(@ (guix tests) gnu-make-for-tests)' > "$tmpdir/a"
diff --git a/tests/guix-pack.sh b/tests/guix-pack.sh
index 0339221ac2..822a67b157 100644
--- a/tests/guix-pack.sh
+++ b/tests/guix-pack.sh
@@ -23,9 +23,8 @@
 
 # A network connection is required to build %bootstrap-coreutils&co,
 # which is required to run these tests with the --bootstrap option.
-if ! guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null; then
-    exit 77
-fi
+. $(dirname $0)/common.sh
+skip_if_network_unreachable
 
 guix pack --version
 
diff --git a/tests/guix-package-net.sh b/tests/guix-package-net.sh
index 6d21c6cff6..f682d09245 100644
--- a/tests/guix-package-net.sh
+++ b/tests/guix-package-net.sh
@@ -38,13 +38,8 @@ shebang_too_long ()
 	 -ge 128
 }
 
-if ! guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null \
-	|| shebang_too_long
-then
-    # Skipping.
-    exit 77
-fi
-
+. $(dirname $0)/common.sh
+skip_if_network_unreachable
 
 profile="t-profile-$$"
 profile_alt="t-profile-alt-$$"
-- 
2.20.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

  reply	other threads:[~2020-11-11  3:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-06 21:30 bug#44491: Support GUIX_DISABLE_NETWORK_TESTS environment variable Vagrant Cascadian
2020-11-08 17:46 ` Ludovic Courtès
2020-11-10 18:13   ` Vagrant Cascadian
2020-11-10 21:26     ` Ludovic Courtès
2020-11-11  3:39       ` Vagrant Cascadian [this message]
2020-11-11  6:06         ` Vagrant Cascadian
2020-12-03 17:09           ` Ludovic Courtès
2020-12-03 19:13             ` Vagrant Cascadian
2020-12-07  7:55               ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h7pwtvde.fsf@yucca \
    --to=vagrant@debian.org \
    --cc=44491@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).