blob: c2e76f1a4409c9adcbc8fa382348a600e5d98147 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: MIT
5#
6
Brad Bishop40320b12019-03-26 16:08:25 -04007import os
8import sys
9basepath = os.path.abspath(os.path.dirname(__file__) + '/../../../../../')
10lib_path = basepath + '/scripts/lib'
11sys.path = sys.path + [lib_path]
12from resulttool.report import ResultsTextReport
13from resulttool import regression as regression
14from resulttool import resultutils as resultutils
15from oeqa.selftest.case import OESelftestTestCase
16
17class ResultToolTests(OESelftestTestCase):
18 base_results_data = {'base_result1': {'configuration': {"TEST_TYPE": "runtime",
19 "TESTSERIES": "series1",
20 "IMAGE_BASENAME": "image",
21 "IMAGE_PKGTYPE": "ipk",
22 "DISTRO": "mydistro",
23 "MACHINE": "qemux86"},
24 'result': {}},
25 'base_result2': {'configuration': {"TEST_TYPE": "runtime",
26 "TESTSERIES": "series1",
27 "IMAGE_BASENAME": "image",
28 "IMAGE_PKGTYPE": "ipk",
29 "DISTRO": "mydistro",
30 "MACHINE": "qemux86-64"},
31 'result': {}}}
32 target_results_data = {'target_result1': {'configuration': {"TEST_TYPE": "runtime",
33 "TESTSERIES": "series1",
34 "IMAGE_BASENAME": "image",
35 "IMAGE_PKGTYPE": "ipk",
36 "DISTRO": "mydistro",
37 "MACHINE": "qemux86"},
38 'result': {}},
39 'target_result2': {'configuration': {"TEST_TYPE": "runtime",
40 "TESTSERIES": "series1",
41 "IMAGE_BASENAME": "image",
42 "IMAGE_PKGTYPE": "ipk",
43 "DISTRO": "mydistro",
44 "MACHINE": "qemux86"},
45 'result': {}},
46 'target_result3': {'configuration': {"TEST_TYPE": "runtime",
47 "TESTSERIES": "series1",
48 "IMAGE_BASENAME": "image",
49 "IMAGE_PKGTYPE": "ipk",
50 "DISTRO": "mydistro",
51 "MACHINE": "qemux86-64"},
52 'result': {}}}
53
54 def test_report_can_aggregate_test_result(self):
55 result_data = {'result': {'test1': {'status': 'PASSED'},
56 'test2': {'status': 'PASSED'},
57 'test3': {'status': 'FAILED'},
58 'test4': {'status': 'ERROR'},
59 'test5': {'status': 'SKIPPED'}}}
60 report = ResultsTextReport()
Brad Bishop15ae2502019-06-18 21:44:24 -040061 result_report = report.get_aggregated_test_result(None, result_data, 'DummyMachine')
Brad Bishop40320b12019-03-26 16:08:25 -040062 self.assertTrue(result_report['passed'] == 2, msg="Passed count not correct:%s" % result_report['passed'])
63 self.assertTrue(result_report['failed'] == 2, msg="Failed count not correct:%s" % result_report['failed'])
64 self.assertTrue(result_report['skipped'] == 1, msg="Skipped count not correct:%s" % result_report['skipped'])
65
66 def test_regression_can_get_regression_base_target_pair(self):
67
68 results = {}
69 resultutils.append_resultsdata(results, ResultToolTests.base_results_data)
70 resultutils.append_resultsdata(results, ResultToolTests.target_results_data)
71 self.assertTrue('target_result1' in results['runtime/mydistro/qemux86/image'], msg="Pair not correct:%s" % results)
72 self.assertTrue('target_result3' in results['runtime/mydistro/qemux86-64/image'], msg="Pair not correct:%s" % results)
73
74 def test_regrresion_can_get_regression_result(self):
75 base_result_data = {'result': {'test1': {'status': 'PASSED'},
76 'test2': {'status': 'PASSED'},
77 'test3': {'status': 'FAILED'},
78 'test4': {'status': 'ERROR'},
79 'test5': {'status': 'SKIPPED'}}}
80 target_result_data = {'result': {'test1': {'status': 'PASSED'},
81 'test2': {'status': 'FAILED'},
82 'test3': {'status': 'PASSED'},
83 'test4': {'status': 'ERROR'},
84 'test5': {'status': 'SKIPPED'}}}
85 result, text = regression.compare_result(self.logger, "BaseTestRunName", "TargetTestRunName", base_result_data, target_result_data)
86 self.assertTrue(result['test2']['base'] == 'PASSED',
87 msg="regression not correct:%s" % result['test2']['base'])
88 self.assertTrue(result['test2']['target'] == 'FAILED',
89 msg="regression not correct:%s" % result['test2']['target'])
90 self.assertTrue(result['test3']['base'] == 'FAILED',
91 msg="regression not correct:%s" % result['test3']['base'])
92 self.assertTrue(result['test3']['target'] == 'PASSED',
93 msg="regression not correct:%s" % result['test3']['target'])
94
95 def test_merge_can_merged_results(self):
96 results = {}
97 resultutils.append_resultsdata(results, ResultToolTests.base_results_data, configmap=resultutils.flatten_map)
98 resultutils.append_resultsdata(results, ResultToolTests.target_results_data, configmap=resultutils.flatten_map)
99 self.assertEqual(len(results[''].keys()), 5, msg="Flattened results not correct %s" % str(results))
100