1#!/bin/bash 2 3if [ $# -ne 1 ]; then 4 echo "usage: hidl_error_test.sh hidl-gen_path" 5 exit 1 6fi 7 8readonly HIDL_GEN_PATH=$1 9readonly HIDL_ERROR_TEST_DIR="$ANDROID_BUILD_TOP/system/tools/hidl/test/error_test" 10 11for dir in $(ls -d $HIDL_ERROR_TEST_DIR/*/); do 12 package=$(basename $dir) 13 output=$($HIDL_GEN_PATH -L check -r test:$HIDL_ERROR_TEST_DIR test.$package@1.0 2>&1) 14 command_fails=$? 15 error=$(cat $HIDL_ERROR_TEST_DIR/$package/1.0/required_error) 16 17 if [[ $error == "" ]]; then 18 echo "error: No required error message specified for $package." 19 echo "$output" | while read line; do echo "test output: $line"; done 20 exit 1 21 fi 22 23 if [ $command_fails -ne 1 ]; then 24 echo "error: $package test did not fail" 25 exit 1 26 fi 27 28 if [[ $output != *$error* ]]; then 29 echo "error: error output for $package does not contain '$error':" 30 echo "$output" | while read line; do echo "test output: $line"; done 31 exit 1 32 fi 33 34done 35