OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Unit tests for telemetry.py. | 6 """Unit tests for telemetry.py. |
7 | 7 |
8 This is a basic check that telemetry.py forms commands properly. | 8 This is a basic check that telemetry.py forms commands properly. |
9 | 9 |
10 """ | 10 """ |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 def FilterDone(self, text): | 41 def FilterDone(self, text): |
42 self.text.append(text) | 42 self.text.append(text) |
43 | 43 |
44 class TelemetryTest(unittest.TestCase): | 44 class TelemetryTest(unittest.TestCase): |
45 """Holds tests for telemetry script.""" | 45 """Holds tests for telemetry script.""" |
46 | 46 |
47 @staticmethod | 47 @staticmethod |
48 def _GetDefaultFactoryProperties(): | 48 def _GetDefaultFactoryProperties(): |
49 fp = {} | 49 fp = {} |
50 fp['build_dir'] = 'src/build' | 50 fp['build_dir'] = 'src/out' |
51 fp['test_name'] = 'sunspider' | 51 fp['test_name'] = 'sunspider' |
52 fp['target'] = 'Release' | 52 fp['target'] = 'Release' |
53 fp['target_os'] = 'android' | 53 fp['target_os'] = 'android' |
54 fp['target_platform'] = 'linux2' | 54 fp['target_platform'] = 'linux2' |
55 fp['step_name'] = 'sunspider' | 55 fp['step_name'] = 'sunspider' |
56 fp['show_perf_results'] = True | 56 fp['show_perf_results'] = True |
57 fp['perf_id'] = 'android-gn' | 57 fp['perf_id'] = 'android-gn' |
58 return fp | 58 return fp |
59 | 59 |
60 def setUp(self): | 60 def setUp(self): |
(...skipping 10 matching lines...) Expand all Loading... |
71 | 71 |
72 ret = runScript(cmd, filter_obj=self.capture, print_cmd=False) | 72 ret = runScript(cmd, filter_obj=self.capture, print_cmd=False) |
73 self.assertEqual(ret, 0) | 73 self.assertEqual(ret, 0) |
74 | 74 |
75 runtest = os.path.abspath(os.path.join(SCRIPT_DIR, '..', 'runtest.py')) | 75 runtest = os.path.abspath(os.path.join(SCRIPT_DIR, '..', 'runtest.py')) |
76 | 76 |
77 expectedText = (['\'adb\' \'root\'', | 77 expectedText = (['\'adb\' \'root\'', |
78 '\'adb\' \'wait-for-device\'', | 78 '\'adb\' \'wait-for-device\'', |
79 '\'%s\' ' % sys.executable + | 79 '\'%s\' ' % sys.executable + |
80 '\'%s\' \'--run-python-script\' \'--target\' \'Release\' ' % runtest + | 80 '\'%s\' \'--run-python-script\' \'--target\' \'Release\' ' % runtest + |
81 '\'--build-dir\' \'src/build\' \'--no-xvfb\' ' + | 81 '\'--build-dir\' \'src/out\' \'--no-xvfb\' ' + |
82 '\'--factory-properties=' + | 82 '\'--factory-properties=' + |
83 '{"target": "Release", ' + | 83 '{"target": "Release", ' + |
84 '"build_dir": "src/build", "perf_id": "android-gn", ' + | 84 '"build_dir": "src/out", "perf_id": "android-gn", ' + |
85 '"step_name": "sunspider", "test_name": "sunspider", ' + | 85 '"step_name": "sunspider", "test_name": "sunspider", ' + |
86 '"target_platform": "linux2", "target_os": "android", ' + | 86 '"target_platform": "linux2", "target_os": "android", ' + |
87 '"show_perf_results": true}\' ' + | 87 '"show_perf_results": true}\' ' + |
88 '\'src/tools/perf/run_benchmark\' \'-v\' ' + | 88 '\'src/tools/perf/run_benchmark\' \'-v\' ' + |
89 '\'--output-format=buildbot\' ' + | 89 '\'--output-format=buildbot\' ' + |
90 '\'--browser=android-chromium-testshell\' \'sunspider\'' | 90 '\'--browser=android-chromium-testshell\' \'sunspider\'' |
91 ]) | 91 ]) |
92 | 92 |
93 self.assertEqual(expectedText, self.capture.text) | 93 self.assertEqual(expectedText, self.capture.text) |
94 | 94 |
95 def testExtraArg(self): | 95 def testExtraArg(self): |
96 fp = self._GetDefaultFactoryProperties() | 96 fp = self._GetDefaultFactoryProperties() |
97 fp['extra_args'] = ['--profile-dir=fake_dir'] | 97 fp['extra_args'] = ['--profile-dir=fake_dir'] |
98 | 98 |
99 cmd = [self.telemetry, '--print-cmd', | 99 cmd = [self.telemetry, '--print-cmd', |
100 '--factory-properties=%s' % json.dumps(fp)] | 100 '--factory-properties=%s' % json.dumps(fp)] |
101 | 101 |
102 ret = runScript(cmd, filter_obj=self.capture, print_cmd=False) | 102 ret = runScript(cmd, filter_obj=self.capture, print_cmd=False) |
103 self.assertEqual(ret, 0) | 103 self.assertEqual(ret, 0) |
104 | 104 |
105 runtest = os.path.abspath(os.path.join(SCRIPT_DIR, '..', 'runtest.py')) | 105 runtest = os.path.abspath(os.path.join(SCRIPT_DIR, '..', 'runtest.py')) |
106 | 106 |
107 expectedText = (['\'adb\' \'root\'', | 107 expectedText = (['\'adb\' \'root\'', |
108 '\'adb\' \'wait-for-device\'', | 108 '\'adb\' \'wait-for-device\'', |
109 '\'%s\' ' % sys.executable + | 109 '\'%s\' ' % sys.executable + |
110 '\'%s\' \'--run-python-script\' \'--target\' \'Release\' ' % runtest + | 110 '\'%s\' \'--run-python-script\' \'--target\' \'Release\' ' % runtest + |
111 '\'--build-dir\' \'src/build\' \'--no-xvfb\' ' + | 111 '\'--build-dir\' \'src/out\' \'--no-xvfb\' ' + |
112 '\'--factory-properties=' + | 112 '\'--factory-properties=' + |
113 '{"target": "Release", "build_dir": "src/build", ' + | 113 '{"target": "Release", "build_dir": "src/out", ' + |
114 '"extra_args": ["--profile-dir=fake_dir"], ' + | 114 '"extra_args": ["--profile-dir=fake_dir"], ' + |
115 '"perf_id": "android-gn", ' + | 115 '"perf_id": "android-gn", ' + |
116 '"step_name": "sunspider", "test_name": "sunspider", ' + | 116 '"step_name": "sunspider", "test_name": "sunspider", ' + |
117 '"target_platform": "linux2", "target_os": "android", ' + | 117 '"target_platform": "linux2", "target_os": "android", ' + |
118 '"show_perf_results": true}\' ' + | 118 '"show_perf_results": true}\' ' + |
119 '\'src/tools/perf/run_benchmark\' \'-v\' ' + | 119 '\'src/tools/perf/run_benchmark\' \'-v\' ' + |
120 '\'--output-format=buildbot\' ' + | 120 '\'--output-format=buildbot\' ' + |
121 '\'--profile-dir=fake_dir\' '+ | 121 '\'--profile-dir=fake_dir\' '+ |
122 '\'--browser=android-chromium-testshell\' \'sunspider\'' | 122 '\'--browser=android-chromium-testshell\' \'sunspider\'' |
123 ]) | 123 ]) |
124 | 124 |
125 self.assertEqual(expectedText, self.capture.text) | 125 self.assertEqual(expectedText, self.capture.text) |
126 | 126 |
127 if __name__ == '__main__': | 127 if __name__ == '__main__': |
128 unittest.main() | 128 unittest.main() |
OLD | NEW |