linuxfwtest.go 717 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright (c) Tailscale Inc & contributors
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. //go:build cgo && linux
  4. // Package linuxfwtest contains tests for the linuxfw package. Go does not
  5. // support cgo in tests, and we don't want the main package to have a cgo
  6. // dependency, so we put all the tests here and call them from the main package
  7. // in tests intead.
  8. package linuxfwtest
  9. import (
  10. "testing"
  11. "unsafe"
  12. )
  13. /*
  14. #include <sys/socket.h> // socket()
  15. */
  16. import "C"
  17. type SizeInfo struct {
  18. SizeofSocklen uintptr
  19. }
  20. func TestSizes(t *testing.T, si *SizeInfo) {
  21. want := unsafe.Sizeof(C.socklen_t(0))
  22. if want != si.SizeofSocklen {
  23. t.Errorf("sockLen has wrong size; want=%d got=%d", want, si.SizeofSocklen)
  24. }
  25. }