golang.org/x/net@v0.25.1-0.20240516223405-c87a5b62e243/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 (
     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  }