1#! /bin/bash
2#
3# Copyright 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
17usage() {
18  cat >&2 <<EOF
19Determine the 32- or 64-bit architecture of a device and print the path to
20native libraries installed on the device for testing purposes.
21
22Usage:
23  $0 --32    Select the 32-bit architecture
24  $0 --64    Select the 64-bit architecture
25EOF
26  exit 1
27}
28
29if [[ $# -ne 1 ]]; then
30  usage
31fi
32
33case "$1" in
34  (--32) TEST_DIRECTORY="nativetest";;
35  (--64) TEST_DIRECTORY="nativetest64";;
36  (*) usage;;
37esac
38
39if [[ -z "$ANDROID_BUILD_TOP" ]]; then
40  echo 'ANDROID_BUILD_TOP environment variable is empty; did you forget to run `lunch`?'
41  exit 1
42fi
43
44bitness_flag=$1
45ISA=$("$ANDROID_BUILD_TOP/art/test/utils/get-device-isa" "$bitness_flag")
46
47echo "/data/${TEST_DIRECTORY}/art/${ISA}"
48