1#!/bin/bash
2
3# Copyright 2017 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
17set -e
18
19#
20# Parse parameters
21#
22
23function printUsage {
24   echo "Supported parameters are:"
25   echo "    -s|--serial <target device serial number> (optional)"
26   echo
27   echo "i.e. ${0##*/} -s <serial number>"
28   exit 1
29}
30
31if [[ $(($# % 2)) -ne 0 ]]
32then
33    echo Parameters must be provided in pairs.
34    echo parameter count = $#
35    echo
36    printUsage
37    exit 1
38fi
39
40while [[ $# -gt 0 ]]
41do
42    case $1 in
43        -s|--serial)
44            # include the flag, because we need to leave it off if not provided
45            serial="$2"
46            shift 2
47            ;;
48        -*)
49            # unknown option
50            echo Unknown option: $1
51            echo
52            printUsage
53            exit 1
54            ;;
55    esac
56done
57
58if [[ $serial ]]; then
59    echo serial = "${serial}"
60    serialFlag="-s $serial"
61    if [[ $(adb devices) != *"$serial"* ]]
62    then
63        echo Device not found: "${serial}"
64        echo
65        printUsage
66        exit 1
67    fi
68else
69    echo Using device $(adb get-serialno)
70fi
71
72# Install everything built by build_all.sh
73echo "adb $serialFlag install -r bin/VulkanLayerValidationTests.apk"
74adb $serialFlag install -r bin/VulkanLayerValidationTests.apk
75
76exit $?
77