summaryrefslogtreecommitdiffhomepage
path: root/test/iptables/iptables_test.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-07-08 16:36:33 -0700
committergVisor bot <gvisor-bot@google.com>2020-07-08 16:36:33 -0700
commit4f7af437e25382bdf75b880d1bf3184eae725231 (patch)
tree7c42719b3cba6fb94b2c3071b82d40e594560e04 /test/iptables/iptables_test.go
parenta75d9f7bee72b9d7611cb015e473ac0bed3d9b02 (diff)
parent14ff2ea9bfc83fb37afe8a5e17e8b8173f85eb68 (diff)
Merge pull request #3171 from kevinGC:ipv6-kokoro
PiperOrigin-RevId: 320290162
Diffstat (limited to 'test/iptables/iptables_test.go')
-rw-r--r--test/iptables/iptables_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/iptables/iptables_test.go b/test/iptables/iptables_test.go
index 9dc64f655..f5ac79370 100644
--- a/test/iptables/iptables_test.go
+++ b/test/iptables/iptables_test.go
@@ -18,6 +18,7 @@ import (
"context"
"fmt"
"net"
+ "reflect"
"testing"
"gvisor.dev/gvisor/pkg/test/dockerutil"
@@ -317,3 +318,28 @@ func TestInputSource(t *testing.T) {
func TestInputInvertSource(t *testing.T) {
singleTest(t, FilterInputInvertSource{})
}
+
+func TestFilterAddrs(t *testing.T) {
+ tcs := []struct {
+ ipv6 bool
+ addrs []string
+ want []string
+ }{
+ {
+ ipv6: false,
+ addrs: []string{"192.168.0.1", "192.168.0.2/24", "::1", "::2/128"},
+ want: []string{"192.168.0.1", "192.168.0.2"},
+ },
+ {
+ ipv6: true,
+ addrs: []string{"192.168.0.1", "192.168.0.2/24", "::1", "::2/128"},
+ want: []string{"::1", "::2"},
+ },
+ }
+
+ for _, tc := range tcs {
+ if got := filterAddrs(tc.addrs, tc.ipv6); !reflect.DeepEqual(got, tc.want) {
+ t.Errorf("%v with IPv6 %t: got %v, but wanted %v", tc.addrs, tc.ipv6, got, tc.want)
+ }
+ }
+}