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