1#!/bin/bash 2 3# Copyright 2013 Google Inc. 4# 5# Use of this source code is governed by a BSD-style license that can be 6# found in the LICENSE file. 7 8if [ "${1}" == '-h' ] || [ "${1}" == '--help' ] 9then 10echo 'test_all_pdfs.sh 11Usage: Run from the trunk directory of a Skia tree to convert a folder of PDFs into PNGs. 12 Many threads will be run simultaneously using the "parallel" tool if that tool is 13 installed. "parallel" can be installed on linux using "sudo apt-get install parallel." 14 Requires that skdiff and pdfviewer have already been built. 15 16Arguments: 17 folder Folder containing PDF files. The PNG results will be placed in "folder/new". 18 If folder contains a folder named "old", the PNGs in "folder/new" will be 19 compared to PNGs in "folder/old" with the same name, and the differences 20 will be stored in a "folder/d".' 21exit 22fi 23 24# Early exit if pdfviewer has not been built. 25# TODO (scroggo): Use release version if debug is unavailable 26if [ ! -f out/Debug/pdfviewer ] 27then 28 echo 'debug version of pdfviewer is required.' 29 exit 30fi 31 32if [ -z $1 ] 33then 34 echo 'folder is a required argument.' 35 exit 36fi 37 38if [ ! -d $1 ] 39then 40 echo 'folder must be a valid directory.' 41 exit 42fi 43 44# Create the directory to contain the new results. If old new results exist, remove them. 45if [ -d $1/new ] 46then 47 rm -rf $1/new 48fi 49 50mkdir $1/new/ 51 52# Run the script to read each PDF and convert it to a PNG. 53if command -v parallel >/dev/null 2>&1 54then 55 echo 'Running in parallel' 56 ls -1 $1/*.pdf | sed "s/^/experimental\/PdfViewer\/scripts\/vm_pdf_viewer_run_one_pdf.sh /" \ 57 | parallel 58else 59 echo 'Converting each file sequentially. Install "parallel" to convert in parallel.' 60 echo '"parallel" can be installed on linux with "sudo apt-get install parallel".' 61 ls -1 $1/*.pdf | xargs experimental/PdfViewer/scripts/vm_pdf_viewer_run_one_pdf.sh 62fi 63 64# Next, compare to the old results. Exit now if there is no folder with old results. 65if [ ! -d $1/old ] 66then 67 exit 68fi 69 70# Check to make sure that skdiff has been built. 71RELEASE_SKDIFF=out/Release/skdiff 72DEBUG_SKDIFF=out/Debug/skdiff 73if [ -f $RELEASE_SKDIFF ] 74then 75 SKDIFF=$RELEASE_SKDIFF 76elif [ -f $DEBUG_SKDIFF ] 77then 78 SKDIFF=$DEBUG_SKDIFF 79else 80 echo 'Build skdiff in order to do comparisons.' 81 exit 82fi 83 84# Create the diff folder, after deleting old diffs if necessary. 85if [ -d $1/d ] 86then 87 rm -rf $1/d 88fi 89 90mkdir $1/d 91 92$SKDIFF $1/old $1/new $1/d 93