Commit a728135a authored by Robert Pluim's avatar Robert Pluim

Skip tests that require Internet when there's no Internet

Bug#46641

The network-stream-tests actually work fine when the local machine has
no IP at all, but cause a crash in the GnuTLS library when there is an
IP configured but the interface is down.

* test/lisp/net/network-stream-tests.el (internet-is-working): New
defvar, checks if we can resolve "google.com".
(connect-to-tls-ipv4-nowait, connect-to-tls-ipv6-nowait)
(open-network-stream-tls-nowait, open-gnutls-stream-new-api-nowait)
(open-gnutls-stream-old-api-nowait): Use it to check for working
Internet access.

* test/src/process-tests.el (internet-is-working): New defvar, checks
if we can resolve "google.com".
(lookup-family-specification, lookup-unicode-domains)
(unibyte-domain-name, lookup-google, non-existent-lookup-failure): Use
it to check for working Internet access.
parent 934dcc21
Pipeline #9452 failed with stages
in 8 minutes and 37 seconds
......@@ -32,6 +32,13 @@
;; it pulls in nsm, which then makes the :nowait t' tests fail unless
;; we disable the nsm, which we do by binding 'network-security-level'
;; Check if the Internet seems to be working. Mainly to pacify
;; Debian's CI system.
(defvar internet-is-working
(progn
(require 'dns)
(dns-query "google.com")))
(ert-deftest make-local-unix-server ()
(skip-unless (featurep 'make-network-process '(:family local)))
(let* ((file (make-temp-name "/tmp/server-test"))
......@@ -291,6 +298,7 @@
(ert-deftest connect-to-tls-ipv4-nowait ()
(skip-unless (executable-find "gnutls-serv"))
(skip-unless (gnutls-available-p))
(skip-unless internet-is-working)
(let ((server (make-tls-server 44331))
(times 0)
(network-security-level 'low)
......@@ -333,6 +341,7 @@
(ert-deftest connect-to-tls-ipv6-nowait ()
(skip-unless (executable-find "gnutls-serv"))
(skip-unless (gnutls-available-p))
(skip-unless internet-is-working)
(skip-unless (not (eq system-type 'windows-nt)))
(skip-unless (featurep 'make-network-process '(:family ipv6)))
(let ((server (make-tls-server 44333))
......@@ -417,6 +426,7 @@
(ert-deftest open-network-stream-tls-nowait ()
(skip-unless (executable-find "gnutls-serv"))
(skip-unless (gnutls-available-p))
(skip-unless internet-is-working)
(let ((server (make-tls-server 44335))
(times 0)
(network-security-level 'low)
......@@ -645,6 +655,7 @@
(ert-deftest open-gnutls-stream-new-api-nowait ()
(skip-unless (executable-find "gnutls-serv"))
(skip-unless (gnutls-available-p))
(skip-unless internet-is-working)
(let ((server (make-tls-server 44668))
(times 0)
(network-security-level 'low)
......@@ -683,6 +694,7 @@
(ert-deftest open-gnutls-stream-old-api-nowait ()
(skip-unless (executable-find "gnutls-serv"))
(skip-unless (gnutls-available-p))
(skip-unless internet-is-working)
(let ((server (make-tls-server 44669))
(times 0)
(network-security-level 'low)
......
......@@ -348,8 +348,7 @@ See Bug#30460."
invocation-directory))
:stop t))))
;; All the following tests require working DNS, which appears not to
;; be the case for hydra.nixos.org, so disable them there for now.
;; The following tests require working DNS
;; This will need updating when IANA assign more IPv6 global ranges.
(defun ipv6-is-available ()
......@@ -360,9 +359,16 @@ See Bug#30460."
(= (logand (aref elt 0) #xe000) #x2000)))
(network-interface-list))))
;; Check if the Internet seems to be working. Mainly to pacify
;; Debian's CI system.
(defvar internet-is-working
(progn
(require 'dns)
(dns-query "google.com")))
(ert-deftest lookup-family-specification ()
"`network-lookup-address-info' should only accept valid family symbols."
(skip-unless (not (getenv "EMACS_HYDRA_CI")))
(skip-unless internet-is-working)
(with-timeout (60 (ert-fail "Test timed out"))
(should-error (network-lookup-address-info "localhost" 'both))
(should (network-lookup-address-info "localhost" 'ipv4))
......@@ -371,20 +377,20 @@ See Bug#30460."
(ert-deftest lookup-unicode-domains ()
"Unicode domains should fail."
(skip-unless (not (getenv "EMACS_HYDRA_CI")))
(skip-unless internet-is-working)
(with-timeout (60 (ert-fail "Test timed out"))
(should-error (network-lookup-address-info "faß.de"))
(should (network-lookup-address-info (puny-encode-domain "faß.de")))))
(ert-deftest unibyte-domain-name ()
"Unibyte domain names should work."
(skip-unless (not (getenv "EMACS_HYDRA_CI")))
(skip-unless internet-is-working)
(with-timeout (60 (ert-fail "Test timed out"))
(should (network-lookup-address-info (string-to-unibyte "google.com")))))
(ert-deftest lookup-google ()
"Check that we can look up google IP addresses."
(skip-unless (not (getenv "EMACS_HYDRA_CI")))
(skip-unless internet-is-working)
(with-timeout (60 (ert-fail "Test timed out"))
(let ((addresses-both (network-lookup-address-info "google.com"))
(addresses-v4 (network-lookup-address-info "google.com" 'ipv4)))
......@@ -396,10 +402,12 @@ See Bug#30460."
(ert-deftest non-existent-lookup-failure ()
"Check that looking up non-existent domain returns nil."
(skip-unless (not (getenv "EMACS_HYDRA_CI")))
(skip-unless internet-is-working)
(with-timeout (60 (ert-fail "Test timed out"))
(should (eq nil (network-lookup-address-info "emacs.invalid")))))
;; End of tests requiring DNS
(defmacro process-tests--ignore-EMFILE (&rest body)
"Evaluate BODY, ignoring EMFILE errors."
(declare (indent 0) (debug t))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment