Skip NetNsId tests unless root

This commit is contained in:
Oleg Senin 2020-02-21 14:38:19 +03:00 committed by Alessandro Boch
parent 5f2fc868c2
commit c79a4b7b40
1 changed files with 2 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import (
// then retrieves the ID. // then retrieves the ID.
// This does not do any namespace switching. // This does not do any namespace switching.
func TestNetNsIdByFd(t *testing.T) { func TestNetNsIdByFd(t *testing.T) {
skipUnlessRoot(t)
// create a network namespace // create a network namespace
ns, err := netns.New() ns, err := netns.New()
CheckErrorFail(t, err) CheckErrorFail(t, err)
@ -44,6 +45,7 @@ func TestNetNsIdByFd(t *testing.T) {
// Does the same as TestNetNsIdByFd, but we need to change namespaces so we // Does the same as TestNetNsIdByFd, but we need to change namespaces so we
// actually have a pid in that namespace // actually have a pid in that namespace
func TestNetNsIdByPid(t *testing.T) { func TestNetNsIdByPid(t *testing.T) {
skipUnlessRoot(t)
runtime.LockOSThread() // we need a constant OS thread runtime.LockOSThread() // we need a constant OS thread
origNs, _ := netns.Get() origNs, _ := netns.Get()