github.com/lianghucheng/zrddz@v0.0.0-20200923083010-c71f680932e2/src/golang.org/x/net/route/message_darwin_test.go (about)

     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.
     4  
     5  package route
     6  
     7  import "testing"
     8  
     9  func TestFetchAndParseRIBOnDarwin(t *testing.T) {
    10  	for _, typ := range []RIBType{sysNET_RT_FLAGS, sysNET_RT_DUMP2, sysNET_RT_IFLIST2} {
    11  		var lastErr error
    12  		var ms []Message
    13  		for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} {
    14  			rs, err := fetchAndParseRIB(af, typ)
    15  			if err != nil {
    16  				lastErr = err
    17  				continue
    18  			}
    19  			ms = append(ms, rs...)
    20  		}
    21  		if len(ms) == 0 && lastErr != nil {
    22  			t.Error(typ, lastErr)
    23  			continue
    24  		}
    25  		ss, err := msgs(ms).validate()
    26  		if err != nil {
    27  			t.Error(typ, err)
    28  			continue
    29  		}
    30  		for _, s := range ss {
    31  			t.Log(s)
    32  		}
    33  	}
    34  }