This repository has been archived by the owner on May 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
d52f426
commit f70db71
Showing
9 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,3 +199,7 @@ foo : bar | |
} | ||
} | ||
} | ||
|
||
func TestSetCPUtype(t *testing.T) { | ||
testSetCPUTypeGeneric(t) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2018 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
// +build arm64 ppc64le | ||
|
||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func testSetCPUTypeGeneric(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
savedArchRequiredCPUFlags := archRequiredCPUFlags | ||
savedArchRequiredCPUAttribs := archRequiredCPUAttribs | ||
savedArchRequiredKernelModules := archRequiredKernelModules | ||
|
||
defer func() { | ||
archRequiredCPUFlags = savedArchRequiredCPUFlags | ||
archRequiredCPUAttribs = savedArchRequiredCPUAttribs | ||
archRequiredKernelModules = savedArchRequiredKernelModules | ||
}() | ||
|
||
assert.Empty(archRequiredCPUFlags) | ||
assert.Empty(archRequiredCPUAttribs) | ||
assert.NotEmpty(archRequiredKernelModules) | ||
|
||
setCPUtype() | ||
|
||
assert.Equal(archRequiredCPUFlags, savedArchRequiredCPUFlags) | ||
assert.Equal(archRequiredCPUAttribs, savedArchRequiredCPUAttribs) | ||
assert.Equal(archRequiredKernelModules, savedArchRequiredKernelModules) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// 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 testEnvGetEnvInfoSetsCPUTypeGeneric(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) | ||
|
||
configFile, config, err := makeRuntimeConfig(tmpdir) | ||
assert.NoError(err) | ||
|
||
expectedEnv, err := getExpectedSettings(config, tmpdir, configFile) | ||
assert.NoError(err) | ||
|
||
env, err := getEnvInfo(configFile, config) | ||
assert.NoError(err) | ||
|
||
assert.Equal(expectedEnv, env) | ||
|
||
assert.Equal(archRequiredCPUFlags, savedArchRequiredCPUFlags) | ||
assert.Equal(archRequiredCPUAttribs, savedArchRequiredCPUAttribs) | ||
assert.Equal(archRequiredKernelModules, savedArchRequiredKernelModules) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters