1#!/bin/bash
2
3# Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
4#
5# Use of this source code is governed by a BSD-style license
6# that can be found in the LICENSE file in the root of the source
7# tree. An additional intellectual property rights grant can be found
8# in the file PATENTS.  All contributing project authors may
9# be found in the AUTHORS file in the root of the source tree.
10
11if [ $# -ne 1 ]; then
12    echo "Usage: run-instantiation-tests.sh ADB-DEVICE-ID"
13    exit 1
14fi
15
16# Paths: update these based on your git checkout and gn output folder names.
17WEBRTC_DIR=$HOME/src/webrtc/src
18BUILD_DIR=$WEBRTC_DIR/out/Android_Release
19
20# Other settings.
21ADB=`which adb`
22SERIAL=$1
23TIMEOUT=7200
24
25# Ensure we are using the latest version.
26ninja -C $BUILD_DIR modules_tests
27
28# Transfer the required files by trying to run a test that doesn't exist.
29echo "===> Transferring required resources to device $1."
30$WEBRTC_DIR/build/android/test_runner.py gtest \
31  --output-directory $BUILD_DIR \
32  --suite modules_tests \
33  --gtest_filter "DoesNotExist" \
34  --shard-timeout $TIMEOUT \
35  --runtime-deps-path $BUILD_DIR/gen.runtime/modules/modules_tests__test_runner_script.runtime_deps \
36  --adb-path $ADB \
37  --device $SERIAL \
38  --verbose
39
40# Run all tests as separate test invocations.
41mkdir $SERIAL
42pushd $SERIAL
43$WEBRTC_DIR/build/android/test_runner.py gtest \
44  --output-directory $BUILD_DIR \
45  --suite modules_tests \
46  --gtest_filter "*InstantiationTest*" \
47  --gtest_also_run_disabled_tests \
48  --shard-timeout $TIMEOUT \
49  --runtime-deps-path ../empty-runtime-deps \
50  --test-launcher-retry-limit 0 \
51  --adb-path $ADB \
52  --device $SERIAL \
53  --verbose \
54  --num-retries 0 \
55  2>&1 | tee -a instantiation-tests.log
56popd
57