From 1f32ce1bb380845be7f5d174ac641a2c592c0c42 Mon Sep 17 00:00:00 2001 From: Shirou WAKAYAMA Date: Tue, 15 Mar 2016 22:47:56 +0900 Subject: [PATCH] [net]linux: skip if "/proc/sys/net" is not exists on test environment. --- net/net_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/net/net_test.go b/net/net_test.go index aabce81..30cef51 100644 --- a/net/net_test.go +++ b/net/net_test.go @@ -3,7 +3,10 @@ package net import ( "fmt" "os" + "runtime" "testing" + + "github.com/shirou/gopsutil/internal/common" ) func TestAddrString(t *testing.T) { @@ -202,6 +205,13 @@ func TestNetFilterCounters(t *testing.T) { return } + if runtime.GOOS == "linux" { + // some test environment has not the path. + if !common.PathExists("/proc/sys/net/netfilter/nf_conntrack_count") { + t.SkipNow() + } + } + v, err := NetFilterCounters() if err != nil { t.Errorf("could not get NetConnections: %v", err) -- GitLab