blob: 8ca650c83b83ddbd721e59469f42fb128f2d908c [file] [log] [blame]
Yunlian Jiang11313592013-05-21 11:29:50 -07001#!/usr/bin/python
2
3# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""Testing of ResultsOrganizer. We create some labels, benchmark_runs
8 and then create a ResultsOrganizer, after that, we compare the result of
9 ResultOrganizer"""
10
11import unittest
12
13from benchmark_run import BenchmarkRun
14from results_cache import Result
15from results_organizer import ResultOrganizer
16
17import mock_instance
18
19result = {'benchmark1': [[{'': 'PASS',
20 'bool': 'True',
21 'milliseconds_1': '1',
22 'milliseconds_2': '8',
23 'milliseconds_3': '9.2',
24 'ms_1': '2.1',
25 'total': '5'},
26 {'test': '2'},
27 {'test': '4'},
28 {'': 'PASS',
29 'bool': 'FALSE',
30 'milliseconds_1': '3',
31 'milliseconds_2': '5',
32 'ms_1': '2.2',
33 'total': '6'},
34 {'test': '3'},
35 {'test': '4'}],
36 [{'': 'PASS',
37 'bool': 'FALSE',
38 'milliseconds_4': '30',
39 'milliseconds_5': '50',
40 'ms_1': '2.23',
41 'total': '6'},
42 {'test': '5'},
43 {'test': '4'},
44 {'': 'PASS',
45 'bool': 'FALSE',
46 'milliseconds_1': '3',
47 'milliseconds_6': '7',
48 'ms_1': '2.3',
49 'total': '7'},
50 {'test': '2'},
51 {'test': '6'}]],
52 'benchmark2': [[{'': 'PASS',
53 'bool': 'TRUE',
54 'milliseconds_1': '3',
55 'milliseconds_8': '6',
56 'ms_1': '2.3',
57 'total': '7'},
58 {'test': '2'},
59 {'test': '6'},
60 {'': 'PASS',
61 'bool': 'TRUE',
62 'milliseconds_1': '3',
63 'milliseconds_8': '6',
64 'ms_1': '2.2',
65 'total': '7'},
66 {'test': '2'},
67 {'test': '2'}],
68 [{'': 'PASS',
69 'bool': 'TRUE',
70 'milliseconds_1': '3',
71 'milliseconds_8': '6',
72 'ms_1': '2',
73 'total': '7'},
74 {'test': '2'},
75 {'test': '4'},
76 {'': 'PASS',
77 'bool': 'TRUE',
78 'milliseconds_1': '3',
79 'milliseconds_8': '6',
80 'ms_1': '1',
81 'total': '7'},
82 {'test': '1'},
83 {'test': '6'}]]}
84
85class ResultOrganizerTest(unittest.TestCase):
86 def testResultOrganizer(self):
87 labels = [mock_instance.label1, mock_instance.label2]
88 benchmarks = [mock_instance.benchmark1, mock_instance.benchmark2]
89 benchmark_runs = [None]*8
90 benchmark_runs[0] = BenchmarkRun("b1", benchmarks[0],
91 labels[0], 1, "", "", "", "")
92 benchmark_runs[1] = BenchmarkRun("b2", benchmarks[0],
93 labels[0], 2, "", "", "", "")
94 benchmark_runs[2] = BenchmarkRun("b3", benchmarks[0],
95 labels[1], 1, "", "", "", "")
96 benchmark_runs[3] = BenchmarkRun("b4", benchmarks[0],
97 labels[1], 2, "", "", "", "")
98 benchmark_runs[4] = BenchmarkRun("b5", benchmarks[1],
99 labels[0], 1, "", "", "", "")
100 benchmark_runs[5] = BenchmarkRun("b6", benchmarks[1],
101 labels[0], 2, "", "", "", "")
102 benchmark_runs[6] = BenchmarkRun("b7", benchmarks[1],
103 labels[1], 1, "", "", "", "")
104 benchmark_runs[7] = BenchmarkRun("b8", benchmarks[1],
105 labels[1], 2, "", "", "", "")
106
107 i = 0
108 for b in benchmark_runs:
109 b.result = Result(b.label.chromeos_root, "", b.label.name)
110 b.result.keyvals = mock_instance.keyval[i]
111 i += 1
112
113 ro = ResultOrganizer(benchmark_runs, labels, benchmarks)
114 self.assertEqual(ro.result, result)
115
116if __name__ == "__main__":
117 unittest.main()