~john-koepi/ubuntu/trusty/golang/default

« back to all changes in this revision

Viewing changes to src/pkg/net/interface_test.go

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-08-03 17:04:59 UTC
  • mfrom: (14.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110803170459-wzd99m3567y80ila
Tags: 1:59-1
* Imported Upstream version 59
* Refresh patches to a new release
* Fix FTBFS on ARM (Closes: #634270)
* Update version.bash to work with Debian packaging and not hg
  repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
        return false
20
20
}
21
21
 
22
 
func interfaceFlagsString(ifi *Interface) string {
23
 
        fs := "<"
24
 
        if ifi.IsUp() {
25
 
                fs += "UP,"
26
 
        }
27
 
        if ifi.CanBroadcast() {
28
 
                fs += "BROADCAST,"
29
 
        }
30
 
        if ifi.IsLoopback() {
31
 
                fs += "LOOPBACK,"
32
 
        }
33
 
        if ifi.IsPointToPoint() {
34
 
                fs += "POINTOPOINT,"
35
 
        }
36
 
        if ifi.CanMulticast() {
37
 
                fs += "MULTICAST,"
38
 
        }
39
 
        if len(fs) > 1 {
40
 
                fs = fs[:len(fs)-1]
41
 
        }
42
 
        fs += ">"
43
 
        return fs
44
 
}
45
 
 
46
22
func TestInterfaces(t *testing.T) {
47
23
        ift, err := Interfaces()
48
24
        if err != nil {
69
45
                if err != nil {
70
46
                        t.Fatalf("Interface.Addrs() failed: %v", err)
71
47
                }
72
 
                t.Logf("%s: flags %s, ifindex %v, mtu %v\n", ifi.Name, interfaceFlagsString(&ifi), ifi.Index, ifi.MTU)
 
48
                t.Logf("%q: flags %q, ifindex %v, mtu %v\n", ifi.Name, ifi.Flags.String(), ifi.Index, ifi.MTU)
73
49
                for _, ifa := range ifat {
74
 
                        t.Logf("\tinterface address %s\n", ifa.String())
 
50
                        t.Logf("\tinterface address %q\n", ifa.String())
75
51
                }
76
 
                t.Logf("\thardware address %v", ifi.HardwareAddr.String())
 
52
                t.Logf("\thardware address %q", ifi.HardwareAddr.String())
77
53
        }
78
54
}
79
55
 
85
61
        t.Logf("table: len/cap = %v/%v\n", len(ifat), cap(ifat))
86
62
 
87
63
        for _, ifa := range ifat {
88
 
                t.Logf("interface address %s\n", ifa.String())
 
64
                t.Logf("interface address %q\n", ifa.String())
89
65
        }
90
66
}