run_perf_test.py 20.4 KB
Newer Older
1 2 3 4 5
#!/usr/bin/env python
# Copyright 2014 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

6 7 8
# for py2/py3 compatibility
from __future__ import print_function

9 10 11
from collections import namedtuple
import coverage
import json
12
from mock import MagicMock, patch
13 14
import os
from os import path, sys
15
import platform
16
import shutil
17
import subprocess
18 19 20 21 22 23
import tempfile
import unittest

# Requires python-coverage and python-mock. Native python coverage
# version >= 3.7.1 should be installed to get the best speed.

24 25 26 27
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
RUN_PERF = os.path.join(BASE_DIR, 'run_perf.py')
TEST_DATA = os.path.join(BASE_DIR, 'unittests', 'testdata')

28 29 30 31
TEST_WORKSPACE = path.join(tempfile.gettempdir(), "test-v8-run-perf")

V8_JSON = {
  "path": ["."],
32
  "owners": ["username@chromium.org"],
33 34 35 36 37 38 39 40 41 42 43 44 45
  "binary": "d7",
  "flags": ["--flag"],
  "main": "run.js",
  "run_count": 1,
  "results_regexp": "^%s: (.+)$",
  "tests": [
    {"name": "Richards"},
    {"name": "DeltaBlue"},
  ]
}

V8_NESTED_SUITES_JSON = {
  "path": ["."],
46
  "owners": ["username@chromium.org"],
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
  "flags": ["--flag"],
  "run_count": 1,
  "units": "score",
  "tests": [
    {"name": "Richards",
     "path": ["richards"],
     "binary": "d7",
     "main": "run.js",
     "resources": ["file1.js", "file2.js"],
     "run_count": 2,
     "results_regexp": "^Richards: (.+)$"},
    {"name": "Sub",
     "path": ["sub"],
     "tests": [
       {"name": "Leaf",
        "path": ["leaf"],
        "run_count_x64": 3,
        "units": "ms",
        "main": "run.js",
        "results_regexp": "^Simple: (.+) ms.$"},
     ]
    },
    {"name": "DeltaBlue",
     "path": ["delta_blue"],
     "main": "run.js",
     "flags": ["--flag2"],
     "results_regexp": "^DeltaBlue: (.+)$"},
    {"name": "ShouldntRun",
     "path": ["."],
     "archs": ["arm"],
     "main": "run.js"},
  ]
}

V8_GENERIC_JSON = {
  "path": ["."],
83
  "owners": ["username@chromium.org"],
84 85 86 87 88 89 90
  "binary": "cc",
  "flags": ["--flag"],
  "generic": True,
  "run_count": 1,
  "units": "ms",
}

91
Output = namedtuple("Output", "stdout, stderr, timed_out, exit_code")
92 93 94 95 96 97 98 99 100 101

class PerfTest(unittest.TestCase):
  @classmethod
  def setUpClass(cls):
    cls.base = path.dirname(path.dirname(path.abspath(__file__)))
    sys.path.append(cls.base)
    cls._cov = coverage.coverage(
        include=([os.path.join(cls.base, "run_perf.py")]))
    cls._cov.start()
    import run_perf
102 103
    from testrunner.local import command
    global command
104 105 106 107 108
    global run_perf

  @classmethod
  def tearDownClass(cls):
    cls._cov.stop()
109 110
    print("")
    print(cls._cov.report())
111 112 113 114 115 116 117 118

  def setUp(self):
    self.maxDiff = None
    if path.exists(TEST_WORKSPACE):
      shutil.rmtree(TEST_WORKSPACE)
    os.makedirs(TEST_WORKSPACE)

  def tearDown(self):
119
    patch.stopall()
120 121 122 123 124 125 126 127
    if path.exists(TEST_WORKSPACE):
      shutil.rmtree(TEST_WORKSPACE)

  def _WriteTestInput(self, json_content):
    self._test_input = path.join(TEST_WORKSPACE, "test.json")
    with open(self._test_input, "w") as f:
      f.write(json.dumps(json_content))

128
  def _MockCommand(self, *args, **kwargs):
129
    # Fake output for each test run.
