tun_linux_test.go 971 B

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