blob: 53af18764edf20b52f5fc895e3d0515fbc5dd425 [file] [log] [blame]
Stefano Galarraga0feafed2020-06-09 16:57:01 +01001#!/bin/bash
2
3# Copyright 2020, The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Tails android system logs releven for crash tests
18
19show_usage_and_exit() {
20 echo "Tail logcat for NNAPI Crash Test logs, driver error logs and failures. Options:"
21 echo " -e | --show_driver_errors : to enable error log for drivers"
22 echo " -d | --driver_log_tag TAG : to use in conjunction with -e specify the LOG tags used by the target driver."
23 echo " To specify multiple tags just quote them and separate them with a space char."
24 echo " If this option is omitted, a list of known tags is used."
25 echo " -o | --save_output_to FILE : to save logcat output to the given file"
26 echo " -s DEVICE_SERIAL_NUMBER : to specify the serial number of the device to connect to"
27 echo " -h : show this message and exit"
28 exit 1
29}
30
31OPTS="$(getopt -o heo:s:d: -l show_driver_errors,save_output_to:driver_log_tag: -- "$@")"
32eval set -- "$OPTS"
33
34SHOW_DRIVERS_ERRORS=false
35OUTPUT_FILE=""
36DEVICE_ID_OPT=""
37DRIVER_LOG_TAGS=()
38while [ $# -gt 0 ] ; do
39 case "$1" in
40 -h)
41 shift
42 show_usage_and_exit
43 ;;
44 -e|--show_driver_errors)
45 SHOW_DRIVERS_ERRORS=true
46 shift
47 ;;
48 -o|--save_output_to)
49 OUTPUT_FILE="$2"
50 shift 2
51 ;;
52 -s)
53 DEVICE_ID_OPT="-s $2"
54 shift 2
55 ;;
56 -d|--driver_log_tag)
57 read -a DRIVER_LOG_TAGS <<< "$2"
58 shift 2
59 ;;
60 -- )
61 shift
62 break
63 ;;
64 * )
65 echo "Invalid argument: $1"
66 show_usage_and_exit
67 ;;
68 esac
69done
70
Stefano Galarraga57b6e4c2021-09-10 15:18:12 +010071CRASH_TEST_LOG_TAGS+=("NN_BENCHMARK" "NN_TESTBASE")
Stefano Galarraga0feafed2020-06-09 16:57:01 +010072while IFS='' read -r tag; do
73 CRASH_TEST_LOG_TAGS+=("$tag");
74done <<< $(find src/com/android/nn/crashtest -name '*.java' -exec grep "TAG =" {} \; \
75 | grep -Po '(?<=")(.+)(?=")')
76
77LOG_TAG_FILTER=""
78
79# Info level from crash tests source
80for tag in "${CRASH_TEST_LOG_TAGS[@]}"; do
81 LOG_TAG_FILTER="${LOG_TAG_FILTER} ${tag}:I"
82done
83
84if [[ "$SHOW_DRIVERS_ERRORS" = true ]]; then
85 if [ ${#DRIVER_LOG_TAGS[@]} -eq 0 ]; then
86 # Qualcomm (drivers for NNAPI1.2)
87 # Google
88 # SLSI
89 DRIVER_LOG_TAGS=(\
90 "android.hardware.neuralnetworks@1.2-service"\
91 "Darwinn"\
92 "Eden"\
93 )
94 fi
95
96 # Error level for listed driver processes
97 for tag in "${DRIVER_LOG_TAGS[@]}"; do
98 LOG_TAG_FILTER="${LOG_TAG_FILTER} ${tag}:E"
99 done
100elif [ ${#DRIVER_LOG_TAGS[@]} -ne 0 ]; then
101 show_usage_and_exit
102fi
103
104# Fatal message for everything else to show crash dumps
Stefano Galarragafdbb44e2021-10-04 17:20:17 +0100105LOG_TAG_FILTER="${LOG_TAG_FILTER} QCSL:V tflite:E *:F"
Stefano Galarraga0feafed2020-06-09 16:57:01 +0100106
107export ANDROID_LOG_TAGS="${LOG_TAG_FILTER}"
108
109if [[ -z "$OUTPUT_FILE" ]]; then
110 adb ${DEVICE_ID_OPT:+"$DEVICE_ID_OPT"} logcat -v color
111else
112 adb ${DEVICE_ID_OPT:+"$DEVICE_ID_OPT"} logcat -v color | tee "$OUTPUT_FILE"
113fi
114
115
116