blob: d40cf2801d5888f216055d3798303c11f9664735 [file] [log] [blame]
Yifan Hong3d5587c2016-12-09 15:18:22 -08001#!/bin/bash
2
Yifan Hong2ef6b392017-03-03 14:46:00 -08003# Run hidl-gen against interfaces in errors/ to ensure it detects as many
4# errors as possible.
Yifan Hong3d5587c2016-12-09 15:18:22 -08005
Yifan Hong2ef6b392017-03-03 14:46:00 -08006if [ ! -d system/tools/hidl/test/errors/ ]; then
7 echo "Where is system/tools/hidl/test/errors?";
8 exit 1;
Yifan Hong3d5587c2016-12-09 15:18:22 -08009fi
10
11# TODO(b/33276472)
Yifan Hong2ef6b392017-03-03 14:46:00 -080012if [ ! -d system/libhidl/transport ]; then
13 echo "Where is system/libhidl/transport?";
14 exit 1;
Yifan Hong3d5587c2016-12-09 15:18:22 -080015fi
16
Yifan Hong2ef6b392017-03-03 14:46:00 -080017if [[ "$@" == *"-h"* ]]; then
18 echo "$0 [-h|-u|-a]"
Yifan Hong3d5587c2016-12-09 15:18:22 -080019 echo " (No options) Run and diff against expected output"
20 echo " -u Update expected output"
21 echo " -a Run and show actual output"
22 echo " -h Show help text"
Yifan Hong2ef6b392017-03-03 14:46:00 -080023 exit 1
Yifan Hong3d5587c2016-12-09 15:18:22 -080024fi
Yifan Hong2ef6b392017-03-03 14:46:00 -080025
26if [[ "$@" == *"-u"* ]]; then update_files=true; fi
27if [[ "$@" == *"-a"* ]]; then show_output=true; fi
28
29function check() {
30 local "${@}"
31 COMMAND="hidl-gen -Lc++ -rtests:system/tools/hidl/test -randroid.hidl:system/libhidl/transport -o /tmp $package"
32
33 if [ $show_output ]; then
34 echo "Running: $COMMAND"
35 $COMMAND
36 echo
37 return
38 fi
39
40 if [[ ! -z "$contains" ]]; then
41 if [ $update_files ]; then
42 # no files to update
43 return
44 fi
45 $COMMAND 2>&1 | grep "$contains" -q
46 if [ $? -eq 0 ]; then
47 echo "Success for $package."
48 else
49 echo "Fail for $package; output doesn't contain '$contains'"
50 fi
51 return
52 fi
53
54 EXPECTED="system/tools/hidl/test/$filename"
55 if [ $update_files ]; then
56 $COMMAND 2>$EXPECTED;
57 echo "Updated $filename."
58 else
59 $COMMAND 2>&1 | diff $EXPECTED -
60 if [ $? -eq 0 ]; then
61 echo "Success for $package."
62 fi
63 fi
64}
65
66check package="tests.errors.syntax@1.0" filename="errors/syntax.output"
67
68check package="tests.errors.versioning@2.2" \
69 contains="Cannot enforce minor version uprevs for tests.errors.versioning@2.2"
70
71check package="tests.errors.versioning@3.3" \
72 contains="Cannot enforce minor version uprevs for tests.errors.versioning@3.3"