OLD | NEW |
(Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """Tests for the logic that drives runs of the benchmarking mojo app and parses |
| 6 its output.""" |
| 7 |
| 8 import imp |
| 9 import os.path |
| 10 import sys |
| 11 import unittest |
| 12 |
| 13 try: |
| 14 imp.find_module("devtoolslib") |
| 15 except ImportError: |
| 16 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 17 |
| 18 from devtoolslib import benchmark |
| 19 |
| 20 |
| 21 class BenchmarkTest(unittest.TestCase): |
| 22 """Tests the benchmark module.""" |
| 23 |
| 24 def test_parse_measurement_results_empty(self): |
| 25 """Tests parsing empty output.""" |
| 26 output = """""" |
| 27 results = benchmark._parse_measurement_results(output) |
| 28 self.assertEquals({}, results) |
| 29 |
| 30 def test_parse_measurement_results_typical(self): |
| 31 """Tests parsing typical output with unrelated log entries.""" |
| 32 output = """ |
| 33 [INFO:network_fetcher.cc(322)] Caching mojo app http://127.0.0.1:31839/benchmark
.mojo at /usr/local/google/home/user/.mojo_url_response_disk_cache/cache/4F6FAE7
52C7958AE122C6A2D778F2014C15578250B3C6746D54B99E4F15A4458/4F6FAE752C7958AE122C6A
2D778F2014C15578250B3C6746D54B99E4F15A4458 |
| 34 [INFO:network_fetcher.cc(322)] Caching mojo app http://127.0.0.1:31839/dart_trac
ed_application.mojo at /usr/local/google/home/user/.mojo_url_response_disk_cache
/cache/AB290478907A1DC5434CBCFD053BE2E74254D882644E76B3C28E3E7E1BCDCC3D/AB290478
907A1DC5434CBCFD053BE2E74254D882644E76B3C28E3E7E1BCDCC3D |
| 35 Observatory listening on http://127.0.0.1:38128 |
| 36 [1109/155613:WARNING:event.cc(234)] Ignoring incorrect complete event (no durati
on) |
| 37 measurement: time_until/a/b 42.5 |
| 38 measurement: time_between/a/b/c/d 21.1 |
| 39 measurement: time_between/a/b/e/f FAILED |
| 40 some measurements failed |
| 41 """ |
| 42 results = benchmark._parse_measurement_results(output) |
| 43 self.assertEquals({'time_until/a/b': 42.5, |
| 44 'time_between/a/b/c/d': 21.1}, results) |
OLD | NEW |