mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-01 17:52:40 +00:00
virtcontainers: Remove code duplication in the test setup
And add some additional log output for displaying the directories and files created when kicking the virtcontainers tests. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
cf22f402d8
commit
a02fd5982c
@ -81,27 +81,36 @@ func TestMain(m *testing.M) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Printf("INFO: Creating virtcontainers test directory %s\n", testDir)
|
||||||
err = os.MkdirAll(testDir, dirMode)
|
err = os.MkdirAll(testDir, dirMode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Could not create test directories:", err)
|
fmt.Println("Could not create test directories:", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = os.Create(filepath.Join(testDir, testKernel))
|
testQemuKernelPath = filepath.Join(testDir, testKernel)
|
||||||
|
testQemuInitrdPath = filepath.Join(testDir, testInitrd)
|
||||||
|
testQemuImagePath = filepath.Join(testDir, testImage)
|
||||||
|
testQemuPath = filepath.Join(testDir, testHypervisor)
|
||||||
|
|
||||||
|
fmt.Printf("INFO: Creating virtcontainers test kernel %s\n", testQemuKernelPath)
|
||||||
|
_, err = os.Create(testQemuKernelPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Could not create test kernel:", err)
|
fmt.Println("Could not create test kernel:", err)
|
||||||
os.RemoveAll(testDir)
|
os.RemoveAll(testDir)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = os.Create(filepath.Join(testDir, testImage))
|
fmt.Printf("INFO: Creating virtcontainers test image %s\n", testQemuImagePath)
|
||||||
|
_, err = os.Create(testQemuImagePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Could not create test image:", err)
|
fmt.Println("Could not create test image:", err)
|
||||||
os.RemoveAll(testDir)
|
os.RemoveAll(testDir)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = os.Create(filepath.Join(testDir, testHypervisor))
|
fmt.Printf("INFO: Creating virtcontainers test hypervisor %s\n", testQemuPath)
|
||||||
|
_, err = os.Create(testQemuPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Could not create test hypervisor:", err)
|
fmt.Println("Could not create test hypervisor:", err)
|
||||||
os.RemoveAll(testDir)
|
os.RemoveAll(testDir)
|
||||||
@ -127,11 +136,6 @@ func TestMain(m *testing.M) {
|
|||||||
sandboxFileState = filepath.Join(runStoragePath, testSandboxID, stateFile)
|
sandboxFileState = filepath.Join(runStoragePath, testSandboxID, stateFile)
|
||||||
sandboxFileLock = filepath.Join(runStoragePath, testSandboxID, lockFileName)
|
sandboxFileLock = filepath.Join(runStoragePath, testSandboxID, lockFileName)
|
||||||
|
|
||||||
testQemuKernelPath = filepath.Join(testDir, testKernel)
|
|
||||||
testQemuInitrdPath = filepath.Join(testDir, testInitrd)
|
|
||||||
testQemuImagePath = filepath.Join(testDir, testImage)
|
|
||||||
testQemuPath = filepath.Join(testDir, testHypervisor)
|
|
||||||
|
|
||||||
testHyperstartCtlSocket = filepath.Join(testDir, "test_hyper.sock")
|
testHyperstartCtlSocket = filepath.Join(testDir, "test_hyper.sock")
|
||||||
testHyperstartTtySocket = filepath.Join(testDir, "test_tty.sock")
|
testHyperstartTtySocket = filepath.Join(testDir, "test_tty.sock")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user