aboutsummaryrefslogtreecommitdiff
path: root/scripts/make-adb-connection.sh
blob: d8bc9dbc94f98274d3f4e5dd3a06d15943f54142 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh

set -e
set -x

LAVA='echo # '
if [ -n `which lava-test-case || true` ]; then
    LAVA='lava-test-case'
fi

LAVA_RAISE='echo # '
if [ -n `which lava-test-raise || true` ]; then
    LAVA_RAISE='lava-test-raise'
fi

# Only intended for devices using ADB over USB

which adb

ls -lR /dev/bus/usb

# start adb and stop the daemon start message from appearing in $result
adb get-serialno || true # start daemon if not yet running.
result=`adb get-serialno 2>&1 | tail -n1`
if [ "$result" = "unknown" ]; then
    echo "ERROR: adb get-serialno returned" $result
    ${LAVA_RAISE} "Failed to get serial number with adb"
    exit 1
elif [ "$result" = "error: no devices/emulators found" ]; then
    ${LAVA_RAISE} $result
    exit 2
fi

${LAVA} adb-serialno --result pass
echo $result > adb-connection.txt