diff --git a/cpu/lockstorm_benchmark.py b/cpu/lockstorm_benchmark.py index c160f917f..54a7056f4 100644 --- a/cpu/lockstorm_benchmark.py +++ b/cpu/lockstorm_benchmark.py @@ -21,6 +21,10 @@ from avocado.utils.software_manager.manager import SoftwareManager +def clear_dmesg(): + process.run("dmesg -C ", sudo=True) + + class lockstorm_benchmark(Test): def setUp(self): """ @@ -61,10 +65,11 @@ def capture_dmesg_dump(self, smt_state): :param smt_state: Here we are passing the smt state that we are going to change. """ - cmd = "dmesg | tail -n 1" + cmd = "dmesg | grep 'lockstorm: spinlock iterations'" self.log.info(f"=================Dump data for \ SMT Mode: {smt_state} benchmark======================\n\n") dump_data = process.run(cmd, shell=True) + return dump_data def test(self): """ @@ -74,6 +79,8 @@ def test(self): 2.Running the lockstorm benchmark. 3. Capturing the benchmark stats. """ + lockstorm_dir = self.logdir + "/lockstorm_benc" + os.makedirs(lockstorm_dir, exist_ok=True) process.run('ppc64_cpu --cores-on=all', shell=True) process.run('ppc64_cpu --smt=on', shell=True) cpu_controller = ["2", "4", "6", "on", "off"] @@ -85,12 +92,26 @@ def test(self): process.run(cmd, shell=True) cmd = "insmod ./lockstorm.ko" + " cpulist=%s" % \ (self.cpu_list) - + clear_dmesg() if self.cpu_list == 0: cmd = "insmod ./lockstorm.ko" process.system(cmd, ignore_status=True, shell=False, sudo=True) - self.capture_dmesg_dump(smt_mode) + lockstorm_data = self.capture_dmesg_dump(smt_mode) + stdout_output = lockstorm_data.stdout + lockstorm_log = lockstorm_dir + "/lockstorm.log" + with open(lockstorm_log, "a") as payload: + payload.write( + "==================Iteration {}=============\ + \n".format(str(test_run))) + payload.write("============SMT mode: {}============= \ + \n".format(smt_mode)) + lines = stdout_output.splitlines() + for line in lines: + decoded_string = line.decode('utf-8') + cleaned_string = decoded_string.lstrip('\t') + payload.write(cleaned_string + '\n') + payload.write("\n") def tearDown(self): """