1#!/bin/bash -e
2
3. $(dirname $0)/../build/run-on-host.sh
4
5if [ "$1" = glibc -o "$1" = musl ]; then
6  if [ "$1" = musl ]; then
7    BUILD_ARGS=USE_HOST_MUSL=true
8  else
9    BUILD_ARGS=
10  fi
11  shift
12  m -j $BUILD_ARGS bionic-unit-tests-glibc
13  (
14    cd ${ANDROID_BUILD_TOP}
15    export ANDROID_DATA=${TARGET_OUT_DATA}
16    export ANDROID_ROOT=${TARGET_OUT}
17    ${HOST_OUT}/nativetest64/bionic-unit-tests-glibc/bionic-unit-tests-glibc $@
18  )
19  exit 0
20elif [ "$1" != 32 -a "$1" != 64 ]; then
21  echo "Usage: $0 [ 32 | 64 | glibc | musl ] [gtest flags]"
22  exit 1
23fi
24
25if [ ${HOST_OS}-${HOST_ARCH} = linux-x86 -o ${HOST_OS}-${HOST_ARCH} = linux-x86_64 ]; then
26
27  prepare $1 bionic-unit-tests
28  shift
29
30  if [ ${TARGET_ARCH} = x86 -o ${TARGET_ARCH} = x86_64 ]; then
31    (
32      cd ${ANDROID_BUILD_TOP}
33      export ANDROID_DATA=${TARGET_OUT_DATA}
34      export ANDROID_DNS_MODE=local
35      export ANDROID_ROOT=${TARGET_OUT}
36      ${NATIVETEST}/bionic-unit-tests/bionic-unit-tests $@
37    )
38  else
39    echo "$0 not supported on TARGET_ARCH=$TARGET_ARCH"
40  fi
41fi
42