@@ -146,6 +146,65 @@ def Store_loc(self, er) :
146
146
matches = [match .group (1 ) for match in re .finditer (pattern ,er )]
147
147
return matches
148
148
149
+ def boot_kernel (self ):
150
+ """
151
+ Does kexec boot for Upstream Linux
152
+ """
153
+ base_version = self .con .run_command ("uname -r" )
154
+ ker_ver = self .con .run_command ("make kernelrelease" )[- 1 ]
155
+ self .con .run_command ("make olddefconfig" )
156
+ cpu = self .con .run_command ("lscpu | grep '^CPU(s):' | awk '{print $2}'" )
157
+ self .con .run_command ("make -j {} all -s vmlinux" .format (cpu [- 1 ]), timeout = 60000 )
158
+ self .con .run_command ("make modules_install" )
159
+ self .con .run_command ("make install" )
160
+ if self .host_distro_name in ['rhel' , 'Red Hat' , 'ubuntu' , 'Ubuntu' ]:
161
+ self .con .run_command ('grubby --set-default /boot/vmlinu*-{}' .format (base_version [- 1 ]))
162
+ elif self .host_distro_name in ['sles' , 'SLES' ]:
163
+ self .con .run_command ('grub2-set-default /boot/vmlinu*-{}' .format (base_version [- 1 ]))
164
+ else :
165
+ raise self .skipTest ("Unsupported OS" )
166
+ cmdline = self .con .run_command ("cat /proc/cmdline" )[- 1 ]
167
+ if self .append_kernel_cmdline :
168
+ cmdline += " %s" % self .append_kernel_cmdline
169
+ try :
170
+ initrd_file = self .con .run_command ("ls -l /boot/initr*-%s.img" % ker_ver )[- 1 ].split (" " )[- 1 ]
171
+ except Exception :
172
+ initrd_file = self .con .run_command ("ls -l /boot/initr*-%s" % ker_ver )[- 1 ].split (" " )[- 1 ]
173
+ kexec_cmdline = "kexec --initrd %s --command-line=\" %s\" /boot/vmlinu*-%s -l" % (initrd_file , cmdline , ker_ver )
174
+ self .con .run_command ("grub2-mkconfig --output=/boot/grub2/grub.cfg" )
175
+ self .con .run_command (kexec_cmdline )
176
+ self .console_thread .console_terminate ()
177
+ self .cv_SYSTEM .util .build_prompt ()
178
+ self .console_thread .console_terminate ()
179
+ self .con .close ()
180
+ time .sleep (10 )
181
+ for i in range (5 ):
182
+ raw_pty = self .wait_for (self .cv_SYSTEM .console .get_console , timeout = 20 )
183
+ time .sleep (10 )
184
+ if raw_pty is not None :
185
+ raw_pty .sendline ("uname -r" )
186
+ break
187
+ raw_pty .sendline ("kexec -e" )
188
+ boot_log = raw_pty .before
189
+ raw_pty .expect ("login:" , timeout = 600 )
190
+ raw_pty .close ()
191
+ con = self .cv_SYSTEM .cv_HOST .get_ssh_connection ()
192
+ kernel_version_output = con .run_command ("uname -r" )[- 1 ]
193
+ log .info ("Installed upstream kernel version: %s" , kernel_version_output [- 1 ])
194
+ if self .conf .args .host_cmd :
195
+ con .run_command (self .conf .args .host_cmd ,
196
+ timeout = 60 )
197
+ self .cv_HOST .host_gather_opal_msg_log ()
198
+ self .cv_HOST .host_gather_kernel_log ()
199
+ if "error" in boot_log .lower () or "warning" in boot_log .lower ():
200
+ print ("Error or warning detected during boot process. Exiting..." )
201
+ return False
202
+ if kernel_version_output != base_version :
203
+ print ("Kernel booted fine. Kernel version:" , kernel_version_output .strip ())
204
+ return True
205
+ else :
206
+ return False
207
+
149
208
150
209
class KernelBuild (KernelTest ):
151
210
"""
@@ -203,3 +262,36 @@ def runTest(self):
203
262
def tearDown (self ):
204
263
self .console_thread .console_terminate ()
205
264
self .con .close ()
265
+
266
+
267
+ class KernelBoot (KernelTest ):
268
+
269
+ def setUp (self ):
270
+ """
271
+ Does setup for KernelBoot from parent KernelTest
272
+ """
273
+ super (KernelBoot ,self ).setUp ()
274
+
275
+ def runTest (self ):
276
+ """
277
+ Clones git repo and boots the kernel to check for failure and do bisection
278
+ """
279
+ self .con .run_command ("if [ -d {} ]; then rm -rf {}; fi" .format (self .home ,self .home ))
280
+ self .con .run_command ("if [ ! -d {} ]; then mkdir -p {}; fi" .format (self .home ,self .home ))
281
+ self .con .run_command ("cd {}" .format (self .home ))
282
+ if not self .branch :
283
+ self .branch = 'master'
284
+ log .info ("CD DONE" )
285
+ self .con .run_command ("git clone --depth 1 -b {} {} linux" .format ( self .branch , self .repo ),timeout = 3000 )
286
+ self .con .run_command ("cd linux" )
287
+ commit = self .con .run_command (" git log -1 --format=%H | sed -r 's/\x1B \[[0-9:]*[JKsu]//g'" )
288
+ self .con .run_command ("cd .." )
289
+ error = self .build_kernel ()
290
+ exit_code = error [0 ]
291
+ if exit_code != 0 :
292
+ return "Build Failure in boot, check build bisection Aborting"
293
+ self .boot_kernel ()
294
+
295
+ def tearDown (self ):
296
+ self .console_thread .console_terminate ()
297
+ self .con .close ()
0 commit comments