File: hidl_error_test.sh

package info (click to toggle)
android-platform-system-tools-hidl 10.0.0%2Br36-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,928 kB
  • sloc: cpp: 21,932; yacc: 1,416; java: 1,239; lex: 496; sh: 360; python: 44; xml: 20; makefile: 12
file content (39 lines) | stat: -rwxr-xr-x 1,079 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash

if [ $# -gt 1 ]; then
    echo "usage: hidl_error_test.sh hidl-gen_path"
    exit 1
fi

readonly HIDL_GEN_PATH=${1:-hidl-gen}
readonly HIDL_ERROR_TEST_DIR="${ANDROID_BUILD_TOP:-.}/system/tools/hidl/test/error_test"

if [ ! -d $HIDL_ERROR_TEST_DIR ]; then
    echo "cannot find test directory: $HIDL_ERROR_TEST_DIR"
    exit 1
fi

for dir in $(ls -d $HIDL_ERROR_TEST_DIR/*/); do
  package=$(basename $dir)
  output=$($HIDL_GEN_PATH -L check -r test:$HIDL_ERROR_TEST_DIR test.$package@1.0 2>&1)
  command_fails=$?
  error=$(cat $HIDL_ERROR_TEST_DIR/$package/1.0/required_error)

  if [[ $error == "" ]]; then
    echo "error: No required error message specified for $package."
    echo "$output" | while read line; do echo "test output: $line"; done
    exit 1
  fi

  if [ $command_fails -ne 1 ]; then
    echo "error: $package test did not fail"
    exit 1
  fi

  if [[ $output != *$error* ]]; then
    echo "error: error output for $package does not contain '$error':"
    echo "$output" | while read line; do echo "test output: $line"; done
    exit 1
  fi

done