Snap for 8564071 from 00d4c39486f5b6c133e5f8ec99af7e007c4e3ed0 to mainline-wifi-release
Change-Id: Ia2d7af6d5be26aa5d1eb5e26bd6c545be2547ff1
diff --git a/Android.bp b/Android.bp
index 5889a9c..f37f1c6 100644
--- a/Android.bp
+++ b/Android.bp
@@ -30,7 +30,10 @@
],
apex_available: [
"//apex_available:platform",
+ "com.android.bluetooth",
+ "com.android.media.swcodec",
"com.android.neuralnetworks",
+ "test_com.android.media.swcodec",
"test_com.android.neuralnetworks",
],
export_include_dirs: ["include"],
diff --git a/EventFlag.cpp b/EventFlag.cpp
index 96f9519..d353873 100644
--- a/EventFlag.cpp
+++ b/EventFlag.cpp
@@ -32,26 +32,6 @@
namespace android {
namespace hardware {
-status_t EventFlag::createEventFlag(int fd, off_t offset, EventFlag** flag) {
- if (flag == nullptr) {
- return BAD_VALUE;
- }
-
- status_t status = NO_MEMORY;
- *flag = nullptr;
-
- EventFlag* evFlag = new (std::nothrow) EventFlag(fd, offset, &status);
- if (evFlag != nullptr) {
- if (status == NO_ERROR) {
- *flag = evFlag;
- } else {
- delete evFlag;
- }
- }
-
- return status;
-}
-
status_t EventFlag::createEventFlag(std::atomic<uint32_t>* fwAddr,
EventFlag** flag) {
if (flag == nullptr) {
@@ -74,23 +54,6 @@
}
/*
- * mmap memory for the futex word
- */
-EventFlag::EventFlag(int fd, off_t offset, status_t* status) {
- mEfWordPtr = static_cast<std::atomic<uint32_t>*>(mmap(NULL,
- sizeof(std::atomic<uint32_t>),
- PROT_READ | PROT_WRITE,
- MAP_SHARED, fd, offset));
- mEfWordNeedsUnmapping = true;
- if (mEfWordPtr != MAP_FAILED) {
- *status = NO_ERROR;
- } else {
- *status = -errno;
- ALOGE("Attempt to mmap event flag word failed: %s\n", strerror(errno));
- }
-}
-
-/*
* Use this constructor if we already know where the futex word for
* the EventFlag group lives.
*/
diff --git a/FmqInternal.cpp b/FmqInternal.cpp
index 886d155..6aad3aa 100644
--- a/FmqInternal.cpp
+++ b/FmqInternal.cpp
@@ -26,6 +26,10 @@
CHECK(exp);
}
+void check(bool exp, const char* message) {
+ CHECK(exp) << message;
+}
+
void logError(const std::string &message) {
LOG(ERROR) << message;
}
diff --git a/OWNERS b/OWNERS
index d19e4ea..cc4d814 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,4 +1,4 @@
smoreland@google.com
elsk@google.com
malchev@google.com
-hridya@google.com
+devinmoore@google.com
diff --git a/TEST_MAPPING b/TEST_MAPPING
index dfa7071..9f1aa6b 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -6,5 +6,13 @@
{
"name": "fmq_test"
}
+ ],
+ "hwasan-postsubmit": [
+ {
+ "name": "fmq_unit_tests"
+ },
+ {
+ "name": "fmq_test"
+ }
]
}
diff --git a/base/fmq/MQDescriptorBase.h b/base/fmq/MQDescriptorBase.h
index 0d18d4c..7303917 100644
--- a/base/fmq/MQDescriptorBase.h
+++ b/base/fmq/MQDescriptorBase.h
@@ -55,6 +55,7 @@
void logError(const std::string& message);
void errorWriteLog(int tag, const char* message);
+void check(bool exp, const char* message);
typedef uint64_t RingBufferPosition;
enum GrantorType : int { READPTRPOS = 0, WRITEPTRPOS, DATAPTRPOS, EVFLAGWORDPOS };
@@ -73,20 +74,12 @@
static inline size_t alignToWordBoundary(size_t length) {
constexpr size_t kAlignmentSize = 64;
- if (kAlignmentSize % __WORDSIZE != 0) {
-#ifdef __BIONIC__
- __assert(__FILE__, __LINE__, "Incompatible word size");
-#endif
- }
+ static_assert(kAlignmentSize % sizeof(long) == 0, "Incompatible word size");
/*
* Check if alignment to word boundary would cause an overflow.
*/
- if (length > SIZE_MAX - kAlignmentSize / 8 + 1) {
-#ifdef __BIONIC__
- __assert(__FILE__, __LINE__, "Queue size too large");
-#endif
- }
+ check(length <= SIZE_MAX - kAlignmentSize / 8 + 1, "Queue size too large");
return (length + kAlignmentSize / 8 - 1) & ~(kAlignmentSize / 8 - 1U);
}
diff --git a/fuzzer/Android.bp b/fuzzer/Android.bp
index 6b41e3f..0926c09 100644
--- a/fuzzer/Android.bp
+++ b/fuzzer/Android.bp
@@ -19,17 +19,19 @@
cc_fuzz {
name: "fmq_fuzzer",
- defaults: [
- "libbinder_ndk_host_user",
- ],
-
srcs: [
"fmq_fuzzer.cpp",
],
+ target: {
+ darwin: {
+ enabled: false,
+ },
+ },
+
static_libs: [
"libfmq",
- "android.hardware.common.fmq-V1-ndk_platform",
+ "android.hardware.common.fmq-V1-ndk",
],
shared_libs: [
@@ -54,9 +56,9 @@
host_supported: true,
sanitize: {
- hwaddress: true,
scs: true,
cfi: true,
+ address: true,
memtag_heap: true,
// undefined behavior is expected
all_undefined: false,
diff --git a/fuzzer/fmq_fuzzer.cpp b/fuzzer/fmq_fuzzer.cpp
index 844188f..8c8a78e 100644
--- a/fuzzer/fmq_fuzzer.cpp
+++ b/fuzzer/fmq_fuzzer.cpp
@@ -21,6 +21,7 @@
#include <thread>
#include <android-base/logging.h>
+#include <android-base/scopeguard.h>
#include <fmq/AidlMessageQueue.h>
#include <fmq/ConvertMQDescriptors.h>
#include <fmq/EventFlag.h>
@@ -35,6 +36,9 @@
typedef int32_t payload_t;
+// The reader will wait for 10 ms
+static constexpr int kBlockingTimeoutNs = 10000000;
+
/*
* MessageQueueBase.h contains asserts when memory allocation fails. So we need
* to set a reasonable limit if we want to avoid those asserts.
@@ -55,6 +59,7 @@
static constexpr int kMaxNumSyncReaders = 1;
static constexpr int kMaxNumUnsyncReaders = 5;
+static constexpr int kMaxDataPerReader = 1000;
typedef android::AidlMessageQueue<payload_t, SynchronizedReadWrite> AidlMessageQueueSync;
typedef android::AidlMessageQueue<payload_t, UnsynchronizedWrite> AidlMessageQueueUnsync;
@@ -67,14 +72,19 @@
typedef android::hardware::MQDescriptorSync<payload_t> MQDescSync;
typedef android::hardware::MQDescriptorUnsync<payload_t> MQDescUnsync;
+static inline uint64_t* getCounterPtr(payload_t* start, int byteOffset) {
+ return reinterpret_cast<uint64_t*>(reinterpret_cast<uint8_t*>(start) - byteOffset);
+}
+
template <typename Queue, typename Desc>
-void reader(const Desc& desc, std::vector<uint8_t> readerData) {
+void reader(const Desc& desc, std::vector<uint8_t> readerData, bool userFd) {
Queue readMq(desc);
if (!readMq.isValid()) {
LOG(ERROR) << "read mq invalid";
return;
}
FuzzedDataProvider fdp(&readerData[0], readerData.size());
+ payload_t* ring = nullptr;
while (fdp.remaining_bytes()) {
typename Queue::MemTransaction tx;
size_t numElements = fdp.ConsumeIntegralInRange<size_t>(0, kMaxNumElements);
@@ -84,19 +94,57 @@
const auto& region = tx.getFirstRegion();
payload_t* firstStart = region.getAddress();
- // TODO add the debug function to get pointer to the ring buffer
- uint64_t* writeCounter = reinterpret_cast<uint64_t*>(
- reinterpret_cast<uint8_t*>(firstStart) - kWriteCounterOffsetBytes);
- *writeCounter = fdp.ConsumeIntegral<uint64_t>();
-
+ // the ring buffer is only next to the read/write counters when there is
+ // no user supplied fd
+ if (!userFd) {
+ if (ring == nullptr) {
+ ring = firstStart;
+ }
+ if (fdp.ConsumeIntegral<uint8_t>() == 1) {
+ uint64_t* writeCounter = getCounterPtr(ring, kWriteCounterOffsetBytes);
+ *writeCounter = fdp.ConsumeIntegral<uint64_t>();
+ }
+ }
(void)std::to_string(*firstStart);
readMq.commitRead(numElements);
}
}
+template <typename Queue, typename Desc>
+void readerBlocking(const Desc& desc, std::vector<uint8_t>& readerData,
+ std::atomic<size_t>& readersNotFinished,
+ std::atomic<size_t>& writersNotFinished) {
+ android::base::ScopeGuard guard([&readersNotFinished]() { readersNotFinished--; });
+ Queue readMq(desc);
+ if (!readMq.isValid()) {
+ LOG(ERROR) << "read mq invalid";
+ return;
+ }
+ FuzzedDataProvider fdp(&readerData[0], readerData.size());
+ do {
+ size_t count = fdp.remaining_bytes()
+ ? fdp.ConsumeIntegralInRange<size_t>(1, readMq.getQuantumCount())
+ : 1;
+ std::vector<payload_t> data;
+ data.resize(count);
+ readMq.readBlocking(data.data(), count, kBlockingTimeoutNs);
+ } while (fdp.remaining_bytes() > sizeof(size_t) && writersNotFinished > 0);
+}
+
+// Can't use blocking calls with Unsync queues(there is a static_assert)
+template <>
+void readerBlocking<AidlMessageQueueUnsync, AidlMQDescUnsync>(const AidlMQDescUnsync&,
+ std::vector<uint8_t>&,
+ std::atomic<size_t>&,
+ std::atomic<size_t>&) {}
+template <>
+void readerBlocking<MessageQueueUnsync, MQDescUnsync>(const MQDescUnsync&, std::vector<uint8_t>&,
+ std::atomic<size_t>&, std::atomic<size_t>&) {}
+
template <typename Queue>
-void writer(Queue& writeMq, FuzzedDataProvider& fdp) {
+void writer(Queue& writeMq, FuzzedDataProvider& fdp, bool userFd) {
+ payload_t* ring = nullptr;
while (fdp.remaining_bytes()) {
typename Queue::MemTransaction tx;
size_t numElements = 1;
@@ -108,23 +156,61 @@
const auto& region = tx.getFirstRegion();
payload_t* firstStart = region.getAddress();
-
- // TODO add the debug function to get pointer to the ring buffer
- uint64_t* readCounter = reinterpret_cast<uint64_t*>(reinterpret_cast<uint8_t*>(firstStart) -
- kReadCounterOffsetBytes);
- *readCounter = fdp.ConsumeIntegral<uint64_t>();
-
+ // the ring buffer is only next to the read/write counters when there is
+ // no user supplied fd
+ if (!userFd) {
+ if (ring == nullptr) {
+ ring = firstStart;
+ }
+ if (fdp.ConsumeIntegral<uint8_t>() == 1) {
+ uint64_t* readCounter = getCounterPtr(ring, kReadCounterOffsetBytes);
+ *readCounter = fdp.ConsumeIntegral<uint64_t>();
+ }
+ }
*firstStart = fdp.ConsumeIntegral<payload_t>();
writeMq.commitWrite(numElements);
}
}
+template <typename Queue>
+void writerBlocking(Queue& writeMq, FuzzedDataProvider& fdp,
+ std::atomic<size_t>& writersNotFinished,
+ std::atomic<size_t>& readersNotFinished) {
+ android::base::ScopeGuard guard([&writersNotFinished]() { writersNotFinished--; });
+ while (fdp.remaining_bytes() > sizeof(size_t) && readersNotFinished > 0) {
+ size_t count = fdp.ConsumeIntegralInRange<size_t>(1, writeMq.getQuantumCount());
+ std::vector<payload_t> data;
+ for (int i = 0; i < count; i++) {
+ data.push_back(fdp.ConsumeIntegral<payload_t>());
+ }
+ writeMq.writeBlocking(data.data(), count, kBlockingTimeoutNs);
+ }
+}
+
+// Can't use blocking calls with Unsync queues(there is a static_assert)
+template <>
+void writerBlocking<AidlMessageQueueUnsync>(AidlMessageQueueUnsync&, FuzzedDataProvider&,
+ std::atomic<size_t>&, std::atomic<size_t>&) {}
+template <>
+void writerBlocking<MessageQueueUnsync>(MessageQueueUnsync&, FuzzedDataProvider&,
+ std::atomic<size_t>&, std::atomic<size_t>&) {}
+
template <typename Queue, typename Desc>
void fuzzAidlWithReaders(std::vector<uint8_t>& writerData,
- std::vector<std::vector<uint8_t>>& readerData) {
+ std::vector<std::vector<uint8_t>>& readerData, bool blocking) {
FuzzedDataProvider fdp(&writerData[0], writerData.size());
- Queue writeMq(fdp.ConsumeIntegralInRange<size_t>(1, kMaxNumElements), fdp.ConsumeBool());
+ bool evFlag = blocking || fdp.ConsumeBool();
+ android::base::unique_fd dataFd;
+ size_t bufferSize = 0;
+ size_t numElements = fdp.ConsumeIntegralInRange<size_t>(1, kMaxNumElements);
+ bool userFd = fdp.ConsumeBool();
+ if (userFd) {
+ // run test with our own data region
+ bufferSize = numElements * sizeof(payload_t);
+ dataFd.reset(::ashmem_create_region("SyncReadWrite", bufferSize));
+ }
+ Queue writeMq(numElements, evFlag, std::move(dataFd), bufferSize);
if (!writeMq.isValid()) {
LOG(ERROR) << "AIDL write mq invalid";
return;
@@ -132,23 +218,47 @@
const auto desc = writeMq.dupeDesc();
CHECK(desc.handle.fds[0].get() != -1);
- std::vector<std::thread> clients;
+ std::atomic<size_t> readersNotFinished = readerData.size();
+ std::atomic<size_t> writersNotFinished = 1;
+ std::vector<std::thread> readers;
for (int i = 0; i < readerData.size(); i++) {
- clients.emplace_back(reader<Queue, Desc>, std::ref(desc), std::ref(readerData[i]));
+ if (blocking) {
+ readers.emplace_back(readerBlocking<Queue, Desc>, std::ref(desc),
+ std::ref(readerData[i]), std::ref(readersNotFinished),
+ std::ref(writersNotFinished));
+
+ } else {
+ readers.emplace_back(reader<Queue, Desc>, std::ref(desc), std::ref(readerData[i]),
+ userFd);
+ }
}
- writer<Queue>(writeMq, fdp);
+ if (blocking) {
+ writerBlocking<Queue>(writeMq, fdp, writersNotFinished, readersNotFinished);
+ } else {
+ writer<Queue>(writeMq, fdp, userFd);
+ }
- for (auto& client : clients) {
- client.join();
+ for (auto& reader : readers) {
+ reader.join();
}
}
template <typename Queue, typename Desc>
void fuzzHidlWithReaders(std::vector<uint8_t>& writerData,
- std::vector<std::vector<uint8_t>>& readerData) {
+ std::vector<std::vector<uint8_t>>& readerData, bool blocking) {
FuzzedDataProvider fdp(&writerData[0], writerData.size());
- Queue writeMq(fdp.ConsumeIntegralInRange<size_t>(1, kMaxNumElements), fdp.ConsumeBool());
+ bool evFlag = blocking || fdp.ConsumeBool();
+ android::base::unique_fd dataFd;
+ size_t bufferSize = 0;
+ size_t numElements = fdp.ConsumeIntegralInRange<size_t>(1, kMaxNumElements);
+ bool userFd = fdp.ConsumeBool();
+ if (userFd) {
+ // run test with our own data region
+ bufferSize = numElements * sizeof(payload_t);
+ dataFd.reset(::ashmem_create_region("SyncReadWrite", bufferSize));
+ }
+ Queue writeMq(numElements, evFlag, std::move(dataFd), bufferSize);
if (!writeMq.isValid()) {
LOG(ERROR) << "HIDL write mq invalid";
return;
@@ -156,15 +266,28 @@
const auto desc = writeMq.getDesc();
CHECK(desc->isHandleValid());
- std::vector<std::thread> clients;
+ std::atomic<size_t> readersNotFinished = readerData.size();
+ std::atomic<size_t> writersNotFinished = 1;
+ std::vector<std::thread> readers;
for (int i = 0; i < readerData.size(); i++) {
- clients.emplace_back(reader<Queue, Desc>, std::ref(*desc), std::ref(readerData[i]));
+ if (blocking) {
+ readers.emplace_back(readerBlocking<Queue, Desc>, std::ref(*desc),
+ std::ref(readerData[i]), std::ref(readersNotFinished),
+ std::ref(writersNotFinished));
+ } else {
+ readers.emplace_back(reader<Queue, Desc>, std::ref(*desc), std::ref(readerData[i]),
+ userFd);
+ }
}
- writer<Queue>(writeMq, fdp);
+ if (blocking) {
+ writerBlocking<Queue>(writeMq, fdp, writersNotFinished, readersNotFinished);
+ } else {
+ writer<Queue>(writeMq, fdp, userFd);
+ }
- for (auto& client : clients) {
- client.join();
+ for (auto& reader : readers) {
+ reader.join();
}
}
@@ -179,16 +302,18 @@
uint8_t numReaders = fuzzSync ? fdp.ConsumeIntegralInRange<uint8_t>(0, kMaxNumSyncReaders)
: fdp.ConsumeIntegralInRange<uint8_t>(0, kMaxNumUnsyncReaders);
for (int i = 0; i < numReaders; i++) {
- readerData.emplace_back(fdp.ConsumeBytes<uint8_t>(5));
+ readerData.emplace_back(fdp.ConsumeBytes<uint8_t>(kMaxDataPerReader));
}
+ bool fuzzBlocking = fdp.ConsumeBool();
std::vector<uint8_t> writerData = fdp.ConsumeRemainingBytes<uint8_t>();
-
if (fuzzSync) {
- fuzzHidlWithReaders<MessageQueueSync, MQDescSync>(writerData, readerData);
- fuzzAidlWithReaders<AidlMessageQueueSync, AidlMQDescSync>(writerData, readerData);
+ fuzzHidlWithReaders<MessageQueueSync, MQDescSync>(writerData, readerData, fuzzBlocking);
+ fuzzAidlWithReaders<AidlMessageQueueSync, AidlMQDescSync>(writerData, readerData,
+ fuzzBlocking);
} else {
- fuzzHidlWithReaders<MessageQueueUnsync, MQDescUnsync>(writerData, readerData);
- fuzzAidlWithReaders<AidlMessageQueueUnsync, AidlMQDescUnsync>(writerData, readerData);
+ fuzzHidlWithReaders<MessageQueueUnsync, MQDescUnsync>(writerData, readerData, false);
+ fuzzAidlWithReaders<AidlMessageQueueUnsync, AidlMQDescUnsync>(writerData, readerData,
+ false);
}
return 0;
diff --git a/include/fmq/EventFlag.h b/include/fmq/EventFlag.h
index af18448..3ec4932 100644
--- a/include/fmq/EventFlag.h
+++ b/include/fmq/EventFlag.h
@@ -31,22 +31,6 @@
*/
struct EventFlag {
/**
- * Create an event flag object with mapping information.
- *
- * @param fd File descriptor to be mmapped to create the event flag word.
- * There is no transfer of ownership of the fd. The caller will still
- * own the fd for the purpose of closing it.
- * @param offset Offset parameter to mmap.
- * @param ef Pointer to address of the EventFlag object that gets created. Will be set to
- * nullptr if unsuccesful.
- *
- * @return status Returns a status_t error code. Likely error codes are
- * NO_ERROR if the method is successful or BAD_VALUE due to invalid
- * mapping arguments.
- */
- static status_t createEventFlag(int fd, off_t offset, EventFlag** ef);
-
- /**
* Create an event flag object from the address of the flag word.
*
* @param efWordPtr Pointer to the event flag word.
@@ -111,11 +95,6 @@
std::atomic<uint32_t>* mEfWordPtr = nullptr;
/*
- * mmap memory for the event flag word.
- */
- EventFlag(int fd, off_t offset, status_t* status);
-
- /*
* Use this constructor if we already know where the event flag word
* lives.
*/
diff --git a/include/fmq/MessageQueueBase.h b/include/fmq/MessageQueueBase.h
index b932317..c34a4ff 100644
--- a/include/fmq/MessageQueueBase.h
+++ b/include/fmq/MessageQueueBase.h
@@ -588,11 +588,8 @@
const auto& grantors = mDesc->grantors();
for (const auto& grantor : grantors) {
- if (hardware::details::isAlignedToWordBoundary(grantor.offset) == false) {
-#ifdef __BIONIC__
- __assert(__FILE__, __LINE__, "Grantor offsets need to be aligned");
-#endif
- }
+ hardware::details::check(hardware::details::isAlignedToWordBoundary(grantor.offset) == true,
+ "Grantor offsets need to be aligned");
}
if (flavor == kSynchronizedReadWrite) {
@@ -605,19 +602,11 @@
*/
mReadPtr = new (std::nothrow) std::atomic<uint64_t>;
}
- if (mReadPtr == nullptr) {
-#ifdef __BIONIC__
- __assert(__FILE__, __LINE__, "mReadPtr is null");
-#endif
- }
+ hardware::details::check(mReadPtr != nullptr, "mReadPtr is null");
mWritePtr = reinterpret_cast<std::atomic<uint64_t>*>(
mapGrantorDescr(hardware::details::WRITEPTRPOS));
- if (mWritePtr == nullptr) {
-#ifdef __BIONIC__
- __assert(__FILE__, __LINE__, "mWritePtr is null");
-#endif
- }
+ hardware::details::check(mWritePtr != nullptr, "mWritePtr is null");
if (resetPointers) {
mReadPtr->store(0, std::memory_order_release);
@@ -628,22 +617,13 @@
}
mRing = reinterpret_cast<uint8_t*>(mapGrantorDescr(hardware::details::DATAPTRPOS));
- if (mRing == nullptr) {
-#ifdef __BIONIC__
- __assert(__FILE__, __LINE__, "mRing is null");
-#endif
- }
+ hardware::details::check(mRing != nullptr, "mRing is null");
if (mDesc->countGrantors() > hardware::details::EVFLAGWORDPOS) {
mEvFlagWord = static_cast<std::atomic<uint32_t>*>(
mapGrantorDescr(hardware::details::EVFLAGWORDPOS));
- if (mEvFlagWord != nullptr) {
- android::hardware::EventFlag::createEventFlag(mEvFlagWord, &mEventFlag);
- } else {
-#ifdef __BIONIC__
- __assert(__FILE__, __LINE__, "mEvFlagWord is null");
-#endif
- }
+ hardware::details::check(mEvFlagWord != nullptr, "mEvFlagWord is null");
+ android::hardware::EventFlag::createEventFlag(mEvFlagWord, &mEventFlag);
}
}
diff --git a/tests/Android.bp b/tests/Android.bp
index ec38cea..40148b1 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -35,6 +35,7 @@
cc_test {
name: "fmq_test_client",
+ tidy_timeout_srcs: ["msgq_test_client.cpp"],
srcs: ["msgq_test_client.cpp"],
cflags: [
@@ -58,10 +59,10 @@
// These are static libs only for testing purposes and portability. Shared
// libs should be used on device.
static_libs: [
- "android.hardware.common-V2-ndk_platform",
- "android.hardware.common.fmq-V1-ndk_platform",
+ "android.hardware.common-V2-ndk",
+ "android.hardware.common.fmq-V1-ndk",
"android.hardware.tests.msgq@1.0",
- "android.fmq.test-ndk_platform",
+ "android.fmq.test-ndk",
],
whole_static_libs: [
"android.hardware.tests.msgq@1.0-impl",
@@ -84,6 +85,7 @@
cc_test {
name: "fmq_unit_tests",
+ tidy_timeout_srcs: ["fmq_unit_tests.cpp"],
srcs: ["fmq_unit_tests.cpp"],
shared_libs: [
"libbase",
@@ -94,7 +96,7 @@
"libutils",
],
static_libs: [
- "android.hardware.common.fmq-V1-ndk_platform",
+ "android.hardware.common.fmq-V1-ndk",
],
cflags: [
diff --git a/tests/aidl/android/fmq/test/FixedParcelable.aidl b/tests/aidl/android/fmq/test/FixedParcelable.aidl
index acb54f2..7d0c0e5 100644
--- a/tests/aidl/android/fmq/test/FixedParcelable.aidl
+++ b/tests/aidl/android/fmq/test/FixedParcelable.aidl
@@ -17,9 +17,11 @@
package android.fmq.test;
import android.fmq.test.EventFlagBits;
+import android.fmq.test.FixedUnion;
@FixedSize
parcelable FixedParcelable {
int a;
EventFlagBits b;
+ FixedUnion u;
}
diff --git a/tests/aidl/android/fmq/test/FixedUnion.aidl b/tests/aidl/android/fmq/test/FixedUnion.aidl
new file mode 100644
index 0000000..40a4a28
--- /dev/null
+++ b/tests/aidl/android/fmq/test/FixedUnion.aidl
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2021 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.fmq.test;
+
+import android.fmq.test.EventFlagBits;
+
+@FixedSize
+union FixedUnion {
+ int a;
+ EventFlagBits b;
+}
diff --git a/tests/aidl/default/Android.bp b/tests/aidl/default/Android.bp
index 71a5533..35bd043 100644
--- a/tests/aidl/default/Android.bp
+++ b/tests/aidl/default/Android.bp
@@ -10,7 +10,7 @@
"libfmq",
],
static_libs: [
- "android.fmq.test-ndk_platform",
+ "android.fmq.test-ndk",
],
export_include_dirs: ["."],
srcs: [
diff --git a/tests/fmq_unit_tests.cpp b/tests/fmq_unit_tests.cpp
index be866ec..d3fdfbc 100644
--- a/tests/fmq_unit_tests.cpp
+++ b/tests/fmq_unit_tests.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <android-base/logging.h>
#include <asm-generic/mman.h>
#include <fmq/AidlMessageQueue.h>
#include <fmq/ConvertMQDescriptors.h>
@@ -514,8 +515,9 @@
* "mRing is null".
*/
TEST_F(DoubleFdFailures, InvalidFd) {
+ android::base::SetLogger(android::base::StdioLogger);
EXPECT_DEATH_IF_SUPPORTED(AidlMessageQueueSync(64, false, android::base::unique_fd(3000), 64),
- "mRing is null");
+ "Check failed: exp mRing is null");
}
/*
diff --git a/tests/msgq_test_client.cpp b/tests/msgq_test_client.cpp
index a6f1ccc..1ff9d50 100644
--- a/tests/msgq_test_client.cpp
+++ b/tests/msgq_test_client.cpp
@@ -20,6 +20,7 @@
#endif
#include <aidl/android/fmq/test/FixedParcelable.h>
+#include <aidl/android/fmq/test/FixedUnion.h>
#include <aidl/android/fmq/test/ITestAidlMsgQ.h>
#include <android-base/logging.h>
#include <android/binder_manager.h>
@@ -38,6 +39,7 @@
// generated
using ::aidl::android::fmq::test::EventFlagBits;
using ::aidl::android::fmq::test::FixedParcelable;
+using ::aidl::android::fmq::test::FixedUnion;
using ::aidl::android::fmq::test::ITestAidlMsgQ;
using android::hardware::tests::msgq::V1_0::ITestMsgQ;
@@ -1169,8 +1171,8 @@
* annotated with @FixedSize is supported. A parcelable without it, will cause
* a compilation error.
*/
-typedef ::testing::Types<FixedParcelable, EventFlagBits, bool, int8_t, char, char16_t, int32_t,
- int64_t, float, double>
+typedef ::testing::Types<FixedParcelable, FixedUnion, EventFlagBits, bool, int8_t, char, char16_t,
+ int32_t, int64_t, float, double>
AidlTypeCheckTypes;
template <typename T>