1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
14 func (ll *Link) String() string {
15 return fmt.Sprintf("name=%s index=%d type=%d flags=%#x mtu=%d addr=%v", ll.Name, ll.Index, ll.Type, ll.Flags, ll.MTU, llAddr(ll.Addr))
18 type linkPack struct {
23 func linkPacks() ([]linkPack, error) {
26 for _, af := range [...]int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} {
27 lls, err := Links(af, "")
32 lps = append(lps, linkPack{af: af, lls: lls})
37 func TestLinks(t *testing.T) {
38 lps, err := linkPacks()
39 if len(lps) == 0 && err != nil {
42 for _, lp := range lps {
44 for _, sll := range lp.lls {
45 lls, err := Links(lp.af, sll.Name)
47 t.Fatal(lp.af, sll.Name, err)
49 for _, ll := range lls {
50 if ll.Name != sll.Name || ll.Index != sll.Index {
51 t.Errorf("af=%s got %v; want %v", addrFamily(lp.af), &ll, &sll)
54 t.Logf("af=%s name=%s %v", addrFamily(lp.af), sll.Name, &ll)
59 t.Errorf("af=%s got %d; want %d", addrFamily(lp.af), n, len(lp.lls))