2023-03-30 17:37:06 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package tstun
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2023-09-22 17:44:59 +00:00
|
|
|
func TestDefaultMTU(t *testing.T) {
|
|
|
|
orig := os.Getenv("TS_DEBUG_MTU")
|
|
|
|
defer os.Setenv("TS_DEBUG_MTU", orig)
|
2023-03-30 17:37:06 +00:00
|
|
|
|
|
|
|
os.Setenv("TS_DEBUG_MTU", "")
|
2023-09-22 17:44:59 +00:00
|
|
|
if DefaultMTU() != 1280 {
|
|
|
|
t.Errorf("DefaultMTU() = %d, want 1280", DefaultMTU())
|
2023-03-30 17:37:06 +00:00
|
|
|
}
|
|
|
|
|
2023-09-22 17:44:59 +00:00
|
|
|
os.Setenv("TS_DEBUG_MTU", "9000")
|
|
|
|
if DefaultMTU() != 9000 {
|
|
|
|
t.Errorf("DefaultMTU() = %d, want 9000", DefaultMTU())
|
2023-03-30 17:37:06 +00:00
|
|
|
}
|
|
|
|
|
2023-09-22 17:44:59 +00:00
|
|
|
os.Setenv("TS_DEBUG_MTU", "123456789")
|
|
|
|
if DefaultMTU() != maxMTU {
|
|
|
|
t.Errorf("DefaultMTU() = %d, want %d", DefaultMTU(), maxMTU)
|
2023-03-30 17:37:06 +00:00
|
|
|
}
|
|
|
|
}
|