summaryrefslogtreecommitdiffstats
path: root/ir
diff options
context:
space:
mode:
authorConnor O'Brien2016-12-20 17:19:08 -0600
committerConnor O'Brien2017-01-19 20:45:52 -0600
commitc75771089a5b62759bce618d8dc326f968f44e7c (patch)
treeb2297c4e5d907e43b2c0e99d73b284390b47c0e4 /ir
parent5c959c69dc92fe1b2606b8531cb1690222e4f106 (diff)
downloadplatform-hardware-interfaces-c75771089a5b62759bce618d8dc326f968f44e7c.tar.gz
platform-hardware-interfaces-c75771089a5b62759bce618d8dc326f968f44e7c.tar.xz
platform-hardware-interfaces-c75771089a5b62759bce618d8dc326f968f44e7c.zip
IR HAL Target-side test
Test: make vts; vts-tradefed run -m HalIrHidlTargetTest Change-Id: I6b750f66a0bc207056abcb493693baebc8af81a5 Signed-off-by: Connor O'Brien <connoro@google.com>
Diffstat (limited to 'ir')
-rw-r--r--ir/1.0/Android.bp103
-rw-r--r--ir/1.0/vts/Android.mk19
-rw-r--r--ir/1.0/vts/ConsumerIr.vts44
-rw-r--r--ir/1.0/vts/functional/Android.bp40
-rw-r--r--ir/1.0/vts/functional/ir_hidl_hal_test.cpp86
-rw-r--r--ir/1.0/vts/functional/vts/testcases/hal/ir/hidl/target/Android.mk23
-rw-r--r--ir/1.0/vts/functional/vts/testcases/hal/ir/hidl/target/AndroidTest.xml31
-rw-r--r--ir/1.0/vts/types.vts21
-rw-r--r--ir/Android.bp1
-rw-r--r--ir/Android.mk19
10 files changed, 387 insertions, 0 deletions
diff --git a/ir/1.0/Android.bp b/ir/1.0/Android.bp
index 3a8fceb4..fb9f070b 100644
--- a/ir/1.0/Android.bp
+++ b/ir/1.0/Android.bp
@@ -54,3 +54,106 @@ cc_library_shared {
54 "android.hidl.base@1.0", 54 "android.hidl.base@1.0",
55 ], 55 ],
56} 56}
57
58genrule {
59 name: "android.hardware.ir.vts.driver@1.0_genc++",
60 tools: ["hidl-gen", "vtsc"],
61 cmd: "$(location hidl-gen) -o $(genDir) -Lvts -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.ir@1.0 && $(location vtsc) -mDRIVER -tSOURCE -b$(genDir) android/hardware/ir/1.0/ $(genDir)/android/hardware/ir/1.0/",
62 srcs: [
63 "types.hal",
64 "IConsumerIr.hal",
65 ],
66 out: [
67 "android/hardware/ir/1.0/types.vts.cpp",
68 "android/hardware/ir/1.0/ConsumerIr.vts.cpp",
69 ],
70}
71
72genrule {
73 name: "android.hardware.ir.vts.driver@1.0_genc++_headers",
74 tools: ["hidl-gen", "vtsc"],
75 cmd: "$(location hidl-gen) -o $(genDir) -Lvts -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.ir@1.0 && $(location vtsc) -mDRIVER -tHEADER -b$(genDir) android/hardware/ir/1.0/ $(genDir)/android/hardware/ir/1.0/",
76 srcs: [
77 "types.hal",
78 "IConsumerIr.hal",
79 ],
80 out: [
81 "android/hardware/ir/1.0/types.vts.h",
82 "android/hardware/ir/1.0/ConsumerIr.vts.h",
83 ],
84}
85
86cc_library_shared {
87 name: "android.hardware.ir.vts.driver@1.0",
88 generated_sources: ["android.hardware.ir.vts.driver@1.0_genc++"],
89 generated_headers: ["android.hardware.ir.vts.driver@1.0_genc++_headers"],
90 export_generated_headers: ["android.hardware.ir.vts.driver@1.0_genc++_headers"],
91 shared_libs: [
92 "libhidlbase",
93 "libhidltransport",
94 "libhwbinder",
95 "liblog",
96 "libutils",
97 "libcutils",
98 "libvts_common",
99 "libvts_datatype",
100 "libvts_measurement",
101 "libvts_multidevice_proto",
102 "libcamera_metadata",
103 "libprotobuf-cpp-full",
104 "android.hidl.base@1.0",
105 "android.hardware.ir@1.0",
106 ],
107 export_shared_lib_headers: [
108 "libhidlbase",
109 "libhidltransport",
110 "libhwbinder",
111 "libutils",
112 "android.hidl.base@1.0",
113 ],
114}
115
116genrule {
117 name: "android.hardware.ir@1.0-IConsumerIr-vts.profiler_genc++",
118 tools: ["hidl-gen", "vtsc"],
119 cmd: "$(location hidl-gen) -o $(genDir) -Lvts -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.ir@1.0 && $(location vtsc) -mPROFILER -tSOURCE -b$(genDir) android/hardware/ir/1.0/ $(genDir)/android/hardware/ir/1.0/",
120 srcs: [
121 "IConsumerIr.hal",
122 "types.hal",
123 ],
124 out: [
125 "android/hardware/ir/1.0/ConsumerIr.vts.cpp",
126 "android/hardware/ir/1.0/types.vts.cpp",
127 ],
128}
129
130genrule {
131 name: "android.hardware.ir@1.0-IConsumerIr-vts.profiler_genc++_headers",
132 tools: ["hidl-gen", "vtsc"],
133 cmd: "$(location hidl-gen) -o $(genDir) -Lvts -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.ir@1.0 && $(location vtsc) -mPROFILER -tHEADER -b$(genDir) android/hardware/ir/1.0/ $(genDir)/android/hardware/ir/1.0/",
134 srcs: [
135 "IConsumerIr.hal",
136 "types.hal",
137 ],
138 out: [
139 "android/hardware/ir/1.0/ConsumerIr.vts.h",
140 "android/hardware/ir/1.0/types.vts.h",
141 ],
142}
143
144cc_library_shared {
145 name: "android.hardware.ir@1.0-IConsumerIr-vts.profiler",
146 generated_sources: ["android.hardware.ir@1.0-IConsumerIr-vts.profiler_genc++"],
147 generated_headers: ["android.hardware.ir@1.0-IConsumerIr-vts.profiler_genc++_headers"],
148 export_generated_headers: ["android.hardware.ir@1.0-IConsumerIr-vts.profiler_genc++_headers"],
149 shared_libs: [
150 "libbase",
151 "libhidlbase",
152 "libhidltransport",
153 "libvts_profiling",
154 "libvts_multidevice_proto",
155 "libprotobuf-cpp-full",
156 "android.hidl.base@1.0",
157 "android.hardware.ir@1.0",
158 ],
159}
diff --git a/ir/1.0/vts/Android.mk b/ir/1.0/vts/Android.mk
new file mode 100644
index 00000000..90c50c89
--- /dev/null
+++ b/ir/1.0/vts/Android.mk
@@ -0,0 +1,19 @@
1#
2# Copyright (C) 2016 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17LOCAL_PATH := $(call my-dir)
18
19include $(LOCAL_PATH)/functional/vts/testcases/hal/ir/hidl/target/Android.mk
diff --git a/ir/1.0/vts/ConsumerIr.vts b/ir/1.0/vts/ConsumerIr.vts
new file mode 100644
index 00000000..bebc6cff
--- /dev/null
+++ b/ir/1.0/vts/ConsumerIr.vts
@@ -0,0 +1,44 @@
1component_class: HAL_HIDL
2component_type_version: 1.0
3component_name: "IConsumerIr"
4
5package: "android.hardware.ir"
6
7import: "android.hardware.ir@1.0::types"
8
9interface: {
10 api: {
11 name: "transmit"
12 return_type_hidl: {
13 type: TYPE_SCALAR
14 scalar_type: "bool_t"
15 }
16 arg: {
17 type: TYPE_SCALAR
18 scalar_type: "int32_t"
19 }
20 arg: {
21 type: TYPE_VECTOR
22 vector_value: {
23 type: TYPE_SCALAR
24 scalar_type: "int32_t"
25 }
26 }
27 }
28
29 api: {
30 name: "getCarrierFreqs"
31 return_type_hidl: {
32 type: TYPE_SCALAR
33 scalar_type: "bool_t"
34 }
35 return_type_hidl: {
36 type: TYPE_VECTOR
37 vector_value: {
38 type: TYPE_STRUCT
39 predefined_type: "::android::hardware::ir::V1_0::ConsumerIrFreqRange"
40 }
41 }
42 }
43
44}
diff --git a/ir/1.0/vts/functional/Android.bp b/ir/1.0/vts/functional/Android.bp
new file mode 100644
index 00000000..c5265de4
--- /dev/null
+++ b/ir/1.0/vts/functional/Android.bp
@@ -0,0 +1,40 @@
1//
2// Copyright (C) 2016 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_test {
18 name: "ir_hidl_hal_test",
19 gtest: true,
20 srcs: ["ir_hidl_hal_test.cpp"],
21 shared_libs: [
22 "libbase",
23 "liblog",
24 "libcutils",
25 "libhidlbase",
26 "libhidltransport",
27 "libhwbinder",
28 "libutils",
29 "android.hardware.ir@1.0",
30 ],
31 static_libs: ["libgtest"],
32 cflags: [
33 "--coverage",
34 "-O0",
35 "-g",
36 ],
37 ldflags: [
38 "--coverage"
39 ]
40}
diff --git a/ir/1.0/vts/functional/ir_hidl_hal_test.cpp b/ir/1.0/vts/functional/ir_hidl_hal_test.cpp
new file mode 100644
index 00000000..57d0b73f
--- /dev/null
+++ b/ir/1.0/vts/functional/ir_hidl_hal_test.cpp
@@ -0,0 +1,86 @@
1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "ir_hidl_hal_test"
18
19#include <android-base/logging.h>
20
21#include <android/hardware/ir/1.0/IConsumerIr.h>
22#include <android/hardware/ir/1.0/types.h>
23
24#include <gtest/gtest.h>
25#include <algorithm>
26
27using ::android::hardware::ir::V1_0::IConsumerIr;
28using ::android::hardware::ir::V1_0::ConsumerIrFreqRange;
29using ::android::hardware::hidl_vec;
30using ::android::hardware::Return;
31using ::android::sp;
32
33// The main test class for IR HIDL HAL.
34class ConsumerIrHidlTest : public ::testing::Test {
35 public:
36 virtual void SetUp() override {
37 ir = IConsumerIr::getService(false);
38 ASSERT_NE(ir, nullptr);
39 }
40
41 virtual void TearDown() override {}
42
43 sp<IConsumerIr> ir;
44};
45
46// Test transmit() for the min and max frequency of every available range
47TEST_F(ConsumerIrHidlTest, TransmitTest) {
48 int32_t freqs;
49 bool success;
50 hidl_vec<ConsumerIrFreqRange> ranges;
51 auto cb = [&](bool s, hidl_vec<ConsumerIrFreqRange> v) {
52 ranges = v;
53 success = s;
54 };
55 Return<void> ret = ir->getCarrierFreqs(cb);
56 ASSERT_TRUE(ret.isOk());
57 ASSERT_TRUE(success);
58
59 if (ranges.size() > 0) {
60 uint32_t len = 16;
61 hidl_vec<int32_t> vec;
62 vec.resize(len);
63 std::fill(vec.begin(), vec.end(), 1);
64 for (auto range = ranges.begin(); range != ranges.end(); range++) {
65 EXPECT_TRUE(ir->transmit(range->min, vec));
66 EXPECT_TRUE(ir->transmit(range->max, vec));
67 }
68 }
69}
70
71// Test transmit() when called with invalid frequencies
72TEST_F(ConsumerIrHidlTest, BadFreqTest) {
73 uint32_t len = 16;
74 hidl_vec<int32_t> vec;
75 vec.resize(len);
76 std::fill(vec.begin(), vec.end(), 1);
77 EXPECT_FALSE(ir->transmit(-1, vec));
78 EXPECT_FALSE(ir->transmit(0, vec));
79}
80
81int main(int argc, char **argv) {
82 ::testing::InitGoogleTest(&argc, argv);
83 int status = RUN_ALL_TESTS();
84 LOG(INFO) << "Test result = " << status;
85 return status;
86}
diff --git a/ir/1.0/vts/functional/vts/testcases/hal/ir/hidl/target/Android.mk b/ir/1.0/vts/functional/vts/testcases/hal/ir/hidl/target/Android.mk
new file mode 100644
index 00000000..a69fd082
--- /dev/null
+++ b/ir/1.0/vts/functional/vts/testcases/hal/ir/hidl/target/Android.mk
@@ -0,0 +1,23 @@
1#
2# Copyright (C) 2016 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17LOCAL_PATH := $(call my-dir)
18
19include $(CLEAR_VARS)
20
21LOCAL_MODULE := HalIrHidlTargetTest
22VTS_CONFIG_SRC_DIR := testcases/hal/ir/hidl/target
23include test/vts/tools/build/Android.host_config.mk
diff --git a/ir/1.0/vts/functional/vts/testcases/hal/ir/hidl/target/AndroidTest.xml b/ir/1.0/vts/functional/vts/testcases/hal/ir/hidl/target/AndroidTest.xml
new file mode 100644
index 00000000..3ad7e452
--- /dev/null
+++ b/ir/1.0/vts/functional/vts/testcases/hal/ir/hidl/target/AndroidTest.xml
@@ -0,0 +1,31 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (C) 2016 The Android Open Source Project
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15-->
16<configuration description="Config for VTS IR HIDL HAL's target-side test cases">
17 <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
18 <option name="push-group" value="HidlHalTest.push" />
19 </target_preparer>
20 <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
21 <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
22 <option name="test-module-name" value="HalIrHidlTargetTest"/>
23 <option name="binary-test-sources" value="
24 _32bit::DATA/nativetest/ir_hidl_hal_test/ir_hidl_hal_test,
25 _64bit::DATA/nativetest64/ir_hidl_hal_test/ir_hidl_hal_test,
26 "/>
27 <option name="binary-test-type" value="hal_hidl_gtest" />
28 <option name="hwbinder-service" value="android.hardware.ir" />
29 <option name="test-timeout" value="1m" />
30 </test>
31</configuration>
diff --git a/ir/1.0/vts/types.vts b/ir/1.0/vts/types.vts
new file mode 100644
index 00000000..d308b1f2
--- /dev/null
+++ b/ir/1.0/vts/types.vts
@@ -0,0 +1,21 @@
1component_class: HAL_HIDL
2component_type_version: 1.0
3component_name: "types"
4
5package: "android.hardware.ir"
6
7
8attribute: {
9 name: "::android::hardware::ir::V1_0::ConsumerIrFreqRange"
10 type: TYPE_STRUCT
11 struct_value: {
12 name: "min"
13 type: TYPE_SCALAR
14 scalar_type: "uint32_t"
15 }
16 struct_value: {
17 name: "max"
18 type: TYPE_SCALAR
19 scalar_type: "uint32_t"
20 }
21} \ No newline at end of file
diff --git a/ir/Android.bp b/ir/Android.bp
index ba90f2c9..ed19a370 100644
--- a/ir/Android.bp
+++ b/ir/Android.bp
@@ -2,4 +2,5 @@
2subdirs = [ 2subdirs = [
3 "1.0", 3 "1.0",
4 "1.0/default", 4 "1.0/default",
5 "1.0/vts/functional",
5] 6]
diff --git a/ir/Android.mk b/ir/Android.mk
new file mode 100644
index 00000000..f9e32763
--- /dev/null
+++ b/ir/Android.mk
@@ -0,0 +1,19 @@
1#
2# Copyright (C) 2016 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17LOCAL_PATH := $(call my-dir)
18
19include $(call all-subdir-makefiles)