]> git.eshelyaron.com Git - emacs.git/commitdiff
Make a network-stream test more robust
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 4 Aug 2020 15:25:36 +0000 (17:25 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 4 Aug 2020 15:25:36 +0000 (17:25 +0200)
* test/lisp/net/network-stream-tests.el
(network-test--resolve-system-name): New function.
(echo-server-with-dns): Skip test if (system-name) doesn't look
like it's going to resolve (bug#42535).

test/lisp/net/network-stream-tests.el

index 7a982548ae1d03e9c4058e6aaebfe8e84b487f28..f44682e1edb44a611be68060d28fa4f30b74eba2 100644 (file)
      (t
       ))))
 
+(defun network-test--resolve-system-name ()
+  (cl-loop for address in (network-lookup-address-info (system-name))
+           when (or (and (= (length address) 5)
+                         ;; IPv4 localhost addresses start with 127.
+                         (= (elt address 0) 127))
+                    (and (= (length address) 9)
+                         ;; IPv6 localhost addresses start with 0.
+                         (= (elt address 0) 0)))
+           return t))
+
 (ert-deftest echo-server-with-dns ()
+  (unless (network-test--resolve-system-name)
+    (ert-skip "Can't test resolver for (system-name)"))
+
   (let* ((server (make-server (system-name)))
          (port (aref (process-contact server :local) 4))
          (proc (make-network-process :name "foo"