nsenter: skip ut on non-root

nsenter needs root privilege to run.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
Peng Tao 2019-12-25 01:56:13 -08:00
parent e5b04a5bf2
commit 5617120649

View File

@ -18,10 +18,14 @@ import (
"github.com/stretchr/testify/assert"
"golang.org/x/sys/unix"
ktu "github.com/kata-containers/runtime/pkg/katatestutils"
)
const testPID = 12345
var tu = ktu.NewTestConstraint(true)
func TestGetNSPathFromPID(t *testing.T) {
for nsType := range CloneFlagsTable {
expectedPath := fmt.Sprintf("/proc/%d/ns/%s", testPID, nsType)
@ -165,6 +169,9 @@ func TestNsEnterEmptyNamespaceListSuccess(t *testing.T) {
}
func TestNsEnterSuccessful(t *testing.T) {
if tu.NotValid(ktu.NeedRoot()) {
t.Skip(ktu.TestDisabledNeedRoot)
}
nsList := supportedNamespaces()
sleepDuration := 60