...
1
2
3
4
5 package route
6
7 import (
8 "syscall"
9 "testing"
10 )
11
12 func TestFetchAndParseRIBOnDarwin(t *testing.T) {
13 for _, typ := range []RIBType{syscall.NET_RT_FLAGS, syscall.NET_RT_DUMP2, syscall.NET_RT_IFLIST2} {
14 var lastErr error
15 var ms []Message
16 for _, af := range []int{syscall.AF_UNSPEC, syscall.AF_INET, syscall.AF_INET6} {
17 rs, err := fetchAndParseRIB(af, typ)
18 if err != nil {
19 lastErr = err
20 continue
21 }
22 ms = append(ms, rs...)
23 }
24 if len(ms) == 0 && lastErr != nil {
25 t.Error(typ, lastErr)
26 continue
27 }
28 ss, err := msgs(ms).validate()
29 if err != nil {
30 t.Error(typ, err)
31 continue
32 }
33 for _, s := range ss {
34 t.Log(s)
35 }
36 }
37 }
38
View as plain text