summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYifan Hong <elsk@google.com>2016-10-14 10:41:41 -0700
committerMartijn Coenen <maco@google.com>2016-10-31 12:02:35 +0000
commitebfa633103e4efbe4c39c8abf906ae597a1d7a5b (patch)
tree889563409884812fddec98373212f49a285ab90f /tests
parent058ee272fd890d480bbab84371b386f1da769e78 (diff)
downloadplatform_hardware_interfaces-ebfa633103e4efbe4c39c8abf906ae597a1d7a5b.tar.gz
platform_hardware_interfaces-ebfa633103e4efbe4c39c8abf906ae597a1d7a5b.tar.bz2
platform_hardware_interfaces-ebfa633103e4efbe4c39c8abf906ae597a1d7a5b.zip
Add interface methods for testing vec<handle>.
Test: hidl_test Bug: 32160974 Change-Id: I7eda1650fcf8d58778b2aad97a5bd62afc95bc36
Diffstat (limited to 'tests')
-rw-r--r--tests/bar/1.0/default/Android.bp1
-rw-r--r--tests/bar/1.0/default/Bar.cpp12
-rw-r--r--tests/bar/1.0/default/Bar.h3
-rw-r--r--tests/foo/1.0/IFoo.hal8
-rw-r--r--tests/foo/1.0/default/Android.bp1
-rw-r--r--tests/foo/1.0/default/Foo.cpp33
-rw-r--r--tests/foo/1.0/default/Foo.h6
7 files changed, 64 insertions, 0 deletions
diff --git a/tests/bar/1.0/default/Android.bp b/tests/bar/1.0/default/Android.bp
index 0d47001c81..c2c2309bb8 100644
--- a/tests/bar/1.0/default/Android.bp
+++ b/tests/bar/1.0/default/Android.bp
@@ -10,6 +10,7 @@ cc_library_shared {
shared_libs: [
"libbase",
+ "libcutils",
"libhidl",
"libhwbinder",
"liblog",
diff --git a/tests/bar/1.0/default/Bar.cpp b/tests/bar/1.0/default/Bar.cpp
index 34ec087e23..b960524b20 100644
--- a/tests/bar/1.0/default/Bar.cpp
+++ b/tests/bar/1.0/default/Bar.cpp
@@ -130,6 +130,18 @@ Return<void> Bar::haveAVectorOfGenericInterfaces(
return Void();
}
+Return<void> Bar::createMyHandle(createMyHandle_cb _hidl_cb) {
+ return mFoo->createMyHandle(_hidl_cb);
+}
+
+Return<void> Bar::createHandles(uint32_t size, createHandles_cb _hidl_cb) {
+ return mFoo->createHandles(size, _hidl_cb);
+}
+
+Return<void> Bar::closeHandles() {
+ return mFoo->closeHandles();
+}
+
// Methods from ::android::hardware::tests::bar::V1_0::IBar follow.
Return<void> Bar::thisIsNew() {
ALOGI("SERVER(Bar) thisIsNew");
diff --git a/tests/bar/1.0/default/Bar.h b/tests/bar/1.0/default/Bar.h
index d2c2635e52..6fea563048 100644
--- a/tests/bar/1.0/default/Bar.h
+++ b/tests/bar/1.0/default/Bar.h
@@ -48,6 +48,9 @@ struct Bar : public IBar {
virtual Return<void> transpose2(const hidl_array<hidl_string, 5 /* 5 */, 3 /* 3 */>& in, transpose2_cb _hidl_cb) override;
virtual Return<void> sendVec(const hidl_vec<uint8_t>& data, sendVec_cb _hidl_cb) override;
virtual Return<void> sendVecVec(sendVecVec_cb _hidl_cb) override;
+ virtual Return<void> createMyHandle(createMyHandle_cb _hidl_cb) override;
+ virtual Return<void> createHandles(uint32_t size, createHandles_cb _hidl_cb) override;
+ virtual Return<void> closeHandles() override;
Return<void> haveAVectorOfInterfaces(
const hidl_vec<sp<ISimple> > &in,
diff --git a/tests/foo/1.0/IFoo.hal b/tests/foo/1.0/IFoo.hal
index 2afaec1b5d..c06fc05b8f 100644
--- a/tests/foo/1.0/IFoo.hal
+++ b/tests/foo/1.0/IFoo.hal
@@ -80,6 +80,11 @@ interface IFoo {
FloatArray myFloatArray;
};
+ struct MyHandle {
+ handle h;
+ int32_t guard;
+ };
+
doThis(float param);
doThatAndReturnSomething(int64_t param) generates (int32_t result);
doQuiteABit(int32_t a, int64_t b, float c, double d) generates (double something);
@@ -112,4 +117,7 @@ interface IFoo {
haveAVectorOfGenericInterfaces(vec<interface> in)
generates (vec<interface> out);
+ createMyHandle() generates (MyHandle h);
+ createHandles(uint32_t size) generates (vec<handle> handles);
+ closeHandles();
};
diff --git a/tests/foo/1.0/default/Android.bp b/tests/foo/1.0/default/Android.bp
index 185e5ea465..f2ee521002 100644
--- a/tests/foo/1.0/default/Android.bp
+++ b/tests/foo/1.0/default/Android.bp
@@ -10,6 +10,7 @@ cc_library_shared {
shared_libs: [
"libbase",
+ "libcutils",
"libhidl",
"libfootest",
"libhwbinder",
diff --git a/tests/foo/1.0/default/Foo.cpp b/tests/foo/1.0/default/Foo.cpp
index f855f21e05..cf4f9755c6 100644
--- a/tests/foo/1.0/default/Foo.cpp
+++ b/tests/foo/1.0/default/Foo.cpp
@@ -291,7 +291,40 @@ Return<void> Foo::haveAVectorOfGenericInterfaces(
const hidl_vec<sp<android::hardware::IBinder> > &in,
haveAVectorOfGenericInterfaces_cb _hidl_cb) {
_hidl_cb(in);
+ return Void();
+}
+
+Return<void> Foo::createMyHandle(createMyHandle_cb _hidl_cb) {
+ native_handle_t* nh = native_handle_create(0, 10);
+ int data[] = {2,3,5,7,11,13,17,19,21,23};
+ CHECK(sizeof(data) == 10 * sizeof(int));
+ memcpy(nh->data, data, sizeof(data));
+ mHandles.push_back(nh);
+
+ MyHandle h;
+ h.guard = 666;
+ h.h = nh;
+ _hidl_cb(h);
+ return Void();
+}
+Return<void> Foo::createHandles(uint32_t size, createHandles_cb _hidl_cb) {
+ hidl_vec<const native_handle_t*> handles;
+ handles.resize(size);
+ for(uint32_t i = 0; i < size; ++i) {
+ createMyHandle([&](const MyHandle& h) {
+ handles[i] = h.h;
+ });
+ }
+ _hidl_cb(handles);
+ return Void();
+}
+
+Return<void> Foo::closeHandles() {
+ for(native_handle_t* h : mHandles) {
+ native_handle_delete(h);
+ }
+ mHandles.clear();
return Void();
}
diff --git a/tests/foo/1.0/default/Foo.h b/tests/foo/1.0/default/Foo.h
index b3785d2c1c..e61291d563 100644
--- a/tests/foo/1.0/default/Foo.h
+++ b/tests/foo/1.0/default/Foo.h
@@ -5,6 +5,7 @@
#include <hidl/Status.h>
#include <hidl/MQDescriptor.h>
+#include <vector>
namespace android {
namespace hardware {
namespace tests {
@@ -44,6 +45,9 @@ struct Foo : public IFoo {
virtual Return<void> transpose2(const hidl_array<hidl_string, 5 /* 5 */, 3 /* 3 */>& in, transpose2_cb _hidl_cb) override;
virtual Return<void> sendVec(const hidl_vec<uint8_t>& data, sendVec_cb _hidl_cb) override;
virtual Return<void> sendVecVec(sendVecVec_cb _hidl_cb) override;
+ virtual Return<void> createMyHandle(createMyHandle_cb _hidl_cb) override;
+ virtual Return<void> createHandles(uint32_t size, createHandles_cb _hidl_cb) override;
+ virtual Return<void> closeHandles() override;
Return<void> haveAVectorOfInterfaces(
const hidl_vec<sp<ISimple> > &in,
@@ -52,6 +56,8 @@ struct Foo : public IFoo {
Return<void> haveAVectorOfGenericInterfaces(
const hidl_vec<sp<android::hardware::IBinder> > &in,
haveAVectorOfGenericInterfaces_cb _hidl_cb) override;
+private:
+ std::vector<::native_handle_t *> mHandles;
};
extern "C" IFoo* HIDL_FETCH_IFoo(const char* name);