All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] oeqa/cpu_utilization_test : add test for cpu utilization after standby state
@ 2021-01-11  1:21 Teoh, Jay Shen
  0 siblings, 0 replies; only message in thread
From: Teoh, Jay Shen @ 2021-01-11  1:21 UTC (permalink / raw)
  To: openembedded-core

From: Teoh Jay Shen <jay.shen.teoh@intel.com>

This test is checking the cpu utilization before and after standby state. The check_CPU_utilization_after_standby manual test case from oeqa/manual/bsp-hw can be replace by this runtime test.

Signed-off-by: Teoh Jay Shen <jay.shen.teoh@intel.com>
---
 .../lib/oeqa/runtime/cases/cpu_utilization_test.py | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 meta/lib/oeqa/runtime/cases/cpu_utilization_test.py

diff --git a/meta/lib/oeqa/runtime/cases/cpu_utilization_test.py b/meta/lib/oeqa/runtime/cases/cpu_utilization_test.py
new file mode 100644
index 0000000..a44b4ec
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/cpu_utilization_test.py
@@ -0,0 +1,23 @@
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.core.decorator.data import skipIfQemu
+
+
+class CPU_utilization_test(OERuntimeTestCase):
+      
+    def set_standby(self): 
+        (status, output) = self.target.run('rtcwake -m mem -s 10')
+        self.assertEqual(status, 0,  msg = 'Failed to set your system into standby mode, output : %s' % output)
+    
+    @skipIfQemu('qemuall', 'Test only runs on real hardware')
+    @OETestDepends(['ssh.SSHTest.test_ssh'])
+    def test_CPU_utilization_after_standby(self):
+        (status, cpu_usage_before_standby) = self.target.run("export TERM=xterm && top -b -n2 | grep 'Cpu(s)' | tail -n 1 | awk '{print $2 + $6}'")
+        self.assertEqual(status, 0,  msg = 'Failed to run the top command, output : %s' % cpu_usage_before_standby)
+        self.set_standby()
+        (status, cpu_usage_after_standby) = self.target.run("export TERM=xterm && top -b -n2 | grep 'Cpu(s)' | tail -n 1 | awk '{print $2 + $6}'")
+        self.assertEqual(status, 0,  msg = 'Failed to run the top command, output : %s' % cpu_usage_after_standby)
+        cpu_usage_before_standby = int(float(cpu_usage_before_standby))
+        cpu_usage_after_standby = int(float(cpu_usage_after_standby))
+        cpu_usage_comparison = ((cpu_usage_before_standby - 5) <= cpu_usage_after_standby <= (cpu_usage_before_standby + 5))
+        self.assertTrue(cpu_usage_comparison, msg='There should be no big difference in the cpu utilization before/after standby, cpu usage before standby : % s, cpu usage after standby : % s' % (cpu_usage_before_standby , cpu_usage_after_standby))
-- 
2.7.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-11  1:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11  1:21 [PATCH] oeqa/cpu_utilization_test : add test for cpu utilization after standby state Teoh, Jay Shen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.