1#! /bin/sh
2
3# Copyright 2018 Google Inc.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7if [ "$(uname)" = Linux ]; then
8  EXAMPLE='/opt/google/chrome/chrome'
9elif [ "$(uname)" = Darwin ]; then
10  EXAMPLE='"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"'
11else
12  EXAMPLE='"/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"'
13fi
14
15if [ $# -ne 3 ] || ! [ -x "$1" ]; then
16  cat >&2 << EOF
17usage:
18  $0 CHROMIUM_BINARY SOURCE_URL DESTINATION_DIRECTORY
19e.g:
20  $0 $EXAMPLE https://www.google.com/ /tmp/
21EOF
22  exit 1
23fi
24
25EXE="$1"
26URL="$2"
27DST="$3"
28
29CRASH=~/tmp/headless_crash_dumps
30mkdir -p "$CRASH" "$DST"
31
32printf 'chrome.gpuBenchmarking.printToSkPicture("%s");\nquit\n' "$DST" | \
33  "$EXE" --headless --disable-gpu --repl -crash-dumps-dir="$CRASH" \
34    --no-sandbox --enable-gpu-benchmarking "$URL"
35