summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDevin Moore <devinmoore@google.com>2021-01-25 20:11:48 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-01-25 20:11:48 +0000
commit1ac54b3b41004ec719d695321a6f2f55cf142454 (patch)
tree0db38148581f22970926a259dfd806ebdbba3096 /tests
parentf36c0b69ef2d0690a352acde31e805674d900f52 (diff)
parent5dd7ba40f19360a4d0b5773572f6f11043cdaece (diff)
Merge "Use NativeHandle in MQDescriptor instead of ParcelFileDescriptor" am: 1f00c21c28 am: 689e51eb68 am: 5dd7ba40f1
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1556319 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ica07e57084bf455b9abf10dce158734e2498306c
Diffstat (limited to 'tests')
-rw-r--r--tests/msgq/1.0/ITestMsgQ.hal5
-rw-r--r--tests/msgq/1.0/default/Android.bp3
-rw-r--r--tests/msgq/1.0/default/TestMsgQ.cpp13
-rw-r--r--tests/msgq/1.0/default/TestMsgQ.h3
4 files changed, 19 insertions, 5 deletions
diff --git a/tests/msgq/1.0/ITestMsgQ.hal b/tests/msgq/1.0/ITestMsgQ.hal
index bd10237c90..0cf9c7c71e 100644
--- a/tests/msgq/1.0/ITestMsgQ.hal
+++ b/tests/msgq/1.0/ITestMsgQ.hal
@@ -41,12 +41,15 @@ interface ITestMsgQ {
*
* @param configureFmq The server sets up a new unsynchronized FMQ if
* this parameter is true.
+ * @param userFd True to initialize the message queue with a user supplied
+ * file descriptor for the ring buffer.
+ * False to let the message queue use a single FD for everything.
*
* @return ret True if successful.
* @return mqDesc This structure describes the unsynchronized FMQ that was
* set up by the service. Client can use it to set up the FMQ at its end.
*/
- getFmqUnsyncWrite(bool configureFmq) generates(bool ret, fmq_unsync<int32_t> mqDesc);
+ getFmqUnsyncWrite(bool configureFmq, bool userFd) generates(bool ret, fmq_unsync<int32_t> mqDesc);
/**
* This method request the service to write into the synchronized read/write
diff --git a/tests/msgq/1.0/default/Android.bp b/tests/msgq/1.0/default/Android.bp
index 6e7cd4478b..a50206bb75 100644
--- a/tests/msgq/1.0/default/Android.bp
+++ b/tests/msgq/1.0/default/Android.bp
@@ -91,9 +91,10 @@ cc_test {
// These are static libs only for testing purposes and portability. Shared
// libs should be used on device.
static_libs: [
+ "android.hardware.common-unstable-ndk_platform",
+ "android.hardware.common.fmq-unstable-ndk_platform",
"android.hardware.tests.msgq@1.0",
"android.fmq.test-ndk_platform",
- "android.hardware.common.fmq-unstable-ndk_platform",
],
whole_static_libs: [
"android.hardware.tests.msgq@1.0-impl",
diff --git a/tests/msgq/1.0/default/TestMsgQ.cpp b/tests/msgq/1.0/default/TestMsgQ.cpp
index 44737378b3..4726ffe5e9 100644
--- a/tests/msgq/1.0/default/TestMsgQ.cpp
+++ b/tests/msgq/1.0/default/TestMsgQ.cpp
@@ -41,10 +41,19 @@ Return<bool> TestMsgQ::configureFmqSyncReadWrite(
return true;
}
-Return<void> TestMsgQ::getFmqUnsyncWrite(bool configureFmq, getFmqUnsyncWrite_cb _hidl_cb) {
+Return<void> TestMsgQ::getFmqUnsyncWrite(bool configureFmq, bool userFd,
+ getFmqUnsyncWrite_cb _hidl_cb) {
if (configureFmq) {
static constexpr size_t kNumElementsInQueue = 1024;
- mFmqUnsynchronized.reset(new (std::nothrow) MessageQueueUnsync(kNumElementsInQueue));
+ static constexpr size_t kElementSizeBytes = sizeof(int32_t);
+ android::base::unique_fd ringbufferFd;
+ if (userFd) {
+ ringbufferFd.reset(
+ ::ashmem_create_region("UnsyncWrite", kNumElementsInQueue * kElementSizeBytes));
+ }
+ mFmqUnsynchronized.reset(new (std::nothrow) MessageQueueUnsync(
+ kNumElementsInQueue, false, std::move(ringbufferFd),
+ kNumElementsInQueue * kElementSizeBytes));
}
if ((mFmqUnsynchronized == nullptr) ||
(mFmqUnsynchronized->isValid() == false)) {
diff --git a/tests/msgq/1.0/default/TestMsgQ.h b/tests/msgq/1.0/default/TestMsgQ.h
index 8a204b725d..49675fe306 100644
--- a/tests/msgq/1.0/default/TestMsgQ.h
+++ b/tests/msgq/1.0/default/TestMsgQ.h
@@ -56,7 +56,8 @@ struct TestMsgQ : public ITestMsgQ {
// Methods from ::android::hardware::tests::msgq::V1_0::ITestMsgQ follow.
Return<bool> configureFmqSyncReadWrite(const MQDescriptorSync<int32_t>& mqDesc) override;
- Return<void> getFmqUnsyncWrite(bool configureFmq, getFmqUnsyncWrite_cb _hidl_cb) override;
+ Return<void> getFmqUnsyncWrite(bool configureFmq, bool userFd,
+ getFmqUnsyncWrite_cb _hidl_cb) override;
Return<bool> requestWriteFmqSync(int32_t count) override;
Return<bool> requestReadFmqSync(int32_t count) override;
Return<bool> requestWriteFmqUnsync(int32_t count) override;