Skip to content

Commit 0ee20d3

Browse files
committed
Merge remote-tracking branch 'origin/pr/31'
2 parents c021f09 + a441b94 commit 0ee20d3

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

machine_test.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ func TestMicroVMExecution(t *testing.T) {
8181
os.Remove(metricsFifo)
8282
}()
8383

84+
vmlinuxPath := filepath.Join(testDataPath, "./vmlinux")
85+
if _, err := os.Stat(vmlinuxPath); err != nil {
86+
t.Fatalf("Cannot find vmlinux file: %s\n"+
87+
`Verify that you have a vmlinux file at "%s" or set the `+
88+
"`%s` environment variable to the correct location.",
89+
err, vmlinuxPath, testDataPathEnv)
90+
}
91+
8492
cfg := Config{
8593
SocketPath: socketPath,
8694
LogFifo: logFifo,
@@ -118,7 +126,7 @@ func TestMicroVMExecution(t *testing.T) {
118126

119127
t.Run("TestCreateMachine", func(t *testing.T) { testCreateMachine(ctx, t, m) })
120128
t.Run("TestMachineConfigApplication", func(t *testing.T) { testMachineConfigApplication(ctx, t, m, cfg) })
121-
t.Run("TestCreateBootSource", func(t *testing.T) { testCreateBootSource(ctx, t, m) })
129+
t.Run("TestCreateBootSource", func(t *testing.T) { testCreateBootSource(ctx, t, m, vmlinuxPath) })
122130
t.Run("TestCreateNetworkInterface", func(t *testing.T) { testCreateNetworkInterfaceByID(ctx, t, m) })
123131
t.Run("TestAttachRootDrive", func(t *testing.T) { testAttachRootDrive(ctx, t, m) })
124132
t.Run("TestAttachSecondaryDrive", func(t *testing.T) { testAttachSecondaryDrive(ctx, t, m) })
@@ -193,8 +201,13 @@ func testMachineConfigApplication(ctx context.Context, t *testing.T, m *Machine,
193201
}
194202
}
195203

196-
func testCreateBootSource(ctx context.Context, t *testing.T, m *Machine) {
197-
err := m.createBootSource(ctx, filepath.Join(testDataPath, "./vmlinux"), "ro console=ttyS0 noapic reboot=k panic=1 pci=off nomodules")
204+
func testCreateBootSource(ctx context.Context, t *testing.T, m *Machine, vmlinuxPath string) {
205+
// panic=0: This option disables reboot-on-panic behavior for the kernel. We
206+
// use this option as we might run the tests without a real root
207+
// filesystem available to the guest.
208+
// Kernel command-line options can be found in the kernel source tree at
209+
// Documentation/admin-guide/kernel-parameters.txt.
210+
err := m.createBootSource(ctx, vmlinuxPath, "ro console=ttyS0 noapic reboot=k panic=0 pci=off nomodules")
198211
if err != nil {
199212
t.Errorf("failed to create boot source: %s", err)
200213
}

0 commit comments

Comments
 (0)