def __init__(self): self.bench_pictures = find_run_binary.find_path_to_program( 'bench_pictures') self.gpuveto = find_run_binary.find_path_to_program('gpuveto') assert os.path.isfile(self.bench_pictures) assert os.path.isfile(self.gpuveto) self.truePositives = 0 self.falsePositives = 0 self.trueNegatives = 0 self.falseNegatives = 0
def __init__(self): self.bench_pictures = find_run_binary.find_path_to_program( 'bench_pictures') sys.stdout.write('Running: %s\n' % (self.bench_pictures)) self.gpuveto = find_run_binary.find_path_to_program('gpuveto') assert os.path.isfile(self.bench_pictures) assert os.path.isfile(self.gpuveto) self.indeterminate = 0 self.truePositives = 0 self.falsePositives = 0 self.trueNegatives = 0 self.falseNegatives = 0
def _generate_skps_and_run_render_pictures(self, subdir, skpdict, image_base_gs_url=None): """Generate SKPs and run render_pictures on them. Args: subdir: subdirectory (within self.temp_dir) to write all files into skpdict: {skpname: redvalue} dictionary describing the SKP files to render """ out_path = os.path.join(self.temp_dir, subdir) os.makedirs(out_path) for skpname, redvalue in skpdict.iteritems(): self._run_skpmaker( output_path=os.path.join(out_path, skpname), red=redvalue) # TODO(epoger): Add --mode tile 256 256 --writeWholeImage to the unittest, # and fix its result! (imageURLs within whole-image entries are wrong when # I tried adding that) binary = find_run_binary.find_path_to_program('render_pictures') render_pictures_cmd = [ binary, '--config', '8888', '-r', out_path, '--writeChecksumBasedFilenames', '--writeJsonSummaryPath', os.path.join(out_path, 'summary.json'), '--writePath', out_path] if image_base_gs_url: render_pictures_cmd.extend(['--imageBaseGSUrl', image_base_gs_url]) return subprocess.check_output(render_pictures_cmd)
def _run_skpmaker(self, output_path, red=0, green=0, blue=0, width=640, height=400): """Runs the skpmaker binary to generate SKP with known characteristics. Args: output_path: Filepath to write the SKP into. red: Value of red color channel in image, 0-255. green: Value of green color channel in image, 0-255. blue: Value of blue color channel in image, 0-255. width: Width of canvas to create. height: Height of canvas to create. """ binary = find_run_binary.find_path_to_program('skpmaker') return subprocess.check_output([ binary, '--red', str(red), '--green', str(green), '--blue', str(blue), '--width', str(width), '--height', str(height), '--writePath', str(output_path) ])
def _generate_skps_and_run_render_pictures(self, subdir, skpdict, image_base_gs_url=None): """Generate SKPs and run render_pictures on them. Args: subdir: subdirectory (within self.temp_dir) to write all files into skpdict: {skpname: redvalue} dictionary describing the SKP files to render """ out_path = os.path.join(self.temp_dir, subdir) os.makedirs(out_path) for skpname, redvalue in skpdict.iteritems(): self._run_skpmaker(output_path=os.path.join(out_path, skpname), red=redvalue) # TODO(epoger): Add --mode tile 256 256 --writeWholeImage to the unittest, # and fix its result! (imageURLs within whole-image entries are wrong when # I tried adding that) binary = find_run_binary.find_path_to_program('render_pictures') render_pictures_cmd = [ binary, '--config', '8888', '-r', out_path, '--writeChecksumBasedFilenames', '--writeJsonSummaryPath', os.path.join(out_path, 'summary.json'), '--writePath', out_path ] if image_base_gs_url: render_pictures_cmd.extend(['--imageBaseGSUrl', image_base_gs_url]) return subprocess.check_output(render_pictures_cmd)
def find_path_to_program(self, program): """Returns path to an existing program binary. Args: program: Basename of the program to find (e.g., 'render_pictures'). Returns: Absolute path to the program binary, as a string. Raises: Exception: unable to find the program binary. """ return find_run_binary.find_path_to_program(program)
def _run_skpmaker(self, output_path, red=0, green=0, blue=0, width=640, height=400): """Runs the skpmaker binary to generate SKP with known characteristics. Args: output_path: Filepath to write the SKP into. red: Value of red color channel in image, 0-255. green: Value of green color channel in image, 0-255. blue: Value of blue color channel in image, 0-255. width: Width of canvas to create. height: Height of canvas to create. """ binary = find_run_binary.find_path_to_program('skpmaker') return subprocess.check_output([ binary, '--red', str(red), '--green', str(green), '--blue', str(blue), '--width', str(width), '--height', str(height), '--writePath', str(output_path)])
import re import shutil import tempfile import threading import time import urllib # Must fix up PYTHONPATH before importing from within Skia import fix_pythonpath # pylint: disable=W0611 # Imports from within Skia import find_run_binary from py.utils import gs_utils SKPDIFF_BINARY = find_run_binary.find_path_to_program('skpdiff') DEFAULT_IMAGE_SUFFIX = '.png' DEFAULT_IMAGES_SUBDIR = 'images' # TODO(epoger): Figure out a better default number of threads; for now, # using a conservative default value. DEFAULT_NUM_WORKER_THREADS = 1 DISALLOWED_FILEPATH_CHAR_REGEX = re.compile('[^\w\-]') RGBDIFFS_SUBDIR = 'diffs' WHITEDIFFS_SUBDIR = 'whitediffs' # Keys used within DiffRecord dictionary representations. # NOTE: Keep these in sync with static/constants.js KEY__DIFFERENCES__MAX_DIFF_PER_CHANNEL = 'maxDiffPerChannel'
def _run_render_pictures(self, args): binary = find_run_binary.find_path_to_program('render_pictures') return find_run_binary.run_command( [binary, '--config', '8888'] + args)