Commit a25ba901 authored by Mikio Hara's avatar Mikio Hara

lif: don't fail test when at least one version of INET protocols is available

This is not perfect but is enough for during the dual IP stack era.

Change-Id: Icd318f75b3ed8c73ccd588be8122379b263651fb
Reviewed-on: https://go-review.googlesource.com/41514
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent d212a1ef
...@@ -78,15 +78,17 @@ type addrPack struct { ...@@ -78,15 +78,17 @@ type addrPack struct {
} }
func addrPacks() ([]addrPack, error) { func addrPacks() ([]addrPack, error) {
var lastErr error
var aps []addrPack var aps []addrPack
for _, af := range [...]int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} { for _, af := range [...]int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} {
as, err := Addrs(af, "") as, err := Addrs(af, "")
if err != nil { if err != nil {
return nil, err lastErr = err
continue
} }
aps = append(aps, addrPack{af: af, as: as}) aps = append(aps, addrPack{af: af, as: as})
} }
return aps, nil return aps, lastErr
} }
func TestAddrs(t *testing.T) { func TestAddrs(t *testing.T) {
......
...@@ -21,15 +21,17 @@ type linkPack struct { ...@@ -21,15 +21,17 @@ type linkPack struct {
} }
func linkPacks() ([]linkPack, error) { func linkPacks() ([]linkPack, error) {
var lastErr error
var lps []linkPack var lps []linkPack
for _, af := range [...]int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} { for _, af := range [...]int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} {
lls, err := Links(af, "") lls, err := Links(af, "")
if err != nil { if err != nil {
return nil, err lastErr = err
continue
} }
lps = append(lps, linkPack{af: af, lls: lls}) lps = append(lps, linkPack{af: af, lls: lls})
} }
return lps, nil return lps, lastErr
} }
func TestLinks(t *testing.T) { func TestLinks(t *testing.T) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment