2014-07-16 20:47:57 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
#
|
|
|
|
# Copyright 2014 Google Inc. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file or at
|
|
|
|
# https://developers.google.com/open-source/licenses/bsd
|
|
|
|
"""Test wrapper for the sample packager binary."""
|
|
|
|
|
|
|
|
import os
|
2016-08-14 22:28:21 +00:00
|
|
|
import platform
|
2014-07-16 20:47:57 +00:00
|
|
|
import subprocess
|
|
|
|
|
|
|
|
import test_env
|
|
|
|
|
|
|
|
|
|
|
|
class PackagerApp(object):
|
|
|
|
"""Main integration class for testing the packager binary."""
|
|
|
|
|
2016-01-07 19:29:19 +00:00
|
|
|
def __init__(self):
|
2016-08-14 22:28:21 +00:00
|
|
|
packager_name = 'packager'
|
|
|
|
if platform.system() == 'Windows':
|
|
|
|
packager_name += '.exe'
|
|
|
|
self.binary = os.path.join(test_env.SCRIPT_DIR, packager_name)
|
2016-04-20 00:42:40 +00:00
|
|
|
assert os.path.exists(self.binary), ('Please run from output directory, '
|
|
|
|
'e.g. out/Debug/packager_test.py')
|
2014-07-16 20:47:57 +00:00
|
|
|
|
|
|
|
def DumpStreamInfo(self, stream):
|
|
|
|
input_str = 'input=%s' % stream
|
|
|
|
cmd = [self.binary, input_str, '--dump_stream_info']
|
|
|
|
return subprocess.check_output(cmd)
|
|
|
|
|
2015-12-21 23:10:17 +00:00
|
|
|
def Version(self):
|
2016-12-08 20:07:09 +00:00
|
|
|
return subprocess.check_output([self.binary, '--version'])
|
2015-12-21 23:10:17 +00:00
|
|
|
|
2014-07-16 20:47:57 +00:00
|
|
|
def Package(self, streams, flags=None):
|
|
|
|
if flags is None:
|
|
|
|
flags = []
|
|
|
|
cmd = [self.binary]
|
|
|
|
cmd.extend(streams)
|
|
|
|
cmd.extend(flags)
|
|
|
|
assert 0 == subprocess.call(cmd)
|