2025-08-19 20:04:22 +00:00
|
|
|
package pmtud
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Test_makeMTUsToTest(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
|
|
testCases := map[string]struct {
|
|
|
|
|
minMTU int
|
|
|
|
|
maxMTU int
|
|
|
|
|
mtus []int
|
|
|
|
|
}{
|
|
|
|
|
"0_0": {
|
2025-10-03 13:55:59 +00:00
|
|
|
mtus: []int{0},
|
2025-08-19 20:04:22 +00:00
|
|
|
},
|
|
|
|
|
"0_1": {
|
|
|
|
|
maxMTU: 1,
|
2025-10-03 13:55:59 +00:00
|
|
|
mtus: []int{0, 1},
|
2025-08-19 20:04:22 +00:00
|
|
|
},
|
|
|
|
|
"0_8": {
|
|
|
|
|
maxMTU: 8,
|
2025-10-03 13:55:59 +00:00
|
|
|
mtus: []int{0, 1, 2, 3, 4, 5, 6, 7, 8},
|
2025-08-19 20:04:22 +00:00
|
|
|
},
|
|
|
|
|
"0_12": {
|
|
|
|
|
maxMTU: 12,
|
2025-10-03 13:55:59 +00:00
|
|
|
mtus: []int{0, 1, 2, 4, 5, 6, 7, 8, 10, 11, 12},
|
2025-08-19 20:04:22 +00:00
|
|
|
},
|
|
|
|
|
"0_80": {
|
|
|
|
|
maxMTU: 80,
|
2025-10-03 13:55:59 +00:00
|
|
|
mtus: []int{0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80},
|
2025-08-19 20:04:22 +00:00
|
|
|
},
|
|
|
|
|
"0_100": {
|
|
|
|
|
maxMTU: 100,
|
2025-10-03 13:55:59 +00:00
|
|
|
mtus: []int{0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100},
|
2025-08-19 20:04:22 +00:00
|
|
|
},
|
|
|
|
|
"1280_1500": {
|
|
|
|
|
minMTU: 1280,
|
|
|
|
|
maxMTU: 1500,
|
2025-10-03 13:55:59 +00:00
|
|
|
mtus: []int{1280, 1302, 1324, 1346, 1368, 1390, 1412, 1434, 1456, 1478, 1500},
|
2025-08-19 20:04:22 +00:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for name, testCase := range testCases {
|
|
|
|
|
t.Run(name, func(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
|
|
mtus := makeMTUsToTest(testCase.minMTU, testCase.maxMTU)
|
|
|
|
|
assert.Equal(t, testCase.mtus, mtus)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|