ut: skip TestStartNetworkMonitor for non-root

It requires root to manipulate netns and otherwise fails
like below:

=== RUN   TestStartNetworkMonitor
--- FAIL: TestStartNetworkMonitor (0.00s)
        Error Trace:    sandbox_test.go:1481
        Error:          Expected nil, but got: &errors.errorString{s:"Error switching to ns /proc/6648/task/6651/ns/net: operation not permitted"}

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
Peng Tao 2019-07-19 08:36:43 -07:00
parent d987a30367
commit c4583f4486

View File

@ -1458,6 +1458,9 @@ func TestGetNetNs(t *testing.T) {
} }
func TestStartNetworkMonitor(t *testing.T) { func TestStartNetworkMonitor(t *testing.T) {
if os.Getuid() != 0 {
t.Skip("Test disabled as requires root user")
}
trueBinPath, err := exec.LookPath("true") trueBinPath, err := exec.LookPath("true")
assert.Nil(t, err) assert.Nil(t, err)
assert.NotEmpty(t, trueBinPath) assert.NotEmpty(t, trueBinPath)