mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-10 20:23:35 +00:00
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>
36 lines
647 B
Go
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)
|
|
}
|