@@ -81,6 +81,14 @@ func TestMicroVMExecution(t *testing.T) {
81
81
os .Remove (metricsFifo )
82
82
}()
83
83
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
+
84
92
cfg := Config {
85
93
SocketPath : socketPath ,
86
94
LogFifo : logFifo ,
@@ -118,7 +126,7 @@ func TestMicroVMExecution(t *testing.T) {
118
126
119
127
t .Run ("TestCreateMachine" , func (t * testing.T ) { testCreateMachine (ctx , t , m ) })
120
128
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 ) })
122
130
t .Run ("TestCreateNetworkInterface" , func (t * testing.T ) { testCreateNetworkInterfaceByID (ctx , t , m ) })
123
131
t .Run ("TestAttachRootDrive" , func (t * testing.T ) { testAttachRootDrive (ctx , t , m ) })
124
132
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,
193
201
}
194
202
}
195
203
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" )
198
211
if err != nil {
199
212
t .Errorf ("failed to create boot source: %s" , err )
200
213
}
0 commit comments