130 131
    test_outputs = [Output(stdout=arg,
                           stderr=None,
132 133
                           timed_out=kwargs.get("timed_out", False),
                           exit_code=kwargs.get("exit_code", 0))
134
                    for arg in args[1]]
135 136 137 138 139 140 141
    def create_cmd(*args, **kwargs):
      cmd = MagicMock()
      def execute(*args, **kwargs):
        return test_outputs.pop()
      cmd.execute = MagicMock(side_effect=execute)
      return cmd

142 143 144
    patch.object(
        run_perf.command, 'PosixCommand',
        MagicMock(side_effect=create_cmd)).start()
145 146 147 148 149 150 151

    # Check that d8 is called from the correct cwd for each test run.
    dirs = [path.join(TEST_WORKSPACE, arg) for arg in args[0]]
    def chdir(*args, **kwargs):
      self.assertEquals(dirs.pop(), args[0])
    os.chdir = MagicMock(side_effect=chdir)

152 153 154
    subprocess.check_call = MagicMock()
    platform.system = MagicMock(return_value='Linux')

155 156 157 158 159 160 161 162 163 164
  def _CallMain(self, *args):
    self._test_output = path.join(TEST_WORKSPACE, "results.json")
    all_args=[
      "--json-test-results",
      self._test_output,
      self._test_input,
    ]
    all_args += args
    return run_perf.Main(all_args)

165 166
  def _LoadResults(self, file_name=None):
    with open(file_name or self._test_output) as f:
167 168
      return json.load(f)

169
  def _VerifyResults(self, suite, units, traces, file_name=None):
170 171 172 173 174
    self.assertEquals([
      {"units": units,
       "graphs": [suite, trace["name"]],
       "results": trace["results"],
       "stddev": trace["stddev"]} for trace in traces],
175
      self._LoadResults(file_name)["traces"])
176 177 178 179

  def _VerifyErrors(self, errors):
    self.assertEquals(errors, self._LoadResults()["errors"])

180
  def _VerifyMock(self, binary, *args, **kwargs):
181 182 183 184 185 186
    shell = path.join(path.dirname(self.base), binary)
    command.Command.assert_called_with(
        cmd_prefix=[],
        shell=shell,
        args=list(args),
        timeout=kwargs.get('timeout', 60))
187

188
  def _VerifyMockMultiple(self, *args, **kwargs):
189 190 191 192 193 194 195 196 197
    self.assertEquals(len(args), len(command.Command.call_args_list))
    for arg, actual in zip(args, command.Command.call_args_list):
      expected = {
        'cmd_prefix': [],
        'shell': path.join(path.dirname(self.base), arg[0]),
        'args': list(arg[1:]),
        'timeout': kwargs.get('timeout', 60)
      }
      self.assertEquals((expected, ), actual)
