emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master a728135 2/2: Skip tests that require Internet when there's no Int


From: Robert Pluim
Subject: master a728135 2/2: Skip tests that require Internet when there's no Internet
Date: Mon, 22 Feb 2021 09:49:13 -0500 (EST)

branch: master
commit a728135a2b551917588425d9758c6cc932cb591b
Author: Robert Pluim <rpluim@gmail.com>
Commit: Robert Pluim <rpluim@gmail.com>

    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.
---
 test/lisp/net/network-stream-tests.el | 12 ++++++++++++
 test/src/process-tests.el             | 22 +++++++++++++++-------
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/test/lisp/net/network-stream-tests.el 
b/test/lisp/net/network-stream-tests.el
index e0a06a2..0fb24d2 100644
--- a/test/lisp/net/network-stream-tests.el
+++ b/test/lisp/net/network-stream-tests.el
@@ -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)
diff --git a/test/src/process-tests.el b/test/src/process-tests.el
index e62bcb3..17aef30 100644
--- a/test/src/process-tests.el
+++ b/test/src/process-tests.el
@@ -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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]