• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2024 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package windows_test
6
7import (
8	"errors"
9	"internal/syscall/windows"
10	"syscall"
11	"testing"
12)
13
14func TestSupportUnixSocket(t *testing.T) {
15	var d syscall.WSAData
16	if err := syscall.WSAStartup(uint32(0x202), &d); err != nil {
17		t.Fatal(err)
18	}
19	defer syscall.WSACleanup()
20
21	// Test that SupportUnixSocket returns true if WSASocket succeeds with AF_UNIX.
22	got := windows.SupportUnixSocket()
23	s, err := windows.WSASocket(syscall.AF_UNIX, syscall.SOCK_STREAM, 0, nil, 0, windows.WSA_FLAG_NO_HANDLE_INHERIT)
24	if err == nil {
25		syscall.Closesocket(s)
26	}
27	want := !errors.Is(err, windows.WSAEAFNOSUPPORT) && !errors.Is(err, windows.WSAEINVAL)
28	if want != got {
29		t.Errorf("SupportUnixSocket = %v; want %v", got, want)
30	}
31}
32