File: route_live_test.go

package info (click to toggle)
golang-github-jsimonetti-rtnetlink 2.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,264 kB
  • sloc: makefile: 2
file content (39 lines) | stat: -rw-r--r-- 720 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//go:build integration
// +build integration

package rtnetlink

import (
	"testing"

	"github.com/jsimonetti/rtnetlink/v2/internal/unix"
	"github.com/mdlayher/netlink"
)

func TestListMatch(t *testing.T) {
	c, err := Dial(&netlink.Config{Strict: true})
	if err != nil {
		t.Fatal(err)
	}
	defer c.Close()

	routes, err := c.Route.ListMatch(&RouteMessage{
		Family: unix.AF_INET,
		Attributes: RouteAttributes{
			Table: unix.RT_TABLE_MAIN,
		},
	})
	if err != nil {
		t.Fatal(err)
	}

	if len(routes) <= 1 {
		t.Fatal("expected multiple routes to be returned")
	}

	for _, rx := range routes {
		if rx.Attributes.Table != unix.RT_TABLE_MAIN {
			t.Fatalf("unepxected route from table %d", rx.Attributes.Table)
		}
	}
}