diff options
author | mfomitchev <mfomitchev@chromium.org> | 2014-12-05 07:13:50 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-05 15:14:14 +0000 |
commit | 00080aaedb7d7c1111289db3d62dfae4ee173ba3 (patch) | |
tree | 143ba618d774ec59458ae5835f083650ce257a72 /tools | |
parent | dbb5e440e2a9723c97f25724d27bab5f5781aec0 (diff) | |
download | chromium_src-00080aaedb7d7c1111289db3d62dfae4ee173ba3.zip chromium_src-00080aaedb7d7c1111289db3d62dfae4ee173ba3.tar.gz chromium_src-00080aaedb7d7c1111289db3d62dfae4ee173ba3.tar.bz2 |
Revert of [Telemetry] Fix video_unittest so that it actually runs on bots. (patchset #6 id:100001 of https://codereview.chromium.org/756553003/)
Reason for revert:
Looks like this broke telemetry_unittests
Build link:
https://build.chromium.org/p/chromium.linux/builders/Linux%20Tests/builds/17356
Output:
[284/694] telemetry.core.video_unittest.VideoTest.testFramesFromMp4 failed unexpectedly:
Traceback (most recent call last):
File "/mnt/data/b/build/slave/Linux_Tests/build/src/tools/telemetry/telemetry/decorators.py", line 84, in wrapper
func(*args, **kwargs)
File "/mnt/data/b/build/slave/Linux_Tests/build/src/tools/telemetry/telemetry/core/video_unittest.py", line 35, in testFramesFromMp4
for i, timestamp_bitmap in enumerate(video_obj._FramesFromMp4()):
File "/mnt/data/b/build/slave/Linux_Tests/build/src/tools/telemetry/telemetry/core/video.py", line 158, in _FramesFromMp4
dimensions = GetDimensions(self._video_file_obj.name)
File "/mnt/data/b/build/slave/Linux_Tests/build/src/tools/telemetry/telemetry/core/video.py", line 137, in GetDimensions
output)
AssertionError: Failed to determine video dimensions. output=avconv: error while loading shared libraries: libavdevice.so.53: cannot open shared object file: No such file or directory
Original issue's description:
> [Telemetry] Fix video_unittest so that it actually runs on bots.
>
> This also makes it explicitly clear that the avconv dependency is currently linux only.
>
> I had another CL out a while ago that fixes this, but that CL's blocked, so I'm separating this out.
>
> BUG=433943
>
> Committed: https://crrev.com/eae4959498c328f8e3fa710b1d507c0d68225b18
> Cr-Commit-Position: refs/heads/master@{#306858}
TBR=tonyg@chromium.org,slamm@chromium.org,mthiesse@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=433943
Review URL: https://codereview.chromium.org/748873003
Cr-Commit-Position: refs/heads/master@{#307024}
Diffstat (limited to 'tools')
-rw-r--r-- | tools/telemetry/telemetry/core/platform/linux_platform_backend.py | 2 | ||||
-rw-r--r-- | tools/telemetry/telemetry/core/video.py | 21 | ||||
-rw-r--r-- | tools/telemetry/telemetry/core/video_unittest.py | 36 |
3 files changed, 32 insertions, 27 deletions
diff --git a/tools/telemetry/telemetry/core/platform/linux_platform_backend.py b/tools/telemetry/telemetry/core/platform/linux_platform_backend.py index fc1e09a..d29fd4e 100644 --- a/tools/telemetry/telemetry/core/platform/linux_platform_backend.py +++ b/tools/telemetry/telemetry/core/platform/linux_platform_backend.py @@ -163,7 +163,7 @@ class LinuxPlatformBackend( os.environ['PATH'] += os.pathsep + os.path.dirname(bin_path) try: - cloud_storage.GetIfChanged(bin_path) + cloud_storage.GetIfChanged(bin_path, cloud_storage.INTERNAL_BUCKET) os.chmod(bin_path, 0755) except cloud_storage.CloudStorageError, e: logging.error(str(e)) diff --git a/tools/telemetry/telemetry/core/video.py b/tools/telemetry/telemetry/core/video.py index c4211e4..4eb4cab 100644 --- a/tools/telemetry/telemetry/core/video.py +++ b/tools/telemetry/telemetry/core/video.py @@ -18,13 +18,9 @@ class Video(object): """Utilities for storing and interacting with the video capture.""" def __init__(self, video_file_obj): - """Initializes the Video object. - - args: - video_file: A file-like object.""" - assert(hasattr(video_file_obj, 'name')) + assert video_file_obj.delete + assert not video_file_obj.close_called self._video_file_obj = video_file_obj - self._tab_contents_bounding_box = None def UploadToCloudStorage(self, bucket, target_path): @@ -47,7 +43,7 @@ class Video(object): time_ms is milliseconds since navigationStart. bitmap is a telemetry.core.Bitmap. """ - frame_generator = self._FramesFromMp4() + frame_generator = self._FramesFromMp4(self._video_file_obj.name) # Flip through frames until we find the initial tab contents flash. content_box = None @@ -117,7 +113,7 @@ class Video(object): return self._tab_contents_bounding_box - def _FramesFromMp4(self): + def _FramesFromMp4(self, mp4_file): host_platform = platform.GetHostPlatform() if not host_platform.CanLaunchApplication('avconv'): host_platform.InstallApplication('avconv') @@ -155,15 +151,14 @@ class Video(object): if 'pts=' in line: return int(1000 * float(line.split('=')[-1])) - dimensions = GetDimensions(self._video_file_obj.name) + dimensions = GetDimensions(mp4_file) frame_length = dimensions[0] * dimensions[1] * 3 frame_data = bytearray(frame_length) # Use rawvideo so that we don't need any external library to parse frames. - proc = subprocess.Popen(['avconv', '-i', self._video_file_obj.name, - '-vcodec', 'rawvideo', '-pix_fmt', 'rgb24', - '-dump', '-loglevel', 'debug', '-f', 'rawvideo', - '-'], + proc = subprocess.Popen(['avconv', '-i', mp4_file, '-vcodec', + 'rawvideo', '-pix_fmt', 'rgb24', '-dump', + '-loglevel', 'debug', '-f', 'rawvideo', '-'], stderr=subprocess.PIPE, stdout=subprocess.PIPE) while True: num_read = proc.stdout.readinto(frame_data) diff --git a/tools/telemetry/telemetry/core/video_unittest.py b/tools/telemetry/telemetry/core/video_unittest.py index b49190d..e940f0f 100644 --- a/tools/telemetry/telemetry/core/video_unittest.py +++ b/tools/telemetry/telemetry/core/video_unittest.py @@ -2,19 +2,30 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import logging import os import unittest -from telemetry import decorators +from telemetry import benchmark from telemetry.core import bitmap +from telemetry.core import platform from telemetry.core import util from telemetry.core import video class VideoTest(unittest.TestCase): - @decorators.Enabled('linux') + @benchmark.Disabled def testFramesFromMp4(self): + host_platform = platform.GetHostPlatform() + + try: + host_platform.InstallApplication('avconv') + finally: + if not host_platform.CanLaunchApplication('avconv'): + logging.warning('Test not supported on this platform') + return # pylint: disable=W0150 + vid = os.path.join(util.GetUnittestDataDir(), 'vid.mp4') expected_timestamps = [ 0, @@ -27,14 +38,13 @@ class VideoTest(unittest.TestCase): 1926, ] - with open(vid) as video_file: - video_obj = video.Video(video_file) - - # Calling _FramesFromMp4 should return all frames. - # pylint: disable=W0212 - for i, timestamp_bitmap in enumerate(video_obj._FramesFromMp4()): - timestamp, bmp = timestamp_bitmap - self.assertEquals(timestamp, expected_timestamps[i]) - expected_bitmap = bitmap.Bitmap.FromPngFile(os.path.join( - util.GetUnittestDataDir(), 'frame%d.png' % i)) - self.assertTrue(expected_bitmap.IsEqual(bmp)) + video_obj = video.Video(vid) + + # Calling _FramesFromMp4 should return all frames. + # pylint: disable=W0212 + for i, timestamp_bitmap in enumerate(video_obj._FramesFromMp4(vid)): + timestamp, bmp = timestamp_bitmap + self.assertEquals(timestamp, expected_timestamps[i]) + expected_bitmap = bitmap.Bitmap.FromPngFile(os.path.join( + util.GetUnittestDataDir(), 'frame%d.png' % i)) + self.assertTrue(expected_bitmap.IsEqual(bmp)) |