@@ -158,11 +158,13 @@ spec = do
158158 when isUnixDomainSocketAvailable $ do
159159 context " unix sockets" $ do
160160 it " basic unix sockets end-to-end" $ do
161- let client sock = send sock testMsg
162- server (sock, addr) = do
163- recv sock 1024 `shouldReturn` testMsg
164- addr `shouldBe` (SockAddrUnix " " )
165- test . setClientAction client $ unixWithUnlink unixAddr server
161+ withSystemTempDirectory " haskell-network" $ \ path -> do
162+ let unixAddr = path ++ " /socket-file"
163+ let client sock = send sock testMsg
164+ server (sock, addr) = do
165+ recv sock 1024 `shouldReturn` testMsg
166+ addr `shouldBe` (SockAddrUnix " " )
167+ test . setClientAction client $ unixWithUnlink unixAddr server
166168#endif
167169
168170#ifdef linux_HOST_OS
@@ -208,19 +210,21 @@ spec = do
208210 --
209211 describe " getPeerCredential" $ do
210212 it " can return something" $ do
211- -- It would be useful to check that we did not get garbage
212- -- back, but rather the actual uid of the test program. For
213- -- that we'd need System.Posix.User, but that is not available
214- -- under Windows. For now, accept the risk that we did not get
215- -- the right answer.
216- --
217- let server (sock, _) = do
218- (_, uid, _) <- getPeerCredential sock
219- uid `shouldNotBe` Nothing
220- client sock = do
221- (_, uid, _) <- getPeerCredential sock
222- uid `shouldNotBe` Nothing
223- test . setClientAction client $ unixWithUnlink unixAddr server
213+ withSystemTempDirectory " haskell-network" $ \ path -> do
214+ let unixAddr = path ++ " /socket-file"
215+ -- It would be useful to check that we did not get garbage
216+ -- back, but rather the actual uid of the test program. For
217+ -- that we'd need System.Posix.User, but that is not available
218+ -- under Windows. For now, accept the risk that we did not get
219+ -- the right answer.
220+ --
221+ let server (sock, _) = do
222+ (_, uid, _) <- getPeerCredential sock
223+ uid `shouldNotBe` Nothing
224+ client sock = do
225+ (_, uid, _) <- getPeerCredential sock
226+ uid `shouldNotBe` Nothing
227+ test . setClientAction client $ unixWithUnlink unixAddr server
224228 {- The below test fails on many *BSD systems, because the getsockopt()
225229 call that underlies getpeereid() does not have the same meaning for
226230 all address families, but the C-library was not checking that the
0 commit comments