198 199 200 201 202 203 204

  def testOneRun(self):
    self._WriteTestInput(V8_JSON)
    self._MockCommand(["."], ["x\nRichards: 1.234\nDeltaBlue: 10657567\ny\n"])
    self.assertEquals(0, self._CallMain())
    self._VerifyResults("test", "score", [
      {"name": "Richards", "results": ["1.234"], "stddev": ""},
205
      {"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
206 207 208 209
    ])
    self._VerifyErrors([])
    self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js")

210 211 212 213 214 215 216 217
  def testOneRunWithTestFlags(self):
    test_input = dict(V8_JSON)
    test_input["test_flags"] = ["2", "test_name"]
    self._WriteTestInput(test_input)
    self._MockCommand(["."], ["Richards: 1.234\nDeltaBlue: 10657567"])
    self.assertEquals(0, self._CallMain())
    self._VerifyResults("test", "score", [
      {"name": "Richards", "results": ["1.234"], "stddev": ""},
218
      {"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
219 220 221 222 223
    ])
    self._VerifyErrors([])
    self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js",
                     "--", "2", "test_name")

224 225 226 227 228 229 230 231 232 233 234
  def testTwoRuns_Units_SuiteName(self):
    test_input = dict(V8_JSON)
    test_input["run_count"] = 2
    test_input["name"] = "v8"
    test_input["units"] = "ms"
    self._WriteTestInput(test_input)
    self._MockCommand([".", "."],
                      ["Richards: 100\nDeltaBlue: 200\n",
                       "Richards: 50\nDeltaBlue: 300\n"])
    self.assertEquals(0, self._CallMain())
    self._VerifyResults("v8", "ms", [
235 236
      {"name": "Richards", "results": ["50.0", "100.0"], "stddev": ""},
      {"name": "DeltaBlue", "results": ["300.0", "200.0"], "stddev": ""},
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
    ])
    self._VerifyErrors([])
    self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js")

  def testTwoRuns_SubRegexp(self):
    test_input = dict(V8_JSON)
    test_input["run_count"] = 2
    del test_input["results_regexp"]
    test_input["tests"][0]["results_regexp"] = "^Richards: (.+)$"
    test_input["tests"][1]["results_regexp"] = "^DeltaBlue: (.+)$"
    self._WriteTestInput(test_input)
    self._MockCommand([".", "."],
                      ["Richards: 100\nDeltaBlue: 200\n",
                       "Richards: 50\nDeltaBlue: 300\n"])
    self.assertEquals(0, self._CallMain())
    self._VerifyResults("test", "score", [
253 254
      {"name": "Richards", "results": ["50.0", "100.0"], "stddev": ""},
      {"name": "DeltaBlue", "results": ["300.0", "200.0"], "stddev": ""},
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
    ])
    self._VerifyErrors([])
    self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js")

  def testNestedSuite(self):
    self._WriteTestInput(V8_NESTED_SUITES_JSON)
    self._MockCommand(["delta_blue", "sub/leaf", "richards"],
                      ["DeltaBlue: 200\n",
                       "Simple: 1 ms.\n",
                       "Simple: 2 ms.\n",
                       "Simple: 3 ms.\n",
                       "Richards: 100\n",
                       "Richards: 50\n"])
    self.assertEquals(0, self._CallMain())
    self.assertEquals([
      {"units": "score",
       "graphs": ["test", "Richards"],
272
       "results": ["50.0", "100.0"],
273 274 275
       "stddev": ""},
      {"units": "ms",
       "graphs": ["test", "Sub", "Leaf"],
276
       "results": ["3.0", "2.0", "1.0"],
277 278 279
       "stddev": ""},
      {"units": "score",
       "graphs": ["test", "DeltaBlue"],
280
       "results": ["200.0"],
281 282 283 284
       "stddev": ""},
      ], self._LoadResults()["traces"])
    self._VerifyErrors([])
    self._VerifyMockMultiple(
285 286
        (path.join("out", "x64.release", "d7"), "--flag", "run.js"),
        (path.join("out", "x64.release", "d7"), "--flag", "run.js"),
287 288 289 290 291 292 293 294 295 296 297 298 299 300
        (path.join("out", "x64.release", "d8"), "--flag", "run.js"),
        (path.join("out", "x64.release", "d8"), "--flag", "run.js"),
        (path.join("out", "x64.release", "d8"), "--flag", "run.js"),
        (path.join("out", "x64.release", "d8"), "--flag", "--flag2", "run.js"))

  def testOneRunStdDevRegExp(self):
    test_input = dict(V8_JSON)
    test_input["stddev_regexp"] = "^%s\-stddev: (.+)$"
    self._WriteTestInput(test_input)
    self._MockCommand(["."], ["Richards: 1.234\nRichards-stddev: 0.23\n"
                              "DeltaBlue: 10657567\nDeltaBlue-stddev: 106\n"])
    self.assertEquals(0, self._CallMain())
    self._VerifyResults("test", "score", [
      {"name": "Richards", "results": ["1.234"], "stddev": "0.23"},
301
      {"name": "DeltaBlue", "results": ["10657567.0"], "stddev": "106"},
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
    ])
    self._VerifyErrors([])
    self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js")

  def testTwoRunsStdDevRegExp(self):
    test_input = dict(V8_JSON)
    test_input["stddev_regexp"] = "^%s\-stddev: (.+)$"
    test_input["run_count"] = 2
    self._WriteTestInput(test_input)
    self._MockCommand(["."], ["Richards: 3\nRichards-stddev: 0.7\n"
                              "DeltaBlue: 6\nDeltaBlue-boom: 0.9\n",
                              "Richards: 2\nRichards-stddev: 0.5\n"
                              "DeltaBlue: 5\nDeltaBlue-stddev: 0.8\n"])
    self.assertEquals(1, self._CallMain())
    self._VerifyResults("test", "score", [
317 318
      {"name": "Richards", "results": ["2.0", "3.0"], "stddev": "0.7"},
      {"name": "DeltaBlue", "results": ["5.0", "6.0"], "stddev": "0.8"},
319 320
    ])
    self._VerifyErrors(
321
        ["Test test/Richards should only run once since a stddev is provided "
322
         "by the test.",
323
         "Test test/DeltaBlue should only run once since a stddev is provided "
324 325
         "by the test.",
         "Regexp \"^DeltaBlue\-stddev: (.+)$\" didn't match for test "
326
         "test/DeltaBlue."])
327 328 329 330 331 332 333 334
    self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js")

  def testBuildbot(self):
    self._WriteTestInput(V8_JSON)
    self._MockCommand(["."], ["Richards: 1.234\nDeltaBlue: 10657567\n"])
    self.assertEquals(0, self._CallMain("--buildbot"))
    self._VerifyResults("test", "score", [
      {"name": "Richards", "results": ["1.234"], "stddev": ""},
335
      {"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
336 337 338 339 340 341 342 343 344 345 346 347
    ])
    self._VerifyErrors([])
    self._VerifyMock(path.join("out", "Release", "d7"), "--flag", "run.js")

  def testBuildbotWithTotal(self):
    test_input = dict(V8_JSON)
    test_input["total"] = True
    self._WriteTestInput(test_input)
    self._MockCommand(["."], ["Richards: 1.234\nDeltaBlue: 10657567\n"])
    self.assertEquals(0, self._CallMain("--buildbot"))
    self._VerifyResults("test", "score", [
      {"name": "Richards", "results": ["1.234"], "stddev": ""},
348
      {"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
349 350 351 352 353 354 355 356 357
      {"name": "Total", "results": ["3626.49109719"], "stddev": ""},
    ])
    self._VerifyErrors([])
    self._VerifyMock(path.join("out", "Release", "d7"), "--flag", "run.js")

  def testBuildbotWithTotalAndErrors(self):
    test_input = dict(V8_JSON)
    test_input["total"] = True
    self._WriteTestInput(test_input)
358
    self._MockCommand(["."], ["x\nRichards: bla\nDeltaBlue: 10657567\ny\n"])
359 360 361
    self.assertEquals(1, self._CallMain("--buildbot"))
    self._VerifyResults("test", "score", [
      {"name": "Richards", "results": [], "stddev": ""},
362
      {"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
363 364
    ])
    self._VerifyErrors(
365
        ["Regexp \"^Richards: (.+)$\" "
366
         "returned a non-numeric for test test/Richards.",
367 368 369 370 371 372 373 374 375
         "Not all traces have the same number of results."])
    self._VerifyMock(path.join("out", "Release", "d7"), "--flag", "run.js")

  def testRegexpNoMatch(self):
    self._WriteTestInput(V8_JSON)
    self._MockCommand(["."], ["x\nRichaards: 1.234\nDeltaBlue: 10657567\ny\n"])
    self.assertEquals(1, self._CallMain())
    self._VerifyResults("test", "score", [
      {"name": "Richards", "results": [], "stddev": ""},
376
      {"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
377 378
    ])
    self._VerifyErrors(
379
        ["Regexp \"^Richards: (.+)$\" didn't match for test test/Richards."])
380 381 382 383 384 385
    self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js")

  def testOneRunGeneric(self):
    test_input = dict(V8_GENERIC_JSON)
    self._WriteTestInput(test_input)
    self._MockCommand(["."], [
386 387
      "RESULT Infra: Constant1= 11 count\n"
      "RESULT Infra: Constant2= [10,5,10,15] count\n"
388 389 390
      "RESULT Infra: Constant3= {12,1.2} count\n"
      "RESULT Infra: Constant4= [10,5,error,15] count\n"])
    self.assertEquals(1, self._CallMain())
391 392 393
    self.assertEquals([
      {"units": "count",
       "graphs": ["test", "Infra", "Constant1"],
394
       "results": ["11.0"],
395 396 397
       "stddev": ""},
      {"units": "count",
       "graphs": ["test", "Infra", "Constant2"],
398
       "results": ["10.0", "5.0", "10.0", "15.0"],
399 400 401
       "stddev": ""},
      {"units": "count",
       "graphs": ["test", "Infra", "Constant3"],
402
       "results": ["12.0"],
403
       "stddev": "1.2"},
404 405 406 407
      {"units": "count",
       "graphs": ["test", "Infra", "Constant4"],
       "results": [],
       "stddev": ""},
408
      ], self._LoadResults()["traces"])
409
    self._VerifyErrors(["Found non-numeric in test/Infra/Constant4"])
410
    self._VerifyMock(path.join("out", "x64.release", "cc"), "--flag", "")
411

412 413 414 415 416 417 418 419 420 421 422 423
  def testOneRunCrashed(self):
    self._WriteTestInput(V8_JSON)
    self._MockCommand(
        ["."], ["x\nRichards: 1.234\nDeltaBlue: 10657567\ny\n"], exit_code=1)
    self.assertEquals(1, self._CallMain())
    self._VerifyResults("test", "score", [
      {"name": "Richards", "results": [], "stddev": ""},
      {"name": "DeltaBlue", "results": [], "stddev": ""},
    ])
    self._VerifyErrors([])
    self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js")

424 425 426 427 428 429 430 431 432 433
  def testOneRunTimingOut(self):
    test_input = dict(V8_JSON)
    test_input["timeout"] = 70
    self._WriteTestInput(test_input)
    self._MockCommand(["."], [""], timed_out=True)
    self.assertEquals(1, self._CallMain())
    self._VerifyResults("test", "score", [
      {"name": "Richards", "results": [], "stddev": ""},
      {"name": "DeltaBlue", "results": [], "stddev": ""},
    ])
434
    self._VerifyErrors([])
435 436
    self._VerifyMock(
        path.join("out", "x64.release", "d7"), "--flag", "run.js", timeout=70)
437 438 439 440 441

  # Simple test that mocks out the android platform. Testing the platform would
  # require lots of complicated mocks for the android tools.
  def testAndroid(self):
    self._WriteTestInput(V8_JSON)
442 443
    # FIXME(machenbach): This is not test-local!
    platform = run_perf.AndroidPlatform
444 445 446 447
    platform.PreExecution = MagicMock(return_value=None)
    platform.PostExecution = MagicMock(return_value=None)
    platform.PreTests = MagicMock(return_value=None)
    platform.Run = MagicMock(
448
        return_value=("Richards: 1.234\nDeltaBlue: 10657567\n", None))
449
    run_perf.AndroidPlatform = MagicMock(return_value=platform)
450 451 452
    with patch.object(run_perf.Platform, 'ReadBuildConfig',
        MagicMock(return_value={'is_android': True})):
      self.assertEquals(0, self._CallMain("--arch", "arm"))
453 454
    self._VerifyResults("test", "score", [
      {"name": "Richards", "results": ["1.234"], "stddev": ""},
455
      {"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
456
    ])
457 458 459 460 461 462 463 464 465 466

  def testTwoRuns_Trybot(self):
    test_input = dict(V8_JSON)
    test_input["run_count"] = 2
    self._WriteTestInput(test_input)
    self._MockCommand([".", ".", ".", "."],
                      ["Richards: 100\nDeltaBlue: 200\n",
                       "Richards: 200\nDeltaBlue: 20\n",
                       "Richards: 50\nDeltaBlue: 200\n",
                       "Richards: 100\nDeltaBlue: 20\n"])
467
    test_output_secondary = path.join(TEST_WORKSPACE, "results_secondary.json")
468
    self.assertEquals(0, self._CallMain(
469 470
        "--outdir-secondary", "out-secondary",
        "--json-test-results-secondary", test_output_secondary,
471 472 473 474 475 476 477 478
    ))
    self._VerifyResults("test", "score", [
      {"name": "Richards", "results": ["100.0", "200.0"], "stddev": ""},
      {"name": "DeltaBlue", "results": ["20.0", "20.0"], "stddev": ""},
    ])
    self._VerifyResults("test", "score", [
      {"name": "Richards", "results": ["50.0", "100.0"], "stddev": ""},
      {"name": "DeltaBlue", "results": ["200.0", "200.0"], "stddev": ""},
479
    ], test_output_secondary)
480 481 482
    self._VerifyErrors([])
    self._VerifyMockMultiple(
        (path.join("out", "x64.release", "d7"), "--flag", "run.js"),
483
        (path.join("out-secondary", "x64.release", "d7"), "--flag", "run.js"),
484
        (path.join("out", "x64.release", "d7"), "--flag", "run.js"),
485
        (path.join("out-secondary", "x64.release", "d7"), "--flag", "run.js"),
486 487
    )

488 489 490 491 492 493 494 495 496 497 498 499 500
  def testWrongBinaryWithProf(self):
    test_input = dict(V8_JSON)
    self._WriteTestInput(test_input)
    self._MockCommand(["."], ["x\nRichards: 1.234\nDeltaBlue: 10657567\ny\n"])
    self.assertEquals(0, self._CallMain("--extra-flags=--prof"))
    self._VerifyResults("test", "score", [
      {"name": "Richards", "results": ["1.234"], "stddev": ""},
      {"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
    ])
    self._VerifyErrors([])
    self._VerifyMock(path.join("out", "x64.release", "d7"),
                     "--flag", "--prof", "run.js")

501 502 503 504 505 506 507
  def testUnzip(self):
    def Gen():
      for i in [1, 2, 3]:
        yield i, i + 1
    l, r = run_perf.Unzip(Gen())
    self.assertEquals([1, 2, 3], list(l()))
    self.assertEquals([2, 3, 4], list(r()))
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575

  #############################################################################
  ### System tests

  def _RunPerf(self, mocked_d8, test_json):
    output_json = path.join(TEST_WORKSPACE, "output.json")
    args = [
      sys.executable, RUN_PERF,
      "--binary-override-path", os.path.join(TEST_DATA, mocked_d8),
      "--json-test-results", output_json,
      os.path.join(TEST_DATA, test_json),
    ]
    subprocess.check_output(args)
    return self._LoadResults(output_json)

  def testNormal(self):
    results = self._RunPerf("d8_mocked1.py", "test1.json")
    self.assertEquals([], results['errors'])
    self.assertEquals([
      {
        'units': 'score',
        'graphs': ['test1', 'Richards'],
        'results': [u'1.2', u'1.2'],
        'stddev': '',
      },
      {
        'units': 'score',
        'graphs': ['test1', 'DeltaBlue'],
        'results': [u'2.1', u'2.1'],
        'stddev': '',
      },
    ], results['traces'])

  def testResultsProcessor(self):
    results = self._RunPerf("d8_mocked2.py", "test2.json")
    self.assertEquals([], results['errors'])
    self.assertEquals([
      {
        'units': 'score',
        'graphs': ['test2', 'Richards'],
        'results': [u'1.2', u'1.2'],
        'stddev': '',
      },
      {
        'units': 'score',
        'graphs': ['test2', 'DeltaBlue'],
        'results': [u'2.1', u'2.1'],
        'stddev': '',
      },
    ], results['traces'])

  def testResultsProcessorNested(self):
    results = self._RunPerf("d8_mocked2.py", "test3.json")
    self.assertEquals([], results['errors'])
    self.assertEquals([
      {
        'units': 'score',
        'graphs': ['test3', 'Octane', 'Richards'],
        'results': [u'1.2'],
        'stddev': '',
      },
      {
        'units': 'score',
        'graphs': ['test3', 'Octane', 'DeltaBlue'],
        'results': [u'2.1'],
        'stddev': '',
      },
    ], results['traces'])
576 577 578 579


if __name__ == '__main__':
  unittest.main()