@@ -79,6 +79,14 @@ func TestMicroVMExecution(t *testing.T) {
79
79
os .Remove (metricsFifo )
80
80
}()
81
81
82
+ vmlinuxPath := filepath .Join (testDataPath , "./vmlinux" )
83
+ if _ , err := os .Stat (vmlinuxPath ); err != nil {
84
+ t .Fatalf ("Cannot find vmlinux file: %s\n " +
85
+ `Verify that you have a vmlinux file at "%s" or set the ` +
86
+ "`%s` environment variable to the correct location." ,
87
+ err , vmlinuxPath , testDataPathEnv )
88
+ }
89
+
82
90
cfg := Config {
83
91
SocketPath : socketPath ,
84
92
LogFifo : logFifo ,
@@ -116,7 +124,7 @@ func TestMicroVMExecution(t *testing.T) {
116
124
117
125
t .Run ("TestCreateMachine" , func (t * testing.T ) { testCreateMachine (ctx , t , m ) })
118
126
t .Run ("TestMachineConfigApplication" , func (t * testing.T ) { testMachineConfigApplication (ctx , t , m , cfg ) })
119
- t .Run ("TestCreateBootSource" , func (t * testing.T ) { testCreateBootSource (ctx , t , m ) })
127
+ t .Run ("TestCreateBootSource" , func (t * testing.T ) { testCreateBootSource (ctx , t , m , vmlinuxPath ) })
120
128
t .Run ("TestCreateNetworkInterface" , func (t * testing.T ) { testCreateNetworkInterfaceByID (ctx , t , m ) })
121
129
t .Run ("TestAttachRootDrive" , func (t * testing.T ) { testAttachRootDrive (ctx , t , m ) })
122
130
t .Run ("TestAttachSecondaryDrive" , func (t * testing.T ) { testAttachSecondaryDrive (ctx , t , m ) })
@@ -191,13 +199,13 @@ func testMachineConfigApplication(ctx context.Context, t *testing.T, m *Machine,
191
199
}
192
200
}
193
201
194
- func testCreateBootSource (ctx context.Context , t * testing.T , m * Machine ) {
202
+ func testCreateBootSource (ctx context.Context , t * testing.T , m * Machine , vmlinuxPath string ) {
195
203
// panic=0: This option disables reboot-on-panic behavior for the kernel. We
196
204
// use this option as we might run the tests without a real root
197
205
// filesystem available to the guest.
198
206
// Kernel command-line options can be found in the kernel source tree at
199
207
// Documentation/admin-guide/kernel-parameters.txt.
200
- err := m .createBootSource (ctx , filepath . Join ( testDataPath , "./vmlinux" ) , "ro console=ttyS0 noapic reboot=k panic=0 pci=off nomodules" )
208
+ err := m .createBootSource (ctx , vmlinuxPath , "ro console=ttyS0 noapic reboot=k panic=0 pci=off nomodules" )
201
209
if err != nil {
202
210
t .Errorf ("failed to create boot source: %s" , err )
203
211
}
0 commit comments