File: tests-Add-common-functions-for-to-check-for-network-.patch

package info (click to toggle)
guix 1.4.0-9
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 161,500 kB
  • sloc: lisp: 861,023; cpp: 10,741; javascript: 9,632; sh: 8,913; makefile: 951; ansic: 558; python: 129; sql: 33; sed: 16
file content (142 lines) | stat: -rw-r--r-- 4,687 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
From b2965a0c2d67f5c113584c92aecb68bd59da469f 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.
Bug: https://issues.guix.gnu.org/44491

* 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            | 31 +++++++++++++++++++++++++++++++
 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, 40 insertions(+), 19 deletions(-)
 create mode 100644 tests/common.sh

Index: guix/Makefile.am
===================================================================
--- guix.orig/Makefile.am
+++ guix/Makefile.am
@@ -702,6 +702,7 @@ EXTRA_DIST +=						\
   tests/keys/rsa.pub					\
   tests/keys/signing-key.pub				\
   tests/keys/signing-key.sec				\
+  tests/common.sh					\
   tests/test.drv					\
   $(TESTS)
 
Index: guix/tests/common.sh
===================================================================
--- /dev/null
+++ guix/tests/common.sh
@@ -0,0 +1,31 @@
+# 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
+    return 1
+}
+
+skip_if_network_unreachable() {
+	if ! network_reachable ; then
+		exit 77
+	fi
+}
Index: guix/tests/guix-build-branch.sh
===================================================================
--- guix.orig/tests/guix-build-branch.sh
+++ guix/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`"
Index: guix/tests/guix-environment.sh
===================================================================
--- guix.orig/tests/guix-environment.sh
+++ guix/tests/guix-environment.sh
@@ -187,9 +187,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"
Index: guix/tests/guix-pack.sh
===================================================================
--- guix.orig/tests/guix-pack.sh
+++ guix/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
 
Index: guix/tests/guix-package-net.sh
===================================================================
--- guix.orig/tests/guix-package-net.sh
+++ guix/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-$$"