mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-25 15:02:45 +00:00
vc: set store RunVMStoragePath for ut
Otherwise we fail ut on failures like: === RUN TestCloudHypervisorCleanupVM --- FAIL: TestCloudHypervisorCleanupVM (0.00s) clh_test.go:191: cloudHypervisor.cleanupVM() expected error != open /run/vc/vm: permission denied clh_test.go:200: Unexpected error = stat /run/vc/vm/cleanVMID: permission denied === RUN TestClhCreateSandbox --- PASS: TestClhCreateSandbox (0.00s) === RUN TestClooudHypervisorStartSandbox time="2019-12-25T00:48:47-08:00" level=error msg="trace called before context set" source=virtcontainers subsystem=cloudHypervisor type=bug --- FAIL: TestClooudHypervisorStartSandbox (0.00s) Error Trace: clh_test.go:266 Error: Received unexpected error: mkdir /run/vc/vm: permission denied Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
parent
3deb24e5de
commit
4c35d0911a
@ -57,21 +57,28 @@ var testVirtiofsdPath = ""
|
||||
var testHyperstartCtlSocket = ""
|
||||
var testHyperstartTtySocket = ""
|
||||
|
||||
var savedRunVMStoragePathFunc func() string
|
||||
|
||||
// cleanUp Removes any stale sandbox/container state that can affect
|
||||
// the next test to run.
|
||||
func cleanUp() {
|
||||
globalSandboxList.removeSandbox(testSandboxID)
|
||||
store.DeleteAll()
|
||||
os.RemoveAll(testDir)
|
||||
os.MkdirAll(testDir, store.DirMode)
|
||||
store.VCStorePrefix = ""
|
||||
store.RunVMStoragePath = savedRunVMStoragePathFunc
|
||||
|
||||
setup()
|
||||
}
|
||||
|
||||
func setup() {
|
||||
os.Mkdir(filepath.Join(testDir, testBundle), store.DirMode)
|
||||
store.VCStorePrefix = testDir
|
||||
savedRunVMStoragePathFunc = store.RunVMStoragePath
|
||||
store.RunVMStoragePath = func() string {
|
||||
return filepath.Join("testDir", "vm")
|
||||
}
|
||||
os.MkdirAll(store.RunVMStoragePath(), store.DirMode)
|
||||
os.MkdirAll(filepath.Join(testDir, testBundle), store.DirMode)
|
||||
|
||||
for _, filename := range []string{testQemuKernelPath, testQemuInitrdPath, testQemuImagePath, testQemuPath} {
|
||||
_, err := os.Create(filename)
|
||||
|
Loading…
Reference in New Issue
Block a user