tun_linux_test.go 852 B

1234567891011121314151617181920212223242526272829303132333435
  1. //go:build !e2e_testing
  2. // +build !e2e_testing
  3. package overlay
  4. import "testing"
  5. var runAdvMSSTests = []struct {
  6. name string
  7. defaultMTU int
  8. maxMTU int
  9. r Route
  10. expected int
  11. }{
  12. // Standard case, default MTU is the device max MTU
  13. {"default", 1440, 1440, Route{}, 0},
  14. {"default-min", 1440, 1440, Route{MTU: 1440}, 0},
  15. {"default-low", 1440, 1440, Route{MTU: 1200}, 1160},
  16. // Case where we have a route MTU set higher than the default
  17. {"route", 1440, 8941, Route{}, 1400},
  18. {"route-min", 1440, 8941, Route{MTU: 1440}, 1400},
  19. {"route-high", 1440, 8941, Route{MTU: 8941}, 0},
  20. }
  21. func TestTunAdvMSS(t *testing.T) {
  22. for _, tt := range runAdvMSSTests {
  23. t.Run(tt.name, func(t *testing.T) {
  24. o := advMSS(tt.r, tt.defaultMTU, tt.maxMTU)
  25. if o != tt.expected {
  26. t.Errorf("got %d, want %d", o, tt.expected)
  27. }
  28. })
  29. }
  30. }