summaryrefslogtreecommitdiffstats
path: root/tests/014
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-10-05 23:55:48 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-10-05 23:55:48 -0700
commit30d54e446ae4137f3cb5db6495f865d1c51ffb54 (patch)
treeda116dd77a8c64b4773b7fe542a3321b8dfdade6 /tests/014
parent35e1645eacd6baa334e9107cdc65913427401942 (diff)
downloadtxr-30d54e446ae4137f3cb5db6495f865d1c51ffb54.tar.gz
txr-30d54e446ae4137f3cb5db6495f865d1c51ffb54.tar.bz2
txr-30d54e446ae4137f3cb5db6495f865d1c51ffb54.zip
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.
Diffstat (limited to 'tests/014')
-rw-r--r--tests/014/socket-misc.tl4
1 files 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)))