GNU bug report logs - #36340
Test failures when networking is disabled

Previous Next

Package: guile;

Reported by: Cyprien Nicolas <cyprien <at> nicolas.tf>

Date: Sun, 23 Jun 2019 11:45:02 UTC

Severity: normal

To reply to this bug, email your comments to 36340 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#36340; Package guile. (Sun, 23 Jun 2019 11:45:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Cyprien Nicolas <cyprien <at> nicolas.tf>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sun, 23 Jun 2019 11:45:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Cyprien Nicolas <cyprien <at> nicolas.tf>
To: bug-guile <at> gnu.org
Subject: Test failures when networking is disabled
Date: Sun, 23 Jun 2019 13:44:26 +0200
Hello,

Guile's configure script offers an option to disable networking support,
but when disabled, some test won't pass.

-----8<-----8<-----8<-----8<-----8<-----
Running 00-repl-server.test
ERROR: 00-repl-server.test: repl-server: simple expression - arguments:
((unbound-variable #f "Unbound variable: ~S" (make-socket-address) #f))
ERROR: 00-repl-server.test: repl-server: HTTP inter-protocol attack -
arguments: ((unbound-variable #f "Unbound variable: ~S"
(make-socket-address) #f))
----->8----->8----->8----->8----->8-----

The error is obviously related to the configure option. I have a patch
for catching unbound-variable and throw unresolved instead, tested on
2.2 and 2.0 branches. Reference: https://bugs.gentoo.org/629004

That patch is enough for stable-2.0 but there is another failure in
suspendable-ports in 2.2.5, as the suspendable-ports ice-9 module
overrides accept and connect functions, missing when networking is disabled.

-----8<-----8<-----8<-----8<-----8<-----
$ guile-2.2
GNU Guile 2.2.5
Copyright (C) 1995-2019 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (use-modules (ice-9 suspendable-ports))
While compiling expression:
In procedure public-lookup: No variable bound to accept in module (guile)
----->8----->8----->8----->8----->8-----

Is guile configured with --disable-networking still a supported
configuration?

Thanks,
Cyprien




Information forwarded to bug-guile <at> gnu.org:
bug#36340; Package guile. (Mon, 24 Jun 2019 12:36:01 GMT) Full text and rfc822 format available.

Message #8 received at 36340 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Cyprien Nicolas <cyprien <at> nicolas.tf>
Cc: 36340 <at> debbugs.gnu.org
Subject: Re: bug#36340: Test failures when networking is disabled
Date: Mon, 24 Jun 2019 14:35:35 +0200
Hi Cyprien!  :-)

Cyprien Nicolas <cyprien <at> nicolas.tf> skribis:

> Is guile configured with --disable-networking still a supported
> configuration?

In theory yes, but as you found out, it’s not well tested.

The way we’d normally addressing in the test suite is by testing:

  (provided? 'socket)

and/or:

  (provided? 'net-db)

and throwing to unresolved or skipping tests altogether.

Would you like to propose a patch that does that for all the instances
that you found?

Thanks!

Ludo’.




Information forwarded to bug-guile <at> gnu.org:
bug#36340; Package guile. (Sun, 07 Jul 2019 13:27:02 GMT) Full text and rfc822 format available.

Message #11 received at 36340 <at> debbugs.gnu.org (full text, mbox):

From: Cyprien Nicolas <cyprien <at> nicolas.tf>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 36340 <at> debbugs.gnu.org
Subject: Re: bug#36340: Test failures when networking is disabled
Date: Sun, 7 Jul 2019 15:26:46 +0200
[Message part 1 (text/plain, inline)]
On 24/06/2019 14:35, Ludovic Courtès wrote:
> Hi Cyprien!  :-)
> 
> Cyprien Nicolas <cyprien <at> nicolas.tf> skribis:
> 
>> Is guile configured with --disable-networking still a supported
>> configuration?
> 
> In theory yes, but as you found out, it’s not well tested.
> 
> The way we’d normally addressing in the test suite is by testing:
> 
>    (provided? 'socket)
> 
> and/or:
> 
>    (provided? 'net-db)
> 
> and throwing to unresolved or skipping tests altogether.
> 
> Would you like to propose a patch that does that for all the instances
> that you found?

Do you mean also harmonizing current tests that uses

    (memq 'socket *features*) ; web-uri.test

and/or

    (defined? 'AF_INET) ; 00-socket.test

or only fixing failing ones?

The attached path mimics net-db.test style for skipping tests for
00-repl-server.test (I hope the indentation is correct).

However, we still have the ice-9 suspendable-ports module issue which
compiles fine but fails to load (actually not related to tests).

Thanks,
[guile-tests-00-repl-server.patch (text/x-patch, attachment)]

Information forwarded to bug-guile <at> gnu.org:
bug#36340; Package guile. (Sun, 09 Mar 2025 23:56:01 GMT) Full text and rfc822 format available.

Message #14 received at 36340 <at> debbugs.gnu.org (full text, mbox):

From: Michael Gran <spk121 <at> yahoo.com>
To: 36340 <at> debbugs.gnu.org
Cc: Michael Gran <spk121 <at> yahoo.com>
Subject: [PATCH 0/2] bug#36340 Fixes to --disable-networking
Date: Sun,  9 Mar 2025 16:55:21 -0700
These are fixes for Guile when built with the --disable-networking
option.

Michael Gran (2):
  Fixes export of suspendable-ports socket funcs when networking
    disabled
  Disable some socket tests when sockets not provided

 module/ice-9/suspendable-ports.scm   | 46 ++++++++++++++++------------
 test-suite/tests/00-repl-server.test |  3 +-
 test-suite/tests/web-server.test     |  6 ++--
 3 files changed, 32 insertions(+), 23 deletions(-)

-- 
2.48.1





Information forwarded to bug-guile <at> gnu.org:
bug#36340; Package guile. (Sun, 09 Mar 2025 23:56:02 GMT) Full text and rfc822 format available.

Message #17 received at 36340 <at> debbugs.gnu.org (full text, mbox):

From: Michael Gran <spk121 <at> yahoo.com>
To: 36340 <at> debbugs.gnu.org
Cc: Michael Gran <spk121 <at> yahoo.com>
Subject: [PATCH 1/2] bug#36340: Fixes suspendable-ports networking disabled
Date: Sun,  9 Mar 2025 16:55:22 -0700
When guile is built with --disable-networking, (ice-9 suspendable-ports)
will attempt to re-export non-existent accept and socket functions.

* module/ice-9/suspendable-ports.scm (accept, connect): set to #f when
  (guile) module does not have accept or connect
  (guile-port-bindings): new variable
  (port-bindings): don't include accept or connect when not defined
---
 module/ice-9/suspendable-ports.scm | 46 ++++++++++++++++++------------
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/module/ice-9/suspendable-ports.scm b/module/ice-9/suspendable-ports.scm
index 9fac1df62..00fd26049 100644
--- a/module/ice-9/suspendable-ports.scm
+++ b/module/ice-9/suspendable-ports.scm
@@ -727,30 +727,38 @@
       (flush-output port))))
 
 (define accept
-  (let ((%accept (@ (guile) accept)))
-    (lambda* (port #:optional (flags 0))
-      (let lp ()
-        (or (%accept port flags)
-            (begin
-              (wait-for-readable port)
-              (lp)))))))
+  (let ((%accept (false-if-exception (@ (guile) accept))))
+    (if %accept
+        (lambda* (port #:optional (flags 0))
+          (let lp ()
+            (or (%accept port flags)
+                (begin
+                  (wait-for-readable port)
+                  (lp)))))
+        #f)))
 
 (define connect
-  (let ((%connect (@ (guile) connect)))
-    (lambda (port sockaddr . args)
-      (unless (apply %connect port sockaddr args)
-        ;; Clownshoes semantics; see connect(2).
-        (wait-for-writable port)
-        (let ((err (getsockopt port SOL_SOCKET SO_ERROR)))
-          (unless (zero? err)
-            (scm-error 'system-error "connect" "~A"
-                       (list (strerror err)) #f)))))))
+  (let ((%connect (false-if-exception (@ (guile) connect))))
+    (if %connect
+        (lambda (port sockaddr . args)
+          (unless (apply %connect port sockaddr args)
+            ;; Clownshoes semantics; see connect(2).
+            (wait-for-writable port)
+            (let ((err (getsockopt port SOL_SOCKET SO_ERROR)))
+              (unless (zero? err)
+                (scm-error 'system-error "connect" "~A"
+                           (list (strerror err)) #f)))))
+        #f)))
 
 (define saved-port-bindings #f)
+(define guile-port-bindings
+  (append
+   '(read-char peek-char force-output close-port)
+   (if accept '(accept) '())
+   (if connect '(connect) '())))
+
 (define port-bindings
-  '(((guile)
-     read-char peek-char force-output close-port
-     accept connect)
+  `(((guile) ,@guile-port-bindings)
     ((ice-9 binary-ports)
      get-u8 lookahead-u8 get-bytevector-n get-bytevector-n!
      get-bytevector-some get-bytevector-some!
-- 
2.48.1





Information forwarded to bug-guile <at> gnu.org:
bug#36340; Package guile. (Sun, 09 Mar 2025 23:56:03 GMT) Full text and rfc822 format available.

Message #20 received at 36340 <at> debbugs.gnu.org (full text, mbox):

From: Michael Gran <spk121 <at> yahoo.com>
To: 36340 <at> debbugs.gnu.org
Cc: Michael Gran <spk121 <at> yahoo.com>
Subject: [PATCH 2/2] bug#36340: Disable tests when sockets not provided
Date: Sun,  9 Mar 2025 16:55:23 -0700
* test-suite/tests/00-repl-server.test (call-with-repl-server): throw
  unsupported when sockets not provided
* test-suite/tests/web-server.test (expect, "server is listening"):
  throw unresolved when socket not provided
---
 test-suite/tests/00-repl-server.test | 3 ++-
 test-suite/tests/web-server.test     | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/test-suite/tests/00-repl-server.test b/test-suite/tests/00-repl-server.test
index 433181ee6..d90da4faa 100644
--- a/test-suite/tests/00-repl-server.test
+++ b/test-suite/tests/00-repl-server.test
@@ -28,7 +28,8 @@
   "Set up a REPL server in a separate process and call PROC with a
 socket connected to that server."
   ;; The REPL server requires thread. The test requires fork.
-  (unless (and (provided? 'threads) (provided? 'fork) (defined? 'mkdtemp))
+  (unless (and (provided? 'threads) (provided? 'fork) (defined? 'mkdtemp)
+               (provided? 'socket))
     (throw 'unsupported))
 
   (let* ((tmpdir (mkdtemp "/tmp/repl-server-test-XXXXXX"))
diff --git a/test-suite/tests/web-server.test b/test-suite/tests/web-server.test
index d84c47d18..f0458eb3f 100644
--- a/test-suite/tests/web-server.test
+++ b/test-suite/tests/web-server.test
@@ -66,7 +66,7 @@
      (run-server handle-request 'http `(#:port ,%port-number)))))
 
 (define-syntax-rule (expect method path code args ...)
-  (if (provided? 'threads)
+  (if (and (provided? 'threads) (provided? 'socket))
       (let-values (((response body)
                     (method (string-append %server-base-uri path)
                             #:decode-body? #t
@@ -78,7 +78,7 @@
 
 (pass-if "server is listening"
   ;; First, wait until the server is listening, up to a few seconds.
-  (if (provided? 'threads)
+  (if (and (provided? 'threads) (provided? 'socket))
       (let ((socket (socket AF_INET SOCK_STREAM 0)))
         (let loop ((n 1))
           (define success?
@@ -122,7 +122,7 @@
     '("Hello, λ world!"
       "Écrit comme ça en Latin-1."
       "GNU Guile")
-  (if (provided? 'threads)
+  (if (and (provided? 'threads) (provided? 'socket))
       (let ((port (open-socket-for-uri %server-base-uri)))
         (define result
           (map (lambda (path)
-- 
2.48.1





This bug report was last modified 95 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.