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