summaryrefslogtreecommitdiffhomepage
path: root/util/linuxfw/linuxfwtest/linuxfwtest.go
blob: ee2cbd1b227f491b2fc79224c061e1c26be5e5df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause

//go:build cgo && linux

// Package linuxfwtest contains tests for the linuxfw package. Go does not
// support cgo in tests, and we don't want the main package to have a cgo
// dependency, so we put all the tests here and call them from the main package
// in tests intead.
package linuxfwtest

import (
	"testing"
	"unsafe"
)

/*
#include <sys/socket.h>  // socket()
*/
import "C"

type SizeInfo struct {
	SizeofSocklen uintptr
}

func TestSizes(t *testing.T, si *SizeInfo) {
	want := unsafe.Sizeof(C.socklen_t(0))
	if want != si.SizeofSocklen {
		t.Errorf("sockLen has wrong size; want=%d got=%d", want, si.SizeofSocklen)
	}
}