• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/bash
2
3YELLOW="\033[1;33m"
4NOCOLOR="\033[0m"
5BLUE="\033[1;34m"
6RED="\033[1;91m"
7
8function happy_hedgehog {
9    echo -e "\t${BLUE}"
10    echo -e "\t       ___------__"
11    echo -e "\t |\__-- /\       _-"
12    echo -e "\t |/_   __      -"
13    echo -e "\t // \ /  \    /__"
14    echo -e "\t | 0 |  0 |__     --_        Gotta go fast!"
15    echo -e "\t \\____-- __ \   ___-"
16    echo -e "\t ( @    __/  / /_"
17    echo -e "\t    -_____---   --_"
18    echo -e "\t     //  \ \\   ___-"
19    echo -e "\t   //|\__/  \\  \\"
20    echo -e "\t   \_-\_____/  \-\\"
21    echo -e "\t        // \\--\|"
22    echo -e "\t   ${RED}____${BLUE}//  ||${RED}_"
23    echo -e "\t${RED}  /_____\ /___\\"
24    echo -e "${NOCOLOR}"
25}
26
27function sad_hedgehog {
28    echo -e "\t${BLUE}"
29    echo -e "\t       ___------__"
30    echo -e "\t |\__-- /\       _-"
31    echo -e "\t |/_    __      -"
32    echo -e "\t // \  /  \    /__"
33    echo -e "\t | 0 |  0 |__     --_        Gotta go sllloowwww!"
34    echo -e "\t \\____-- __ \   ___-"
35    echo -e "\t ( @    __   / /_"
36    echo -e "\t    -_____---   --_"
37    echo -e "\t     //  \ \\   ___-"
38    echo -e "\t   //|\__/  \\  \\"
39    echo -e "\t   \_-\_____/  \-\\"
40    echo -e "\t        // \\--\|"
41    echo -e "\t  ${RED} ____${BLUE}//  ||${RED}_"
42    echo -e "\t${RED}  /_____\ /___\\"
43    echo -e "{$NOCOLOR}"
44}
45
46PYTHON_BIN="python3.10"
47
48function check_environment {
49    if [[ -z "${ANDROID_BUILD_TOP}" ]] || [[ -z "${ANDROID_HOST_OUT}" ]] ; then
50      echo -e "${RED}ANDROID_BUILD_TOP${NOCOLOR} or ${RED}ANDROID_HOST_OUT${NOCOLOR} is not set for host run"
51      echo -e "Navigate to android root and run:"
52      echo -e "${YELLOW}"
53      echo -e ". build/envsetup.sh"
54      echo -e "lunch <fish>"
55      echo -e "${NOCOLOR}"
56      echo
57      exit 1
58    fi
59    if ! [ -x "$(command -v ${PYTHON_BIN})" ] ; then
60      echo -e "${RED}You must have ${PYTHON_BIN} installed${NOCOLOR}"
61      exit 1
62    fi
63    ${PYTHON_BIN} -m virtualenv --version
64    if [[ $? -ne 0 ]] ; then
65        echo -e "${RED}virtualenv not installed for ${PYTHON_BIN}${NOCOLOR}"
66        echo -e "${RED}Please run '${PYTHON_BIN} -m pip install virtualenv' to install it${NOCOLOR}"
67        exit 1
68    fi
69}
70
71ASHMEM_OUT="/dev/shm/out"
72ASHMEM_DIST="${ASHMEM_OUT}/dist"
73ASHMEM_VENV="${ASHMEM_DIST}/bluetooth_venv"
74ASHMEM_GOTTA_GO_FAST="/dev/shm/gottagofast"
75ASHMEM_HOST_LOGS="${ASHMEM_GOTTA_GO_FAST}/logs"
76ASHMEM_OUT_TARGET="${ASHMEM_GOTTA_GO_FAST}/target"
77ASHMEM_SOONG="${ASHMEM_GOTTA_GO_FAST}/out/soong"
78CERT_HOST_LOGS="/tmp/logs/HostOnlyCert"
79CERT_DEVICE_LOGS="TODO: Add this"
80CERT_TEST_VENV=${ANDROID_BUILD_TOP}/out/dist/bluetooth_venv
81OUT_TARGET="${ANDROID_BUILD_TOP}/out/target"
82TEST_CONFIG="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/blueberry/tests/gd/host_config.yaml"
83TEST_FILTER="--presubmit"
84TEST_RUNNER="blueberry/tests/gd/gd_test_runner.py"
85CPP_BUILD_TARGET="bluetooth_stack_with_facade root-canal bluetooth_packets_python3"
86RUST_BUILD_TARGET="bluetooth_with_facades root-canal bluetooth_packets_python3 bt_topshim_facade"
87BUILD_TARGET=$CPP_BUILD_TARGET
88
89CLEAN_VENV=false
90GOTTA_GO_FAST=false
91NUM_REPETITIONS="1"
92SKIP_SOONG_BUILD=false
93USE_ASHMEM_VENV=true
94VERBOSE_MODE=false
95DEVICE_TEST=false
96
97## Verify devices connected and valid
98DUT_SERIAL="DUT Not Set"
99DUT_ADB="DUT Not Set"
100DUT_NAME="DUT Not Set"
101
102# Used for position arguments needed for later
103POSITIONAL=()
104function parse_options {
105    while [[ $# -gt 0 ]]
106    do
107    key="$1"
108    case $key in
109        # This will delete the existing venv before running the test
110        # If you updated external libraries such as ACTS, you need to add this flag
111        --clean)
112        CLEAN_VENV=true
113        shift # past argument
114        ;;
115        --help)
116        echo
117        echo -e "${YELLOW}Help menu${NOCOLOR}"
118        echo -e "==================================="
119        echo -e "${BLUE}  --clean${NOCOLOR}"
120        echo -e "    Clean the virtul environment; use if ACTS has been updated."
121        echo -e "${BLUE}  --disable-ashmem-venv${NOCOLOR}"
122        echo -e "    Places the virtual environment on disk rather than in ashmem which is default."
123        echo -e "${BLUE}  --gotta-go-fast${NOCOLOR}"
124        echo -e "    Makes use of ashmem as best as possible for targeted speed increases."
125        echo -e "${BLUE}  --device${NOCOLOR}"
126        echo -e "    Run the test on the 2 real devices."
127        echo -e "${BLUE}  --sl4a${NOCOLOR}"
128        echo -e "    Run GD Sl4A combination tests using the default gd_sl4a config."
129        echo -e "    Please install the correct SL4A build to DUT manually before running tests."
130        echo -e "${BLUE}  --sl4a_sl4a${NOCOLOR}"
131        echo -e "    Run SL$A combination tests using the default sl4a_sl4a config."
132        echo -e "    Please install the correct SL4A build to DUT and cert manually before running tests."
133        echo -e "${BLUE}  --rust${NOCOLOR}"
134        echo -e "    Run the test using the rust implementation on the 2 real devices."
135        echo -e "${BLUE}  --rhost${NOCOLOR}"
136        echo -e "    Run the test using the rust implementation on the host."
137        echo -e "${BLUE}  --repeat=<N>${NOCOLOR}"
138        echo -e "    Repeat the test sequence N (int) number of times."
139        echo -e "${BLUE}  --skip-soong-build${NOCOLOR}"
140        echo -e "    Skips building soong targets. Use when you are just modifying simple python files."
141        echo -e "${BLUE}  --test_config=<configfile>${NOCOLOR}"
142        echo -e "    Override default test configuration."
143        echo -e "${BLUE}  --verbose${NOCOLOR}"
144        echo -e "    Displays device logs and test logs to output."
145        echo
146        echo -e "Usage: $0 [--clean|--host|--repeat=<N>|--test_config=<config>] [TestGroupName[:IndividualTestName]]"
147        echo -e "        ${YELLOW}e.g."
148        echo -e "         $0 --host --clean SecurityTest"
149        echo -e "         $0 --host --verbose SecurityTest:test_dut_initiated_display_only_display_only ${NOCOLOR}"
150        echo
151        shift
152        exit 0
153        ;;
154        # This will cause the bluetooth_venv to NOT be created in ashmem
155        # Using ashmem increases --clean build times by 40% (~21 seconds on my machine)
156        --disable-ashmem-venv)
157        USE_ASHMEM_VENV=false
158        shift # past argument
159        ;;
160        --gotta-go-fast)
161        GOTTA_GO_FAST=true
162        shift # past argument
163        ;;
164        --device)
165        DEVICE_TEST=true
166        TEST_CONFIG="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/blueberry/tests/gd/devices_config.yaml"
167        shift # past argument
168        ;;
169        # Repeat running the specified test cases by N times in one single setup
170        --repeat=*)
171        NUM_REPETITIONS="${key#*=}"
172        shift # past argument
173        ;;
174        --skip-soong-build)
175        SKIP_SOONG_BUILD=true
176        shift
177        ;;
178        --test_config=*)
179        TEST_CONFIG="${key#*=}"
180        shift # past argument
181        ;;
182        --rust)
183        BUILD_TARGET=$RUST_BUILD_TARGET
184        export RUST_BACKTRACE=1
185        TEST_CONFIG="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/blueberry/tests/gd/rust_devices_config.yaml"
186        DEVICE_TEST=true
187        shift # past argument
188        ;;
189        --rhost)
190        export RUST_BACKTRACE=1
191        BUILD_TARGET=$RUST_BUILD_TARGET
192        TEST_CONFIG="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/blueberry/tests/gd/rust_host_config.yaml"
193        shift # past argument
194        ;;
195        --sl4a)
196        TEST_CONFIG="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/blueberry/tests/gd_sl4a/gd_sl4a_device_config.yaml"
197        TEST_RUNNER="blueberry/tests/gd_sl4a/gd_sl4a_test_runner.py"
198        DEVICE_TEST=true
199        shift # past argument
200        ;;
201        --sl4a_sl4a)
202        TEST_CONFIG="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/blueberry/tests/sl4a_sl4a/sl4a_sl4a_device_config.yaml"
203        TEST_RUNNER="blueberry/tests/sl4a_sl4a/sl4a_sl4a_test_runner.py"
204        DEVICE_TEST=true
205        shift # past argument
206        ;;
207        # This will log everything to both log file and stdout
208        --verbose)
209        VERBOSE_MODE=true
210        shift # past argument
211        ;;
212        --*) # unknown argument
213        echo "$0: unrecognized argument '$1'"
214        echo "Try '$0  --help' for more information"
215        exit 1
216        shift
217        ;;
218        *)    # unknown option
219        POSITIONAL+=("$1") # save it in an array for later
220        shift # past argument
221        ;;
222    esac
223    done
224    set -- "${POSITIONAL[@]}" # restore positional parameters
225
226    # Set the test filter
227    if [[ -n "$1" ]] ; then
228      TEST_FILTER="--tests $1"
229    fi
230
231    INSTALL_ARGS="--reuse-libraries"
232    if [ "$CLEAN_VENV" == true ] ; then
233      echo -e "${YELLOW}Cleaning up existing virtualenv${NOCOLOR}"
234      rm -rf $CERT_TEST_VENV/*
235      rm -rf $CERT_TEST_VENV
236      mkdir -p ${CERT_TEST_VENV}
237      INSTALL_ARGS=""
238    else
239      echo -e "${YELLOW}Try to reuse existing virtualenv at ${CERT_TEST_VENV}${NOCOLOR}"
240    fi
241
242}
243
244function select_devices {
245  if [ "$DEVICE_TEST" == true ] ; then
246    RR="$(cat ${TEST_CONFIG}|grep \'CERT\\\|DUT\')"
247    if [ "$RR" != "" ]; then
248      DUT_SERIAL="$(menu-adb DUT)"
249      DUT_ADB="adb -s ${DUT_SERIAL}"
250      DUT_NAME="$(adb devices -l | grep -v "List of device" | grep ${DUT_SERIAL} | awk '{ print $6 }' | cut -d ':' -f 2)"
251      CERT_SERIAL="$(menu-adb CERT)"
252      CERT_ADB="adb -s ${CERT_SERIAL}"
253      CERT_NAME="$(adb devices -l | grep -v "List of device" | grep ${CERT_SERIAL} | awk '{ print $6 }' | cut -d ':' -f 2)"
254
255      if [ "${CERT_SERIAL}" == "${DUT_SERIAL}" ]; then
256          echo
257          echo -e "${RED}ERROR: CERT and DUT cannot be the same device, or you only have one device connected!${NOCOLOR}"
258          echo
259          exit 1
260      fi
261
262      ## Set android devices in config
263      sed -i "s/'DUT'/'${DUT_SERIAL}'/g" ${TEST_CONFIG}
264      sed -i "s/'CERT'/'${CERT_SERIAL}'/g" ${TEST_CONFIG}
265    fi
266  fi
267}
268
269function soong_build {
270    if [ "$CLEAN_VENV" == true ] ; then
271        $ANDROID_BUILD_TOP/build/soong/soong_ui.bash --build-mode --"modules-in-a-dir" --dir="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system" dist $BUILD_TARGET -j $(nproc)
272        if [[ $? -ne 0 ]] ; then
273            echo -e "${RED}Failed to build ${BUILD_TARGET}${NOCOLOR}"
274            exit 1
275        fi
276    else
277        $ANDROID_BUILD_TOP/build/soong/soong_ui.bash --build-mode --"all-modules" --dir="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system" dist $BUILD_TARGET -j $(nproc)
278        if [[ $? -ne 0 ]] ; then
279            echo -e "${RED}Failed to build ${BUILD_TARGET}${NOCOLOR}"
280            exit 1
281        fi
282    fi
283}
284
285function setup_venv {
286    # Make venv in memory, decreases --clean build times by 40%
287    # Caveat is you lose the venv if the computer reboots
288    if [ "${USE_ASHMEM_VENV}" == true ] ; then
289        echo -e "${BLUE}Using ashmem virtual environment.${NOCOLOR}"
290        if [[ ! -L ${CERT_TEST_VENV} ]] ; then
291            echo -e "${BLUE}"
292            echo -ne "Creating ashmem dist folder..."
293            mkdir -p "${ASHMEM_VENV}"
294            # Ensure the directory doesn't exist
295            rm -rf "${CERT_TEST_VENV}"
296            echo -e "Done"
297            echo -ne "Sym linking ${ASHMEM_VENV} to ${CERT_TEST_VENV}..."
298            ln -s "${ASHMEM_VENV}" "${CERT_TEST_VENV}"
299            echo -e "Done"
300            echo -e "${NOCOLOR}"
301        fi
302    else
303        echo -e "${RED}Not using ashmem virtual environment.${NOCOLOR}"
304        if [[ -L ${CERT_TEST_VENV} ]] ; then
305            echo -e "${RED}"
306            echo -en "Removing sym link from ${ASHMEM_VENV} to ${CERT_TEST_VENV}..."
307            rm -rf ""${ASHMEM_VENV} "${CERT_TEST_VENV}"
308            echo -e "Done"
309            echo -en "Cleaning up memory..."
310            rm -rf "${ASHMEM_VENV}"
311            echo -e "Done"
312            echo -e "${NOCOLOR}"
313        fi
314    fi
315    ${PYTHON_BIN} -m virtualenv --python `which "${PYTHON_BIN}"` "${CERT_TEST_VENV}"
316    if [[ $? -ne 0 ]] ; then
317        echo -e "${RED}Error setting up virtualenv${NOCOLOR}"
318        exit 1
319    fi
320
321    unzip -o -q "${ANDROID_BUILD_TOP}/out/dist/bluetooth_cert_tests.zip" -d "${CERT_TEST_VENV}/sources"
322    if [[ $? -ne 0 ]] ; then
323        echo -e "${RED}Error unzipping bluetooth_cert_tests.zip${NOCOLOR}"
324        exit 1
325    fi
326
327    venv_common
328}
329
330function incremental_venv {
331#LINT.IfChange
332    HOST_BIN="${ANDROID_BUILD_TOP}/out/host/linux-x86/bin"
333    HOST_LIB="${ANDROID_BUILD_TOP}/out/host/linux-x86/lib64"
334    DEST_DIR="${ANDROID_BUILD_TOP}/out/dist/bluetooth_venv/sources"
335    DEST_LIB_DIR="${DEST_DIR}/lib64"
336    cp {$HOST_BIN,$DEST_DIR}/bluetooth_stack_with_facade
337    cp {$HOST_BIN,$DEST_DIR}/bluetooth_with_facades
338    cp {$HOST_BIN,$DEST_DIR}/bt_topshim_facade
339    cp {$HOST_BIN,$DEST_DIR}/root-canal
340
341    cp {$HOST_LIB,$DEST_DIR}/bluetooth_packets_python3.so
342
343    cp {$HOST_LIB,$DEST_LIB_DIR}/libbase.so
344    cp {$HOST_LIB,$DEST_LIB_DIR}/libbluetooth_gd.so
345    cp {$HOST_LIB,$DEST_LIB_DIR}/libc++.so
346    cp {$HOST_LIB,$DEST_LIB_DIR}/libchrome.so
347    cp {$HOST_LIB,$DEST_LIB_DIR}/libcrypto-host.so
348    cp {$HOST_LIB,$DEST_LIB_DIR}/libevent-host.so
349    cp {$HOST_LIB,$DEST_LIB_DIR}/libgrpc++_unsecure.so
350    cp {$HOST_LIB,$DEST_LIB_DIR}/libgrpc++.so
351    cp {$HOST_LIB,$DEST_LIB_DIR}/libgrpc_wrap.so
352    cp {$HOST_LIB,$DEST_LIB_DIR}/liblog.so
353    cp {$HOST_LIB,$DEST_LIB_DIR}/libssl-host.so
354    cp {$HOST_LIB,$DEST_LIB_DIR}/libz-host.so
355    cp {$HOST_LIB,$DEST_LIB_DIR}/libprotobuf-cpp-full.so
356    cp {$HOST_LIB,$DEST_LIB_DIR}/libunwindstack.so
357    cp {$HOST_LIB,$DEST_LIB_DIR}/liblzma.so
358    cp {$HOST_LIB,$DEST_LIB_DIR}/libbacktrace.so
359
360    i="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/setup.py"
361    cp {${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system,$DEST_DIR}${i#${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system}
362    for i in `find ${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/blueberry -name "*.py" -type f`; do
363        cp {${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system,$DEST_DIR}${i#${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system}
364    done
365#LINT.ThenChange(../../Android.mk)
366
367    venv_common
368}
369
370function venv_common {
371    $(echo "${CERT_TEST_VENV}/bin/python" "${CERT_TEST_VENV}/sources/setup.py" --quiet build --force "${INSTALL_ARGS}")
372    if [[ $? -ne 0 ]] ; then
373        echo -e "${RED}Error building GD Python libraries${NOCOLOR}"
374        echo -e "${YELLOW}NOTE:${NOCOLOR} To build external libraries the first time, please add --clean option."
375        exit 1
376    fi
377
378    $(echo "${CERT_TEST_VENV}/bin/python" "${CERT_TEST_VENV}/sources/setup.py" --quiet install --skip-build --force "${INSTALL_ARGS}")
379    if [[ $? -ne 0 ]] ; then
380        echo -e "${RED}Error installing GD Python libraries${NOCOLOR}"
381        exit 1
382    fi
383
384"${CERT_TEST_VENV}/bin/python" -c "
385import bluetooth_packets_python3 as bp3
386bp3.BaseStruct
387"
388if [[ $? -ne 0 ]] ; then
389  echo -e "${RED}Setup failed as bluetooth_packets_python3 cannot be imported${NOCOLOR}"
390  exit 1
391fi
392
393if [ "${VERBOSE_MODE}" == true ] ; then
394  TEMP_CONFIG=/tmp/temp_mobly_config.yaml
395  cat "${TEST_CONFIG}" | "${CERT_TEST_VENV}/bin/python" -c "
396import sys
397import yaml
398config = yaml.load(sys.stdin)
399config['verbose_mode'] = True
400print(yaml.dump(config))
401  " > "${TEMP_CONFIG}"
402  TEST_CONFIG="${TEMP_CONFIG}"
403  if [[ $? -ne 0 ]] ; then
404    echo -e "${RED}Setup failed as verbose mode is chosen but cannot be enabled${NOCOLOR}"
405    exit 1
406  fi
407fi
408}
409
410function gotta_go_fast {
411    if [ "${GOTTA_GO_FAST}" == true ] ; then
412        # Call here to explicitly note the flag is in use
413        happy_hedgehog
414        if [[ ! -L "${CERT_HOST_LOGS}" ]] ; then
415            rm -rf "${CERT_HOST_LOGS}"
416            mkdir -p "${ASHMEM_HOST_LOGS}"
417            ln -s "${ASHMEM_HOST_LOGS}" "${CERT_HOST_LOGS}"
418        fi
419
420        if [[ ! -L "${OUT_TARGET}" ]] ; then
421            rm -rf "${OUT_TARGET}"
422            mkdir -p "${ASHMEM_OUT_TARGET}"
423            ln -s  "${ASHMEM_OUT_TARGET}" "${OUT_TARGET}"
424        fi
425    else
426        if [[ -L "${CERT_HOST_LOGS}" ]] ; then
427            # Call here so we don't spam anyone not using the flag
428            sad_hedgehog
429            rm -rf "${CERT_HOST_LOGS}"
430            rm -rf "${ASHMEM_HOST_LOGS}"
431        fi
432
433        if [[ -L "${OUT_TARGET}" ]] ; then
434            rm -rf "${OUT_TARGET}"
435            rm -rf "${ASHMEM_OUT_TARGET}"
436        fi
437    fi
438}
439
440function run_tests {
441    for n in $(seq "${NUM_REPETITIONS}"); do
442      $(echo "${CERT_TEST_VENV}/bin/python" "${CERT_TEST_VENV}/sources/${TEST_RUNNER}" \
443          "-c ${TEST_CONFIG}" "${TEST_FILTER}")
444    done
445
446    if [ "${CLEAN_VENV}" != true ] ; then
447      echo -e "${YELLOW}NOTE:${NOCOLOR} Completed tests using existing external libraries in virtualenv."
448      echo -e "${YELLOW}NOTE:${NOCOLOR} To update external libraries, please add --clean option."
449    fi
450}
451
452function menu-adb() {
453    TMP=$(adb devices -l | grep -v "List of device" | awk '{ print $1 }')
454    # TODO(optedoblivion): If the device doesn't have a name (offline), it misnames them
455    NTMP=$(adb devices -l | grep -v "List of device" | awk '{ print $6 }' | cut -d ':' -f 2)
456    SERIALS=($TMP)
457    DEVICES=($NTMP)
458    LEN=${#SERIALS[@]}
459    result=0
460    if [ $LEN -lt 1 ]; then
461        echo -e "${YELLOW}No devices connected!${NOCOLOR}"
462        return 1
463    fi
464
465    if [ "$LEN" == "" ]; then
466        LEN=0
467    fi
468
469    answer=0
470
471    DEVICE_NAME="$1 device"
472
473    if [ $LEN -gt 1 ]; then
474        echo "+-------------------------------------------------+" 1>&2
475        echo "| Choose a ${DEVICE_NAME}:                         " 1>&2
476        echo "+-------------------------------------------------+" 1>&2
477        echo "|                                                 |" 1>&2
478        let fixed_len=$LEN-1
479        for i in `seq 0 $fixed_len`;
480        do
481            serial=${SERIALS[i]}
482            device=${DEVICES[i]}
483            echo "| $i) $serial $device" 1>&2
484            ## TODO[MSB]: Find character count, fill with space and ending box wall
485        done
486        echo "|                                                 |" 1>&2
487        echo "+-------------------------------------------------+" 1>&2
488        echo 1>&2
489        echo -n "Index number: " 1>&2
490        read answer
491    fi
492
493    if [ $answer -ge $LEN ]; then
494        echo
495        echo "Please choose a correct index!" 1>&2
496        echo
497        return 1
498    fi
499
500    SERIAL=${SERIALS[$answer]}
501    echo $SERIAL
502}
503
504function main {
505    check_environment
506    parse_options $@
507    select_devices
508    if [[ "${SKIP_SOONG_BUILD}" != true ]] ; then
509        soong_build
510    fi
511    if [ "$CLEAN_VENV" == true ] ; then
512        setup_venv
513    else
514        incremental_venv
515    fi
516    gotta_go_fast
517    run_tests
518}
519
520main $@
521