@@ -15,13 +15,17 @@ USAGE="USAGE: `basename ${0}` [--help] [--serial <SerialNumber>] [options]
15
15
16
16
adb remount tests
17
17
18
- --color Dress output with highlighting colors
19
- --help This help
20
- --no-wait-screen Do not wait for display screen to settle
21
- --print-time Report the test duration
22
- --serial Specify device (must if multiple are present)
23
- --wait-adb <duration> adb wait timeout
24
- --wait-fastboot <duration> fastboot wait timeout
18
+ -c --color Dress output with highlighting colors
19
+ -h --help This help
20
+ -D --no-wait-screen Do not wait for display screen to settle
21
+ -t --print-time Report the test duration
22
+ -s --serial Specify device (must if multiple are present)"
23
+ if [ -n " ` which timeout` " ]; then
24
+ USAGE=" ${USAGE}
25
+ -a --wait-adb <duration> adb wait timeout
26
+ -f --wait-fastboot <duration> fastboot wait timeout"
27
+ fi
28
+ USAGE=" ${USAGE}
25
29
26
30
Conditions:
27
31
- Must be a userdebug build.
@@ -72,7 +76,7 @@ inFastboot() {
72
76
if [ -n " ${ANDROID_SERIAL} " ]; then
73
77
grep " ^${ANDROID_SERIAL} [${SPACE}${TAB} ]" > /dev/null
74
78
else
75
- wc -l | grep ' ^1$ ' > /dev/null
79
+ wc -l | grep " ^[ ${SPACE}${TAB} ]*1 \$ " > /dev/null
76
80
fi
77
81
}
78
82
@@ -85,7 +89,7 @@ inAdb() {
85
89
if [ -n " ${ANDROID_SERIAL} " ]; then
86
90
grep " ^${ANDROID_SERIAL} [${SPACE}${TAB} ]" > /dev/null
87
91
else
88
- wc -l | grep ' ^1$ ' > /dev/null
92
+ wc -l | grep " ^[ ${SPACE}${TAB} ]*1 \$ " > /dev/null
89
93
fi
90
94
}
91
95
@@ -100,7 +104,7 @@ inRecovery() {
100
104
grep " ^${ANDROID_SERIAL} [${SPACE}${TAB} ][${SPACE}${TAB} ]*recovery\$ " > /dev/null
101
105
return ${?}
102
106
fi
103
- if echo " ${list} " | wc -l | grep ' ^1$ ' > /dev/null; then
107
+ if echo " ${list} " | wc -l | grep " ^[ ${SPACE}${TAB} ]*1 \$ " > /dev/null; then
104
108
echo " ${list} " |
105
109
grep " [${SPACE}${TAB} ]recovery\$ " > /dev/null
106
110
return ${?}
@@ -143,7 +147,7 @@ adb_logcat() {
143
147
adb logcat " ${@ } " < /dev/null |
144
148
tr -d ' \r' |
145
149
grep -v ' logd : logdr: UID=' |
146
- sed -e ' ${/------- beginning of kernel/d}' -e ' s/^[0-1][0-9]-[0-3][0-9] //'
150
+ sed -e ' ${ /------- beginning of kernel/d }' -e ' s/^[0-1][0-9]-[0-3][0-9] //'
147
151
}
148
152
149
153
[ " USAGE: avc_check >/dev/stderr
@@ -284,7 +288,7 @@ adb_wait() {
284
288
local start=` date +%s`
285
289
local duration=
286
290
local ret
287
- if [ -n " ${1} " ]; then
291
+ if [ -n " ${1} " -a -n " ` which timeout ` " ]; then
288
292
USB_DEVICE=` usb_devnum --next`
289
293
duration=` format_duration ${1} `
290
294
echo -n " . . . waiting ${duration} " ${ANDROID_SERIAL} ${USB_ADDRESS} ${USB_DEVICE} " ${CR} "
@@ -359,18 +363,22 @@ usb_status() {
359
363
echo " (In adb mode ` adb_user` )"
360
364
else
361
365
echo " (USB stack borken for ${USB_ADDRESS} )"
362
- USB_DEVICE=` usb_devnum`
363
- if [ -n " ${USB_DEVICE} " ]; then
364
- echo " # lsusb -v -s ${USB_DEVICE# dev} "
365
- local D=` lsusb -v -s ${USB_DEVICE# dev} 2>&1 `
366
- if [ -n " ${D} " ]; then
367
- echo " ${D} "
368
- else
369
- lsusb -v
366
+ if [ -n " ` which usb_devnum` " ]; then
367
+ USB_DEVICE=` usb_devnum`
368
+ if [ -n " ` which lsusb` " ]; then
369
+ if [ -n " ${USB_DEVICE} " ]; then
370
+ echo " # lsusb -v -s ${USB_DEVICE# dev} "
371
+ local D=` lsusb -v -s ${USB_DEVICE# dev} 2>&1 `
372
+ if [ -n " ${D} " ]; then
373
+ echo " ${D} "
374
+ else
375
+ lsusb -v
376
+ fi
377
+ else
378
+ echo " # lsusb -v (expected device missing)"
379
+ lsusb -v
380
+ fi
370
381
fi
371
- else
372
- echo " # lsusb -v (expected device missing)"
373
- lsusb -v
374
382
fi >&2
375
383
fi
376
384
}
@@ -382,7 +390,7 @@ fastboot_wait() {
382
390
local ret
383
391
# fastboot has no wait-for-device, but it does an automatic
384
392
# wait and requires (even a nonsensical) command to do so.
385
- if [ -n " ${1} " ]; then
393
+ if [ -n " ${1} " -a -n " ` which timeout ` " ]; then
386
394
USB_DEVICE=` usb_devnum --next`
387
395
echo -n " . . . waiting ` format_duration ${1} ` " ${ANDROID_SERIAL} ${USB_ADDRESS} ${USB_DEVICE} " ${CR} "
388
396
timeout --preserve-status --signal=KILL ${1} fastboot wait-for-device > /dev/null 2> /dev/null
@@ -409,7 +417,7 @@ fastboot_wait() {
409
417
Returns: waits until the device has returned for recovery or optional timeout" ]
410
418
recovery_wait () {
411
419
local ret
412
- if [ -n " ${1} " ]; then
420
+ if [ -n " ${1} " -a -n " ` which timeout ` " ]; then
413
421
USB_DEVICE=` usb_devnum --next`
414
422
echo -n " . . . waiting ` format_duration ${1} ` " ${ANDROID_SERIAL} ${USB_ADDRESS} ${USB_DEVICE} " ${CR} "
415
423
timeout --preserve-status --signal=KILL ${1} adb wait-for-recovery 2> /dev/null
@@ -754,13 +762,28 @@ skip_unrelated_mounts() {
754
762
# # MAINLINE
755
763
# #
756
764
757
- OPTIONS=` getopt --alternative --unquoted \
758
- --longoptions help,serial:,colour,color,no-colour,no-color \
759
- --longoptions wait-adb:,wait-fastboot: \
760
- --longoptions wait-screen,wait-display \
761
- --longoptions no-wait-screen,no-wait-display \
762
- --longoptions gtest_print_time,print-time \
763
- -- " ?hs:" ${* } ` ||
765
+ HOSTOS=` uname`
766
+ GETOPTS=" --alternative --unquoted
767
+ --longoptions help,serial:,colour,color,no-colour,no-color
768
+ --longoptions wait-adb:,wait-fastboot:
769
+ --longoptions wait-screen,wait-display
770
+ --longoptions no-wait-screen,no-wait-display
771
+ --longoptions gtest_print_time,print-time
772
+ --"
773
+ if [ " Darwin" = " ${HOSTOS} " ]; then
774
+ GETOPTS=
775
+ USAGE=" ` echo \" ${USAGE} \" |
776
+ sed ' s/--color/ /g
777
+ 1s/--help/-h/
778
+ s/--help/ /g
779
+ s/--no-wait-screen/ /g
780
+ s/--print-time/ /g
781
+ 1s/--serial/-s/
782
+ s/--serial/ /g
783
+ s/--wait-adb/ /g
784
+ s/--wait-fastboot/ /g' ` "
785
+ fi
786
+ OPTIONS=` getopt ${GETOPTS} " ?a:cCdDf:hs:t" ${* } ` ||
764
787
( echo " ${USAGE} " >&2 ; false ) ||
765
788
die " getopt failure"
766
789
set -- ${OPTIONS}
@@ -776,26 +799,26 @@ while [ ${#} -gt 0 ]; do
776
799
export ANDROID_SERIAL=${2}
777
800
shift
778
801
;;
779
- --color | --colour)
802
+ -c | - -color | --colour)
780
803
color=true
781
804
;;
782
- --no-color | --no-colour)
805
+ -C | - -no-color | --no-colour)
783
806
color=false
784
807
;;
785
- --no-wait-display | --no-wait-screen)
808
+ -D | - -no-wait-display | --no-wait-screen)
786
809
screen_wait=false
787
810
;;
788
- --wait-display | --wait-screen)
811
+ -d | - -wait-display | --wait-screen)
789
812
screen_wait=true
790
813
;;
791
- --print-time | --gtest_print_time)
814
+ -t | - -print-time | --gtest_print_time)
792
815
print_time=true
793
816
;;
794
- --wait-adb)
817
+ -a | - -wait-adb)
795
818
ADB_WAIT=${2}
796
819
shift
797
820
;;
798
- --wait-fastboot)
821
+ -f | - -wait-fastboot)
799
822
FASTBOOT_WAIT=${2}
800
823
shift
801
824
;;
@@ -847,9 +870,13 @@ D=`get_property ro.serialno`
847
870
[ -n " ${D} " ] || D=` get_property ro.boot.serialno`
848
871
[ -z " ${D} " -o -n " ${ANDROID_SERIAL} " ] || ANDROID_SERIAL=${D}
849
872
USB_SERIAL=
850
- [ -z " ${ANDROID_SERIAL} " ] || USB_SERIAL=` find /sys/devices -name serial |
851
- grep usb |
852
- xargs -r grep -l ${ANDROID_SERIAL} `
873
+ if [ -n " ${ANDROID_SERIAL} " -a " Darwin" != " ${HOSTOS} " ]; then
874
+ USB_SERIAL=" ` find /sys/devices -name serial | grep usb` "
875
+ if [ -n " ${USB_SERIAL} " ]; then
876
+ USB_SERIAL=` echo " ${USB_SERIAL} " |
877
+ xargs grep -l ${ANDROID_SERIAL} `
878
+ fi
879
+ fi
853
880
USB_ADDRESS=
854
881
if [ -n " ${USB_SERIAL} " ]; then
855
882
USB_ADDRESS=${USB_SERIAL%/ serial}
0 commit comments