1#!/bin/sh
2#
3# Copyright (C) 2019 The Android Open-Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18usage() {
19    echo "Usage: $0 [--all] [--apk-info=file] [--apk-dir=dir]"
20    echo ""
21    echo "Options:"
22    echo -e "  -a, --all \t\trun all tests"
23    echo -e "  -h, --help \t\tprint this help"
24    echo -e "  --apk-info=file \tAn XML file describing the list of APKs for qualifications."
25    echo -e "  --apk-dir=dir \tDirectory containing the APKs for qualifications.  If --apk-info is"
26    echo -e "                \tnot specified and a file named 'apk-info.xml' exists in --apk-dir,"
27    echo -e "                \tthat file will be used as the apk-info."
28    exit 1;
29}
30
31OPTS=`getopt -o ah -l all,help,apk-info:,apk-dir: -- "$@"` || usage
32eval set -- "$OPTS"
33
34CONFIG="certification-tests.xml"
35APK_INFO=""
36APK_DIR=""
37while [ $# -ne 0 ]; do
38    case "$1" in
39        --apk-info)
40            APK_INFO="--apk-info $2"; shift 2;;
41        --apk-dir)
42            APK_DIR="--apk-dir $2"; shift 2;;
43        -a|--all)
44            CONFIG="AndroidTest.xml"; shift;;
45        -h|--help)
46            usage;;
47        --) shift; break;;
48        *)
49            # Should be unreachable.
50            echo "Internal error: getopt ${OPTS}"
51            usage
52    esac
53done
54
55ANDROID_TARGET_OUT_TESTCASES=$PWD/testcases ./bin/tradefed.sh run commandAndExit ${CONFIG} ${APK_INFO} ${APK_DIR} "$@"
56