Files
kata-containers/virtcontainers/utils/utils_linux_test.go
Gabi Beyer b08ab6ae1f vc: modify ioctl function to handle shim test
The kata shim tests make use of an ioctl function, so instead
of having a custom one within that file, use the ioctl
function in utils/utils_linux

Fixes #1419

Signed-off-by: Gabi Beyer <Gabrielle.n.beyer@intel.com>
2019-04-12 10:48:08 -07:00

36 lines
647 B
Go

// Copyright (c) 2018 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
package utils
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func TestFindContextID(t *testing.T) {
assert := assert.New(t)
ioctlFunc = func(fd uintptr, request, arg1 uintptr) error {
return errors.New("ioctl")
}
orgVHostVSockDevicePath := VHostVSockDevicePath
orgMaxUInt := maxUInt
defer func() {
VHostVSockDevicePath = orgVHostVSockDevicePath
maxUInt = orgMaxUInt
}()
VHostVSockDevicePath = "/dev/null"
maxUInt = uint64(1000000)
f, cid, err := FindContextID()
assert.Nil(f)
assert.Zero(cid)
assert.Error(err)
}