1cb93a386Sopenharmony_ci#! /bin/sh 2cb93a386Sopenharmony_ci 3cb93a386Sopenharmony_ci# Copyright 2018 Google Inc. 4cb93a386Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci# found in the LICENSE file. 6cb93a386Sopenharmony_ci 7cb93a386Sopenharmony_ciif [ "$(uname)" = Linux ]; then 8cb93a386Sopenharmony_ci EXAMPLE='/opt/google/chrome/chrome' 9cb93a386Sopenharmony_cielif [ "$(uname)" = Darwin ]; then 10cb93a386Sopenharmony_ci EXAMPLE='"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"' 11cb93a386Sopenharmony_cielse 12cb93a386Sopenharmony_ci EXAMPLE='"/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"' 13cb93a386Sopenharmony_cifi 14cb93a386Sopenharmony_ci 15cb93a386Sopenharmony_ciif [ $# -lt 3 ] || ! [ -x "$1" ]; then 16cb93a386Sopenharmony_ci cat >&2 << EOF 17cb93a386Sopenharmony_ciusage: 18cb93a386Sopenharmony_ci $0 CHROMIUM_BINARY SOURCE_URL DESTINATION_PATH 19cb93a386Sopenharmony_ci $0 CHROMIUM_BINARY SOURCE_URL DESTINATION_PATH OPTIONAL_WAIT_TIME # 5 second sleep before capture 20cb93a386Sopenharmony_cie.g: 21cb93a386Sopenharmony_ci $0 $EXAMPLE https://www.google.com/ /tmp/foo.mskp 22cb93a386Sopenharmony_ci $0 $EXAMPLE https://www.google.com/ /tmp/foo.mskp 5 23cb93a386Sopenharmony_ciEOF 24cb93a386Sopenharmony_ci exit 1 25cb93a386Sopenharmony_cifi 26cb93a386Sopenharmony_ci 27cb93a386Sopenharmony_ciEXE="$1" 28cb93a386Sopenharmony_ciURL="$2" 29cb93a386Sopenharmony_ciDST="$3" 30cb93a386Sopenharmony_ciSLP=${4:-0} # sleep in seconds before capture. 4th param iff provided, else 0. 31cb93a386Sopenharmony_ci 32cb93a386Sopenharmony_ciCRASH=~/tmp/headless_crash_dumps 33cb93a386Sopenharmony_cimkdir -p "$CRASH" 34cb93a386Sopenharmony_ci 35cb93a386Sopenharmony_ci(sleep $SLP; printf 'chrome.gpuBenchmarking.printPagesToSkPictures("%s");\nquit\n' "$DST") | \ 36cb93a386Sopenharmony_ci "$EXE" --headless --disable-gpu --repl -crash-dumps-dir="$CRASH" \ 37cb93a386Sopenharmony_ci --no-sandbox --enable-gpu-benchmarking "$URL" 38