tun_linux_test.go 934 B

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