mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-28 20:15:51 +00:00
ACRN hypervisor is a type-1 hypervisor and this patch adds support to check and validate if the system is capable of running kata containers with ACRN hypervisor. Depends-on: github.com/kata-containers/tests#1793 v3->v4: Implemented a generic way to identify hypervisor and test VM creation. v2->v3: 1. Removed cgo structs and defined go structs. 2. Suppressed lint warnings due to unused createVM struct. v1->v2: 1. Created an issue #1784 to address TODO item. 2. Fixed formatting of the log message. 3. Currently ACRN is only supported on amd64. So moved ACRN specific code to kata-check_amd64.go. Fixes: #1778 Signed-off-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
// Copyright (c) 2018 Intel Corporation
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
// +build arm64 ppc64le
|
|
|
|
package main
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func testSetCPUTypeGeneric(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
tmpdir, err := ioutil.TempDir("", "")
|
|
assert.NoError(err)
|
|
defer os.RemoveAll(tmpdir)
|
|
|
|
savedArchRequiredCPUFlags := archRequiredCPUFlags
|
|
savedArchRequiredCPUAttribs := archRequiredCPUAttribs
|
|
savedArchRequiredKernelModules := archRequiredKernelModules
|
|
|
|
defer func() {
|
|
archRequiredCPUFlags = savedArchRequiredCPUFlags
|
|
archRequiredCPUAttribs = savedArchRequiredCPUAttribs
|
|
archRequiredKernelModules = savedArchRequiredKernelModules
|
|
}()
|
|
|
|
assert.Empty(archRequiredCPUFlags)
|
|
assert.Empty(archRequiredCPUAttribs)
|
|
assert.NotEmpty(archRequiredKernelModules)
|
|
|
|
_, config, err := makeRuntimeConfig(tmpdir)
|
|
assert.NoError(err)
|
|
|
|
setCPUtype(config.HypervisorType)
|
|
|
|
assert.Equal(archRequiredCPUFlags, savedArchRequiredCPUFlags)
|
|
assert.Equal(archRequiredCPUAttribs, savedArchRequiredCPUAttribs)
|
|
assert.Equal(archRequiredKernelModules, savedArchRequiredKernelModules)
|
|
}
|