From 30d54e446ae4137f3cb5db6495f865d1c51ffb54 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 5 Oct 2021 23:55:48 -0700 Subject: unix: fix sock-opt test case. On systems with true Unix heritage, like Solaris, MacOS/Darwin, and undoubtedly various BSDs, getsockopt is returning a bitmask value for some options , rather than 1. For instance if we enable SO_REUSEADDR, and then read back the value of the option, we get 4 and not 1. This is because the value of the SO_REUSEADDR symbol itself is 4; it is a mask. The kernel code is evidently just masking out the desired option out of the option mask, and returning the mask value without reducing it to 0 or 1. * tests/014/socket-misc.tl: Test the result of sock-opt for nonzero using nzerop rather than testing specifically for 1. --- tests/014/socket-misc.tl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/014/socket-misc.tl b/tests/014/socket-misc.tl index bd94acac..5f533529 100644 --- a/tests/014/socket-misc.tl +++ b/tests/014/socket-misc.tl @@ -13,8 +13,8 @@ (vtest (sock-peer s) orig))) (with-stream (s (open-socket af-inet sock-stream)) - (test (set-and-get (sock-opt s sol-socket so-reuseaddr) 1) 1) + (test (nzerop (set-and-get (sock-opt s sol-socket so-reuseaddr) 1)) t) (test (set-and-get (sock-opt s sol-socket so-reuseaddr (ffi int)) 0) 0) (whenlet ((addr (bindfree s 1025 65535))) ;; sock-bind enables so-reuseaddr. - (test (sock-opt s sol-socket so-reuseaddr) 1))) + (test (nzerop (sock-opt s sol-socket so-reuseaddr)) t))) -- cgit v1.2.3