1*d9f75844SAndroid Build Coastguard Worker#!/bin/bash 2*d9f75844SAndroid Build Coastguard Worker 3*d9f75844SAndroid Build Coastguard Worker# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 4*d9f75844SAndroid Build Coastguard Worker# 5*d9f75844SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license 6*d9f75844SAndroid Build Coastguard Worker# that can be found in the LICENSE file in the root of the source 7*d9f75844SAndroid Build Coastguard Worker# tree. An additional intellectual property rights grant can be found 8*d9f75844SAndroid Build Coastguard Worker# in the file PATENTS. All contributing project authors may 9*d9f75844SAndroid Build Coastguard Worker# be found in the AUTHORS file in the root of the source tree. 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker# 'adb shell' always returns "0" regardless of executable return code. 12*d9f75844SAndroid Build Coastguard Worker# This handy script will return executable return code to shell which 13*d9f75844SAndroid Build Coastguard Worker# can be used by buildbots. 14*d9f75844SAndroid Build Coastguard Worker 15*d9f75844SAndroid Build Coastguard Workeradb_shell () { 16*d9f75844SAndroid Build Coastguard Worker local RET ADB_LOG 17*d9f75844SAndroid Build Coastguard Worker ADB_LOG=$(mktemp "${TMPDIR:-/tmp}/adb-XXXXXXXX") 18*d9f75844SAndroid Build Coastguard Worker adb "$1" "$2" shell "$3" "$4" ";" echo \$? | tee "$ADB_LOG" 19*d9f75844SAndroid Build Coastguard Worker sed -i -e 's![[:cntrl:]]!!g' "$ADB_LOG" # Remove \r. 20*d9f75844SAndroid Build Coastguard Worker RET=$(sed -e '$!d' "$ADB_LOG") # Last line contains status code. 21*d9f75844SAndroid Build Coastguard Worker rm -f "$ADB_LOG" 22*d9f75844SAndroid Build Coastguard Worker return $RET 23*d9f75844SAndroid Build Coastguard Worker} 24