Skip to content

Commit 95a55aa

Browse files
author
Sachin P Bappalige
committed
Add softlockup scenario for kdump/Fadump testing
KernelCrash_KdumpSoftlockup testcase use source files(softlockup.c and Makefile).These files added to op-tests framework's directory "op-test/test_binaries". This testcase activates the kernel panic on soft lockup and copy softlockup.c and Makefile to /tmp directory to build kernel module. The command insmod used to insert generated kernel module(softlockup.ko) into the kernel and verify the dump file created after kernel panic on soft lockup. Signed-off-by: Sachin P Bappalige <[email protected]>
1 parent 7e75b5a commit 95a55aa

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

test_binaries/Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
obj-m += softlockup.o
2+
3+
all:
4+
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
5+
6+
clean:
7+
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

test_binaries/softlockup.c

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <linux/init.h>
2+
#include <linux/kernel.h>
3+
#include <linux/module.h>
4+
#include <linux/spinlock.h>
5+
6+
MODULE_LICENSE("GPL");
7+
MODULE_AUTHOR("LIKHITHA");
8+
MODULE_DESCRIPTION("Kernel Module for softlockups");
9+
10+
static spinlock_t my_lock;
11+
12+
int a;
13+
14+
static int __init my_init(void)
15+
{
16+
spin_lock_init(&my_lock);
17+
printk(KERN_INFO "softlockup module: Initialized spinlock\n");
18+
19+
/* Perform critical section operations */
20+
spin_lock(&my_lock);
21+
while (1) {
22+
a+=1;
23+
}
24+
spin_unlock(&my_lock);
25+
26+
return 0;
27+
}
28+
29+
static void __exit my_exit(void)
30+
{
31+
printk(KERN_INFO "Exiting module\n");
32+
}
33+
34+
module_init(my_init);
35+
module_exit(my_exit);

testcases/PowerNVDump.py

+26
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ def kernel_crash(self, crash_type="echo_c"):
370370
elif crash_type == "hmc":
371371
self.cv_HMC.run_command("chsysstate -r lpar -m %s -n %s -o dumprestart" %
372372
(self.system_name, self.lpar_name), timeout=300)
373+
elif crash_type == "softlockup":
374+
self.c.pty.sendline("insmod /tmp/softlockup.ko")
373375
done = False
374376
boot_type = BootType.NORMAL
375377
rc = -1
@@ -1323,6 +1325,29 @@ def runTest(self):
13231325
if not obj.update_kernel_cmdline(self.distro, remove_args="fadump=nocma", reboot=True, reboot_cmd=True):
13241326
self.fail("KernelArgTest failed to update kernel args")
13251327

1328+
class KernelCrash_KdumpSoftlockup(PowerNVDump):
1329+
1330+
'''
1331+
This test verifies kdump/fadump after inserting softlockup kernel module.
1332+
'''
1333+
1334+
def runTest(self):
1335+
self.setup_test()
1336+
# Make sure softlockup related file does not exist
1337+
self.c.run_command("cd /tmp; ls -1; rm -rf soft* Makefile", timeout=60)
1338+
1339+
#copy the source files from test_binaries to /tmp
1340+
self.cv_HOST.copy_test_file_to_host("softlockup.c")
1341+
self.cv_HOST.copy_test_file_to_host("Makefile")
1342+
1343+
#compile source files to get kernel modules
1344+
self.c.run_command("cd /tmp; make", timeout=60)
1345+
1346+
#Enable softlockup
1347+
self.c.run_command("sysctl -w kernel.softlockup_panic=1")
1348+
1349+
boot_type = self.kernel_crash(crash_type="softlockup")
1350+
self.verify_dump_file(boot_type)
13261351

13271352
def crash_suite():
13281353
s = unittest.TestSuite()
@@ -1354,5 +1379,6 @@ def crash_suite():
13541379
s.addTest(KernelCrash_DisableAll())
13551380
s.addTest(SkirootKernelCrash())
13561381
s.addTest(OPALCrash_MPIPL())
1382+
s.addTest(KernelCrash_KdumpSoftlockup())
13571383

13581384
return s

0 commit comments

Comments
 (0)