From 9756afd47aa87593e382b8843337889ec7c31408 Mon Sep 17 00:00:00 2001 From: Yeoh Ee Peng Date: Wed, 1 Apr 2020 14:50:33 +0800 Subject: runtime/cyclictest: Enable cyclictest for image with rt kernel Enable cyclictest: - test execute cyclictest, retrieve the maximum latency captured inside log and compare it to the target latency - cyclictest arguments based on public cyclictest arguments used for intel corei7 https://www.osadl.org/Latency-plot-of-system-in-rack-9-slot.qa-latencyplot-r9s5.0.html?shadow=1 - set default target latency based on 24 us (captured from public cyclictest execution) multiple by 1.2 (buffer) - enable user defined target latency by configuring 'RTKERNEL_TARGET_LATENCY' as bitbake config example, inside local.conf: RTKERNEL_TARGET_LATENCY = "25" Signed-off-by: Yeoh Ee Peng Signed-off-by: Anuj Mittal --- lib/oeqa/runtime/cases/cyclictest.py | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lib/oeqa/runtime/cases/cyclictest.py (limited to 'lib/oeqa') diff --git a/lib/oeqa/runtime/cases/cyclictest.py b/lib/oeqa/runtime/cases/cyclictest.py new file mode 100644 index 00000000..8890651a --- /dev/null +++ b/lib/oeqa/runtime/cases/cyclictest.py @@ -0,0 +1,39 @@ +from oeqa.runtime.case import OERuntimeTestCase +from oeqa.core.decorator.depends import OETestDepends +from oeqa.runtime.decorator.package import OEHasPackage +import os +import subprocess +import datetime + +class CyclicTest(OERuntimeTestCase): + + @OEHasPackage(['rt-tests']) + @OETestDepends(['ssh.SSHTest.test_ssh']) + def test_cyclic(self): + # Cyclictest command and argument based on public setup for Intel(R) Core(TM) i7-6700 + # https://www.osadl.org/Latency-plot-of-system-in-rack-9-slot.qa-latencyplot-r9s5.0.html?shadow=1 + # Command line: cyclictest -l100000000 -m -Sp99 -i200 -h400 -q + status, output = self.target.run('cyclictest -l100000000 -m -Sp99 -i200 -h400') + self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output)) + test_log_dir = self.td.get('TEST_LOG_DIR', '') + + if not test_log_dir: + test_log_dir = os.path.join(self.td.get('WORKDIR', ''), 'testimage') + + cyclic_log_dir = os.path.join(test_log_dir, '%s.%s' % ('cyclic_test', datetime.datetime.now().strftime('%Y%m%d%H%M%S'))) + os.makedirs(cyclic_log_dir) + log_path = os.path.join(cyclic_log_dir, 'cyclic_log') + with open(log_path, 'w') as f: + f.write(output) + + max_latency = subprocess.check_output(('grep "Max Latencies" %s | tr " " "\n" | sort -n | tail -1 | sed s/^0*//') % log_path, shell=True).strip() + max_latency = int(max_latency) + + # Default target latency based on max latency (24us) captured at public execution multiple by 1.2 (20% buffer) + # https://www.osadl.org/Latency-plot-of-system-in-rack-9-slot.qa-latencyplot-r9s5.0.html?shadow=1 + target_latency = 1.2*24 + user_defined_target_latency = self.tc.td.get("RTKERNEL_TARGET_LATENCY") + if user_defined_target_latency: + target_latency = int(user_defined_target_latency) + self.assertTrue(max_latency < target_latency, + msg="Max latency (%sus) is greater than target (%sus)." % (max_latency, target_latency)) -- cgit v1.2.3-54-g00ecf