OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2010 The Chromium OS 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 import glob, logging, os, re, stat, time, urllib |
| 6 |
| 7 from autotest_lib.client.bin import test |
| 8 from autotest_lib.client.common_lib import error, utils |
| 9 |
| 10 class audiovideo_FFMPEG(test.test): |
| 11 version = 1 |
| 12 |
| 13 def run_once(self): |
| 14 """ Run FFMPEG performance test! """ |
| 15 # fetch all the test cases from file. |
| 16 testcases = os.path.join(self.bindir, "testcases") |
| 17 self.performance_results = {} |
| 18 for line in open(testcases, "rt"): |
| 19 # skip comment line and blank line |
| 20 line = line.rstrip() |
| 21 if len(line) == 0: continue |
| 22 if line[0] == "#": continue |
| 23 # run each test cases |
| 24 testcase = line.split() |
| 25 self.run_testcase(testcase) |
| 26 self.write_perf_keyval(self.performance_results) |
| 27 |
| 28 |
| 29 def run_testcase(self, testcase): |
| 30 executable = os.path.join(self.bindir, "ffmpeg_tests.i686") |
| 31 file_url = testcase[0] |
| 32 |
| 33 # TODO(jiesun): if url is not local, grab it from internet. |
| 34 if file_url.startswith("http"): |
| 35 file_name = file_url.split('/')[-1] |
| 36 file_path = os.path.join(self.bindir, file_name) |
| 37 logging.info("Retrieving %s" % file_url) |
| 38 urllib.urlretrieve(file_url, file_path) |
| 39 logging.info("Done.") |
| 40 else: |
| 41 # if url is local, we assume it is in the same directory. |
| 42 file_name = file_url; |
| 43 file_path = os.path.join(self.bindir, file_name) |
| 44 |
| 45 if not os.path.exists(file_path): |
| 46 raise error.TestError("ffmpeg_tests: test media missing %s!" |
| 47 % file_url) |
| 48 |
| 49 command_line = ("LD_LIBRARY_PATH=/opt/google/chrome/ %s %s" |
| 50 % (executable, file_path)) |
| 51 logging.info("Running %s" % command_line) |
| 52 |
| 53 cpu_usage, stdout = utils.get_cpu_percentage( |
| 54 utils.system_output, |
| 55 command_line, |
| 56 retain_output=True) |
| 57 |
| 58 # what's the fps we measures. |
| 59 fps_pattern = re.search(r"FPS:\s+([\d\.]+)", stdout) |
| 60 if fps_pattern is None: |
| 61 raise error.TestFail("ffmpeg_tests failed to exit normally!") |
| 62 fps = float(fps_pattern.group(1)) |
| 63 cpu_usage *= 100.0 # in percentage. |
| 64 logging.info("Cpu Usage %s%%; FPS: %s" % (cpu_usage, fps)) |
| 65 |
| 66 # record the performance data for future analysis. |
| 67 self.performance_results['fps_' + file_name] = fps |
| 68 self.performance_results['cpuusage_' + file_name] = cpu_usage |
| 69 |
| 70 # TODO(jiesun/fbarchard): what else need to be checked? |
| 71 |
OLD | NEW |