summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYeoh Ee Peng <ee.peng.yeoh@intel.com>2019-07-05 02:38:54 (GMT)
committerAnuj Mittal <anuj.mittal@intel.com>2019-07-08 00:24:00 (GMT)
commit0b5476b20db65468542beb03e359a4027fa924c5 (patch)
treebb68c22f6f9c281aae7a7246871299dfec186f3d
parent918789b6fdcc80a0e330ffa3db4b0f482c68f7f8 (diff)
downloadmeta-intel-0b5476b20db65468542beb03e359a4027fa924c5.tar.gz
oeqa/runtime/microcode: Enable microcode update test
With iucode-tool, identified the selected microcode to be used for microcode update by the specific processor. Compared the updated microcode from dmesg to the selected microcode, test failed if the updated microcode revision does not match the available selected microcode revision from the iucode-tool. Compute int from hexadecimal for comparison based on Naveen Kumar suggestion. Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com> Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
-rw-r--r--lib/oeqa/runtime/cases/microcode.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/oeqa/runtime/cases/microcode.py b/lib/oeqa/runtime/cases/microcode.py
new file mode 100644
index 0000000..6ce36a6
--- /dev/null
+++ b/lib/oeqa/runtime/cases/microcode.py
@@ -0,0 +1,36 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.runtime.decorator.package import OEHasPackage
3import re
4
5class MicrocodeTest(OERuntimeTestCase):
6
7 def get_revision_from_microcode_string_list(self, microcode_string_list, re_pattern):
8 re_compile = re.compile(re_pattern)
9 rev_list = []
10 for s in microcode_string_list:
11 matched_revs = re_compile.findall(s)
12 if matched_revs:
13 for mr in matched_revs:
14 rev_list.append(int(mr, 16))
15 return rev_list
16
17 @OEHasPackage(["iucode-tool"])
18 def test_microcode_update(self):
19 (status, output) = self.target.run('iucode_tool /lib/firmware/intel-ucode/ -tb -lS | grep rev')
20 if status:
21 self.skipTest("The iucode_tool detected no microcode for update.")
22
23 selected_microcodes = output.splitlines()
24 selected_rev_list = self.get_revision_from_microcode_string_list(selected_microcodes, "rev (\w*)")
25 self.assertTrue(selected_rev_list, msg="Could not find any rev from iucode_tool selected microcode.")
26
27 (status, output) = self.target.run('dmesg | grep microcode')
28 self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
29
30 updated_microcodes = output.splitlines()
31 updated_rev_list = self.get_revision_from_microcode_string_list(updated_microcodes, "revision=(\w*)")
32 self.assertTrue(updated_rev_list, msg="Could not find any updated revision from microcode dmesg.")
33
34 for ul in updated_rev_list:
35 self.assertTrue(ul in selected_rev_list, msg="Updated revision, %s, not in selected revision list (%s)" %
36 (ul, selected_rev_list))