Skip to content

Commit

Permalink
OpTestKernelTest: Git bisect automation for kexec boot failure
Browse files Browse the repository at this point in the history
Made changes to KernelBoot class to add git
bisect for kexec boot on warning.

Signed-off-by: Tejas Manhas <[email protected]>
  • Loading branch information
Tejas Manhas authored and Tejas Manhas committed Jul 25, 2024
1 parent 2f8dbb0 commit 39196ec
Showing 1 changed file with 78 additions and 13 deletions.
91 changes: 78 additions & 13 deletions testcases/OpTestKernelTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ def boot_kernel(self):
"""
Does kexec boot for Upstream Linux
"""
self.con.run_command("export TERM=dumb")
self.con.run_command("export NO_COLOR=1")
self.con.run_command("alias ls='ls --color=never'")
self.con.run_command("alias grep='grep --color=never'")
self.con.run_command("git config --global color.ui false")
self.con.run_command("bind 'set enable-bracketed-paste off'")
self.con.run_command("make olddefconfig")
base_version = self.con.run_command("uname -r")
ker_ver = self.con.run_command("make kernelrelease")[-1]
Expand All @@ -152,32 +158,39 @@ def boot_kernel(self):
kexec_cmdline = "kexec --initrd %s --command-line=\"%s\" /boot/vmlinu*-%s -l" % (initrd_file, cmdline, ker_ver)
self.con.run_command("grub2-mkconfig --output=/boot/grub2/grub.cfg")
self.con.run_command(kexec_cmdline)
self.con.run_command("bind 'set enable-bracketed-paste off'")
self.con.close()
self.console_thread.console_terminate()
self.cv_SYSTEM.util.build_prompt()
self.console_thread.console_terminate()
self.con.close()
time.sleep(10)
time.sleep(15)
for i in range(5):
raw_pty = self.util.wait_for(self.cv_SYSTEM.console.get_console, timeout=20)
time.sleep(10)
if raw_pty is not None:
raw_pty.sendline("uname -r")
break
raw_pty.sendline("kexec -e")
boot_log=raw_pty.before
raw_pty.expect("login:", timeout=600)
raw_pty.close()
con = self.cv_SYSTEM.cv_HOST.get_ssh_connection()
kernel_version_output = con.run_command("uname -r")[-1]
try:
raw_pty.sendline("kexec -e")
except Exception as e:
log.info(e)
rc = raw_pty.expect(["login:", "WARNING: CPU"], timeout=600)
if rc == 1:
raw_pty.close()
self.con = self.cv_SYSTEM.cv_HOST.get_ssh_connection()
dmessage = self.con.run_command("dmesg --color=never")
log.info("dmesg begin!!!")
log.info(dmessage)
log.info("dmesg end !!!")
log.info("WARNING: CPU catched")
return False
kernel_version_output = self.con.run_command("uname -r")[-1]
log.info("Installed upstream kernel version: %s", kernel_version_output[-1])
if self.conf.args.host_cmd:
con.run_command(self.conf.args.host_cmd,
self.con.run_command(self.conf.args.host_cmd,
timeout=60)
self.cv_HOST.host_gather_opal_msg_log()
self.cv_HOST.host_gather_kernel_log()
if "error" in boot_log.lower() or "warning" in boot_log.lower():
print("Error or warning detected during boot process. Exiting...")
return False
if kernel_version_output != base_version :
print("Kernel booted fine. Kernel version:", kernel_version_output.strip())
return True
Expand Down Expand Up @@ -268,7 +281,59 @@ def runTest(self):
exit_code = error[0]
if exit_code != 0:
return "Build Failure in boot, check build bisection Aborting"
self.boot_kernel()
log.info("BOOOT STARTING")
boot = False
try :
boot = self.boot_kernel()
except Exception as e:
log.info("EXCEPTION")
if not boot and self.bisect_flag == '1':
log.info("BISECTION STARTING")
subprocess.run(f"if [ -d {self.linux_path} ]; then rm -rf {self.linux_path}; fi", shell=True, check=True)
subprocess.run(f"if [ ! -d {self.linux_path} ]; then mkdir -p {self.linux_path}; fi", shell=True, check=True)
subprocess.run(f"cd {self.home}", shell=True, check=True)
subprocess.run("git config --global http.postBuffer 1048576000", shell=True, check=True)
subprocess.run(f"git clone -b {self.branch} {self.repo} {self.linux_path}" , shell=True, check=True,timeout=1800)
subprocess.run(f"cd {self.linux_path}",shell=True,check=True)
try:
subprocess.run("git bisect start", shell=True, check=True,cwd=self.linux_path)
subprocess.run("git bisect bad", shell=True, check=True,cwd=self.linux_path)
folder_type=re.split(r'[\/\\.]',str(self.repo))[-2]
if folder_type == 'linux-next':
subprocess.run("git fetch --tags" , shell=True, check=True)
good_tag=subprocess.run("git tag -l 'v[0-9]*' | sort -V | tail -n 1", shell=True, check=True)
subprocess.run(f"git bisect good {good_tag}", shell=True, check=True,cwd=self.linux_path)
else:
subprocess.run("pwd")
subprocess.run(f"git bisect good {self.good_commit}", shell=True, check=True,cwd=self.linux_path)
while True:
print("ENTERED LOOP BISECT")
subprocess.run("git bisect next", shell=True, check=True, cwd=self.linux_path)
commit_to_test = subprocess.check_output("git rev-parse HEAD", shell=True, cwd=self.linux_path).decode().strip()
log.info("commit to test is")
log.info(commit_to_test)
self.con.run_command(" if [ '$(pwd)' != {} ]; then cd {} || exit 1 ; fi ".format(self.linux_path,self.linux_path))
self.con.run_command("bind 'set enable-bracketed-paste off'")
self.con.run_command("git checkout {}".format(self.branch))
self.con.run_command("git checkout {}".format(commit_to_test))
result = self.boot_kernel()
if result == True:
print("git bisect good bi")
subprocess.run("git bisect good", shell=True, check=True,cwd=self.linux_path)
else:
print("git bisect bad bi")
subprocess.run("git bisect bad", shell=True, check=True,cwd=self.linux_path)
except subprocess.CalledProcessError as e:
log.info("Error:", e)
finally:
logi = subprocess.run("git bisect log", shell=True, check=True,cwd=self.linux_path)
log.info(logi)
subprocess.run("git bisect reset", shell=True, check=True,cwd=self.linux_path)
log.info("after git bisect reset")
elif self.bisect_flag != '1':
log.info("BOOT FAILURE, NO BISECTION")
else:
log.info("NO BISECTION NEEDED, NOT BOOT FAILURE")

def tearDown(self):
self.console_thread.console_terminate()
Expand Down

0 comments on commit 39196ec

Please sign in to comment.