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-- 791 bytes parent folder | download | duplicates (3)
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 rtnl

import (
	"net"
	"testing"
)

func TestLiveRoute(t *testing.T) {
	c, err := Dial(nil)
	if err != nil {
		t.Fatal(err)
	}
	defer c.Close()

	route, err := c.RouteGet(net.ParseIP("8.8.8.8"))
	if err != nil {
		t.Fatal(err)
	}

	t.Logf("got route: %v", route)
	if route.Gateway.IsUnspecified() {
		t.Error("zero route.Gateway, expected non-zero")
	}
	if route.Gateway.IsLoopback() {
		t.Error("lo route.Gatway, expected non lo")
	}
	if route.Interface == nil {
		t.Error("nil route.Interface, expected non-nil")
	}
	if len(route.Interface.Name) == 0 {
		t.Error("zero-length route.Interface.Name")
	}
	if hardwareAddrIsUnspecified(route.Interface.HardwareAddr) {
		t.Error("zero route.Interface.HardwareAddr, expected non-zero")
	}
}