OSDN Git Service

Tests for Reference Support.
authorYifan Hong <elsk@google.com>
Tue, 23 Aug 2016 23:50:55 +0000 (16:50 -0700)
committerYifan Hong <elsk@google.com>
Thu, 29 Sep 2016 21:57:22 +0000 (14:57 -0700)
Bug: 31300815 pointer support
Bug: 31349114 nested types
Bug: 31757611 Parcel ref# cap

Test: `make hidl_test && adb sync && adb shell hidl_test`
      Only works with a kernel patch.

Change-Id: I48351b1bf861a4d2d77f823f7242524156cde1e7

tests/pointer/1.0/Android.mk [new file with mode: 0644]
tests/pointer/1.0/IGraph.hal [new file with mode: 0644]
tests/pointer/1.0/IPointer.hal [new file with mode: 0644]

diff --git a/tests/pointer/1.0/Android.mk b/tests/pointer/1.0/Android.mk
new file mode 100644 (file)
index 0000000..d1c23bf
--- /dev/null
@@ -0,0 +1,53 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := android.hardware.tests.pointer@1.0
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+
+intermediates := $(local-generated-sources-dir)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+#
+# Build IGraph.hal
+#
+GEN := $(intermediates)/android/hardware/tests/pointer/1.0/GraphAll.cpp
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IGraph.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+    $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+    -Lc++ -randroid.hardware:hardware/interfaces \
+    android.hardware.tests.pointer@1.0::IGraph
+
+$(GEN): $(LOCAL_PATH)/IGraph.hal
+       $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IPointer.hal
+#
+GEN := $(intermediates)/android/hardware/tests/pointer/1.0/PointerAll.cpp
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IPointer.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+    $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+    -Lc++ -randroid.hardware:hardware/interfaces \
+    android.hardware.tests.pointer@1.0::IPointer
+
+$(GEN): $(LOCAL_PATH)/IPointer.hal
+       $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(intermediates)
+LOCAL_SHARED_LIBRARIES := \
+  libhidl \
+  libhwbinder \
+  libutils \
+  libcutils \
+
+LOCAL_MULTILIB := both
+include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/pointer/1.0/IGraph.hal b/tests/pointer/1.0/IGraph.hal
new file mode 100644 (file)
index 0000000..0853745
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.tests.pointer@1.0;
+
+interface IGraph {
+
+  struct Node {
+    int32_t data;
+  };
+  struct Edge {
+    ref<Node> left;
+    ref<Node> right;
+  };
+  struct Graph {
+    vec<Node> nodes;
+    vec<Edge> edges;
+  };
+
+  struct Theta {
+    int32_t data;
+  };
+  struct Alpha {
+    ref<Theta> s_ptr;
+  };
+  struct Beta {
+    ref<Theta> s_ptr;
+  };
+  struct Gamma {
+    ref<Alpha> a_ptr;
+    ref<Beta> b_ptr;
+  };
+
+  passANode(Node n);
+  passAGraph(Graph g);
+  passTwoGraphs(ref<Graph> g1, ref<Graph> g2);
+  giveAGraph() generates (Graph g);
+  passAGamma(Gamma c);
+  passASimpleRef(ref<Alpha> a);
+  passASimpleRefS(ref<Theta> s);
+  giveASimpleRef() generates (ref<Alpha> a);
+
+  getErrors() generates (int32_t errors);
+};
diff --git a/tests/pointer/1.0/IPointer.hal b/tests/pointer/1.0/IPointer.hal
new file mode 100644 (file)
index 0000000..e68fb31
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.tests.pointer@1.0;
+
+interface IPointer {
+  // type declarations
+  struct Sam { int32_t data; };
+  struct Ada { ref<Sam> s_ptr; };
+  struct Bob { ref<Ada> a_ptr; ref<Sam> s_ptr; };
+  struct Cin { Ada a; ref<Bob> b_ptr; };
+  struct Dom { Cin c; };
+
+  typedef ref<int32_t> Int32Ptr;
+  typedef ref<Sam>     SamPtr;
+
+  struct Ptr {
+    ref<Ada>[5] ptr_array;
+    ref<Ada[5]> array_ptr;
+    Int32Ptr int_ptr;
+    ref<int32_t[5]> int_array_ptr;
+    ref<int32_t>[5] int_ptr_array;
+    ref<string> str_ref;
+    vec<ref<Ada>> a_ptr_vec;
+    ref<vec<Ada>> a_vec_ptr;
+  };
+
+  // test cases
+  foo1(Sam s, SamPtr s_ptr);
+  foo2(Sam s, Ada a);
+  foo3(Sam s, Ada a, Bob b);
+  foo4(ref<Sam> s_ptr);
+  foo5(Ada a, Bob b);
+  foo6(ref<Ada> a_ptr);
+  foo7(ref<Ada> a_ptr, ref<Bob> b_ptr);
+  foo8(Dom d);
+  foo9(ref<string> str_ref);
+  foo10(vec<ref<Sam>> s_ptr_vec);
+  foo11(ref<vec<Sam>> s_vec_ptr);
+  foo12(ref<Sam[5]> s_array_ref);
+  foo13(ref<Sam>[5] s_ref_array);
+  foo14(ref<ref<ref<Sam>>> s_3ptr);
+  foo15(ref<ref<ref<int32_t>>> i_3ptr);
+  foo16(Ptr p);
+  foo17(ref<Ptr> p);
+  foo18(ref<string> str_ref, ref<string> str_ref2, string str);
+  foo19(ref<vec<Ada>> a_vec_ref, vec<Ada> a_vec, ref<vec<Ada>> a_vec_ref2);
+  foo20(vec<ref<Sam>> s_ptr_vec);
+  foo21(ref<Ada[1][2][3]> a_array_ptr);
+  foo22(ref<Ada>[1][2][3] a_ptr_array);
+
+  bar1() generates (Sam s, ref<Sam> s_ptr);
+  bar2() generates (Sam s, Ada a);
+  bar3() generates (Sam s, Ada a, Bob b);
+  bar4() generates (ref<Sam> s_ptr);
+  bar5() generates (Ada a, Bob b);
+  bar6() generates (ref<Ada> a_ptr);
+  bar7() generates (ref<Ada> a_ptr, ref<Bob> b_ptr);
+  bar8() generates (Dom d);
+  bar9() generates (ref<string> str_ref);
+  bar10() generates (vec<ref<Sam>> s_ptr_vec);
+  bar11() generates (ref<vec<Sam>> s_vec_ptr);
+  bar12() generates (ref<Sam[5]> s_array_ref);
+  bar13() generates (ref<Sam>[5] s_ref_array);
+  bar14() generates (ref<ref<ref<Sam>>> s_3ptr);
+  bar15() generates (ref<ref<ref<int32_t>>> i_3ptr);
+  bar16() generates (Ptr p);
+  bar17() generates (ref<Ptr> p);
+  bar18() generates (ref<string> str_ref, ref<string> str_ref2, string str);
+  bar19() generates (ref<vec<Ada>> a_vec_ref, vec<Ada> a_vec, ref<vec<Ada>> a_vec_ref2);
+  bar20() generates (vec<ref<Sam>> s_ptr_vec);
+  bar21() generates (ref<Ada[1][2][3]> a_array_ptr);
+  bar22() generates (ref<Ada>[1][2][3] a_ptr_array);
+
+  getErrors() generates(int32_t errors);
+};