@@ -125,6 +125,65 @@ def Store_loc(self, er) :
125
125
matches = [match .group (1 ) for match in re .finditer (pattern ,er )]
126
126
return matches
127
127
128
+ def boot_kernel (self ):
129
+ """
130
+ Does kexec boot for Upstream Linux
131
+ """
132
+ self .con .run_command ("make olddefconfig" )
133
+ base_version = self .con .run_command ("uname -r" )
134
+ ker_ver = self .con .run_command ("make kernelrelease" )[- 1 ]
135
+ cpu = self .con .run_command ("lscpu | grep '^CPU(s):' | awk '{print $2}'" )
136
+ self .con .run_command ("make -j {} all -s vmlinux" .format (cpu [- 1 ]), timeout = 60000 )
137
+ self .con .run_command ("make modules_install" )
138
+ self .con .run_command ("make install" )
139
+ if self .host_distro_name in ['rhel' , 'Red Hat' , 'ubuntu' , 'Ubuntu' ]:
140
+ self .con .run_command ('grubby --set-default /boot/vmlinu*-{}' .format (base_version [- 1 ]))
141
+ elif self .host_distro_name in ['sles' , 'SLES' ]:
142
+ self .con .run_command ('grub2-set-default /boot/vmlinu*-{}' .format (base_version [- 1 ]))
143
+ else :
144
+ raise self .skipTest ("Unsupported OS" )
145
+ cmdline = self .con .run_command ("cat /proc/cmdline" )[- 1 ]
146
+ if self .append_kernel_cmdline :
147
+ cmdline += " %s" % self .append_kernel_cmdline
148
+ try :
149
+ initrd_file = self .con .run_command ("ls -l /boot/initr*-%s.img" % ker_ver )[- 1 ].split (" " )[- 1 ]
150
+ except Exception :
151
+ initrd_file = self .con .run_command ("ls -l /boot/initr*-%s" % ker_ver )[- 1 ].split (" " )[- 1 ]
152
+ kexec_cmdline = "kexec --initrd %s --command-line=\" %s\" /boot/vmlinu*-%s -l" % (initrd_file , cmdline , ker_ver )
153
+ self .con .run_command ("grub2-mkconfig --output=/boot/grub2/grub.cfg" )
154
+ self .con .run_command (kexec_cmdline )
155
+ self .console_thread .console_terminate ()
156
+ self .cv_SYSTEM .util .build_prompt ()
157
+ self .console_thread .console_terminate ()
158
+ self .con .close ()
159
+ time .sleep (10 )
160
+ for i in range (5 ):
161
+ raw_pty = self .util .wait_for (self .cv_SYSTEM .console .get_console , timeout = 20 )
162
+ time .sleep (10 )
163
+ if raw_pty is not None :
164
+ raw_pty .sendline ("uname -r" )
165
+ break
166
+ raw_pty .sendline ("kexec -e" )
167
+ boot_log = raw_pty .before
168
+ raw_pty .expect ("login:" , timeout = 600 )
169
+ raw_pty .close ()
170
+ con = self .cv_SYSTEM .cv_HOST .get_ssh_connection ()
171
+ kernel_version_output = con .run_command ("uname -r" )[- 1 ]
172
+ log .info ("Installed upstream kernel version: %s" , kernel_version_output [- 1 ])
173
+ if self .conf .args .host_cmd :
174
+ con .run_command (self .conf .args .host_cmd ,
175
+ timeout = 60 )
176
+ self .cv_HOST .host_gather_opal_msg_log ()
177
+ self .cv_HOST .host_gather_kernel_log ()
178
+ if "error" in boot_log .lower () or "warning" in boot_log .lower ():
179
+ print ("Error or warning detected during boot process. Exiting..." )
180
+ return False
181
+ if kernel_version_output != base_version :
182
+ print ("Kernel booted fine. Kernel version:" , kernel_version_output .strip ())
183
+ return True
184
+ else :
185
+ return False
186
+
128
187
129
188
class KernelBuild (KernelTest ):
130
189
"""
@@ -182,3 +241,35 @@ def runTest(self):
182
241
def tearDown (self ):
183
242
self .console_thread .console_terminate ()
184
243
self .con .close ()
244
+
245
+
246
+ class KernelBoot (KernelTest ):
247
+
248
+ def setUp (self ):
249
+ """
250
+ Does setup for KernelBoot from parent KernelTest
251
+ """
252
+ super (KernelBoot ,self ).setUp ()
253
+
254
+ def runTest (self ):
255
+ """
256
+ Clones git repo and boots the kernel to check for failure and do bisection
257
+ """
258
+ self .con .run_command ("if [ -d {} ]; then rm -rf {}; fi" .format (self .home ,self .home ))
259
+ self .con .run_command ("if [ ! -d {} ]; then mkdir -p {}; fi" .format (self .home ,self .home ))
260
+ self .con .run_command ("cd {}" .format (self .home ))
261
+ if not self .branch :
262
+ self .branch = 'master'
263
+ self .con .run_command ("git clone --depth 1 -b {} {} linux" .format ( self .branch , self .repo ),timeout = 3000 )
264
+ self .con .run_command ("cd linux" )
265
+ commit = self .con .run_command (" git log -1 --format=%H | sed -r 's/\x1B \[[0-9:]*[JKsu]//g'" )
266
+ self .con .run_command ("cd .." )
267
+ error = self .build_kernel ()
268
+ exit_code = error [0 ]
269
+ if exit_code != 0 :
270
+ return "Build Failure in boot, check build bisection Aborting"
271
+ self .boot_kernel ()
272
+
273
+ def tearDown (self ):
274
+ self .console_thread .console_terminate ()
275
+ self .con .close ()
0 commit comments