mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-22 12:29:49 +00:00
kata-env: Fix amd64 VM container capable check
Fix nasty bug which resulted in `kata-env` showing `VMContainerCapable = true` even on amd64 systems without virtualisation support (thankfully `kata-check` still showed the correct results). Added arch-specific tests to avoid any possibility of regression. Fixes #660. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
@@ -491,3 +491,32 @@ func TestKvmIsUsable(t *testing.T) {
|
||||
func TestGetCPUDetails(t *testing.T) {
|
||||
genericTestGetCPUDetails(t)
|
||||
}
|
||||
|
||||
func TestSetCPUtype(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
savedArchRequiredCPUFlags := archRequiredCPUFlags
|
||||
savedArchRequiredCPUAttribs := archRequiredCPUAttribs
|
||||
savedArchRequiredKernelModules := archRequiredKernelModules
|
||||
|
||||
defer func() {
|
||||
archRequiredCPUFlags = savedArchRequiredCPUFlags
|
||||
archRequiredCPUAttribs = savedArchRequiredCPUAttribs
|
||||
archRequiredKernelModules = savedArchRequiredKernelModules
|
||||
}()
|
||||
|
||||
archRequiredCPUFlags = map[string]string{}
|
||||
archRequiredCPUAttribs = map[string]string{}
|
||||
archRequiredKernelModules = map[string]kernelModule{}
|
||||
|
||||
setCPUtype()
|
||||
|
||||
assert.NotEmpty(archRequiredCPUFlags)
|
||||
assert.NotEmpty(archRequiredCPUAttribs)
|
||||
assert.NotEmpty(archRequiredKernelModules)
|
||||
|
||||
assert.Equal(archRequiredCPUFlags["vmx"], "Virtualization support")
|
||||
|
||||
_, ok := archRequiredKernelModules["kvm"]
|
||||
assert.True(ok)
|
||||
}
|
||||
|
Reference in New Issue
Block a user