1#!/bin/bash
2
3# Quit if any command produces an error.
4set -e
5
6BUILD_ONLY="false"
7while getopts "b" opt; do
8  case ${opt} in
9    b)
10      BUILD_ONLY="true"
11      ;;
12  esac
13done
14
15# Build and run the CHRE unit test binary.
16JOB_COUNT=$((`grep -c ^processor /proc/cpuinfo`))
17
18# Export the variant Makefile.
19export CHRE_VARIANT_MK_INCLUDES="$CHRE_VARIANT_MK_INCLUDES \
20  variant/googletest/variant.mk"
21
22make clean
23make google_x86_googletest_debug -j$JOB_COUNT
24
25if [ "$BUILD_ONLY" = "false" ]; then
26./out/google_x86_googletest_debug/libchre ${@:1}
27else
28    if [ ! -f ./out/google_x86_googletest_debug/libchre ]; then
29        echo  "./out/google_x86_googletest_debug/libchre does not exist."
30        exit 1
31    fi
32fi