#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os
import sys

"""This script runs unit tests for code in gpu_tests/ that does telemetry
performance measurement.

This script DOES NOT run benchmarks. run_gpu_tests does that.
"""

sys.path.append(os.path.join(os.path.dirname(__file__),
    os.pardir, os.pardir, os.pardir, 'tools', 'telemetry'))

from telemetry.unittest import gtest_testrunner
from telemetry.unittest import run_tests


if __name__ == '__main__':
  top_level_dir = os.path.abspath(os.path.dirname(__file__))
  runner = gtest_testrunner.GTestTestRunner(print_result_after_run=False)
  ret = run_tests.Main(sys.argv[1:], top_level_dir, top_level_dir, runner)

  if runner.result:
    runner.result.PrintSummary()
    sys.exit(min(ret + runner.result.num_errors, 255))
  else:
    sys.exit(ret)