Merge changes from topic "b117561179"
* changes:
More verbose error for safe_union invalid access.
safe_union: return error on bad reads
diff --git a/build/hidl_interface.go b/build/hidl_interface.go
index 3d78223..fdf22f6 100644
--- a/build/hidl_interface.go
+++ b/build/hidl_interface.go
@@ -465,7 +465,7 @@
panic("internal error, multiple dependencies found but only one added")
}
visited = true
- h.properties.Full_root_option = dep.(*hidlPackageRoot).properties.Full_root_option
+ h.properties.Full_root_option = dep.(*hidlPackageRoot).getFullPackageRoot()
})
if !visited {
panic("internal error, no dependencies found but dependency added")
diff --git a/build/hidl_package_root.go b/build/hidl_package_root.go
index 58bc44f..e0f8248 100644
--- a/build/hidl_package_root.go
+++ b/build/hidl_package_root.go
@@ -32,18 +32,17 @@
properties struct {
// path to the package root from android build root
Path *string
-
- // actual package path. defaults to current directory
- Full_root_option string `blueprint:"mutated"`
}
}
+func (r *hidlPackageRoot) getFullPackageRoot() string {
+ return "-r" + r.Name() + ":" + *r.properties.Path
+}
+
func (r *hidlPackageRoot) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if r.properties.Path == nil {
r.properties.Path = proptools.StringPtr(ctx.ModuleDir())
}
-
- r.properties.Full_root_option = "-r" + ctx.ModuleName() + ":" + *r.properties.Path
}
func (r *hidlPackageRoot) DepsMutator(ctx android.BottomUpMutatorContext) {
}
diff --git a/generateCppImpl.cpp b/generateCppImpl.cpp
index 997b78f..1485119 100644
--- a/generateCppImpl.cpp
+++ b/generateCppImpl.cpp
@@ -77,11 +77,8 @@
const Interface* iface = mRootScope.getInterface();
const std::string baseName = iface->getBaseName();
- const std::string guard = makeHeaderGuard(baseName, false /* indicateGenerated */);
-
out << "// FIXME: your file license if you have one\n\n";
- out << "#ifndef " << guard << "\n";
- out << "#define " << guard << "\n\n";
+ out << "#pragma once\n\n";
generateCppPackageInclude(out, mPackage, iface->localName());
@@ -132,8 +129,6 @@
out << "} // namespace implementation\n";
enterLeaveNamespace(out, false /* leave */);
-
- out << "\n#endif // " << guard << "\n";
}
void AST::generateCppImplSource(Formatter& out) const {
diff --git a/test/hidl_test/Android.bp b/test/hidl_test/Android.bp
index ea0ba1f..4308ed7 100644
--- a/test/hidl_test/Android.bp
+++ b/test/hidl_test/Android.bp
@@ -35,6 +35,7 @@
"android.hardware.tests.memory@1.0",
"android.hardware.tests.multithread@1.0",
"android.hardware.tests.trie@1.0",
+ "android.hardware.tests.safeunion.cpp@1.0",
"android.hardware.tests.safeunion@1.0",
],
@@ -51,6 +52,7 @@
"android.hardware.tests.memory@1.0-impl",
"android.hardware.tests.multithread@1.0-impl",
"android.hardware.tests.trie@1.0-impl",
+ "android.hardware.tests.safeunion.cpp@1.0-impl",
"android.hardware.tests.safeunion@1.0-impl",
],
diff --git a/test/hidl_test/hidl_test.h b/test/hidl_test/hidl_test.h
index 278a2a9..3a2f7f7 100644
--- a/test/hidl_test/hidl_test.h
+++ b/test/hidl_test/hidl_test.h
@@ -12,6 +12,7 @@
#include <android/hardware/tests/pointer/1.0/IGraph.h>
#include <android/hardware/tests/pointer/1.0/IPointer.h>
#include <android/hardware/tests/safeunion/1.0/ISafeUnion.h>
+#include <android/hardware/tests/safeunion/cpp/1.0/ICppSafeUnion.h>
#include <android/hardware/tests/trie/1.0/ITrie.h>
template <template <typename Type> class Service>
@@ -26,6 +27,7 @@
using ::android::hardware::tests::multithread::V1_0::IMultithread;
using ::android::hardware::tests::pointer::V1_0::IGraph;
using ::android::hardware::tests::pointer::V1_0::IPointer;
+ using ::android::hardware::tests::safeunion::cpp::V1_0::ICppSafeUnion;
using ::android::hardware::tests::safeunion::V1_0::ISafeUnion;
using ::android::hardware::tests::trie::V1_0::ITrie;
@@ -40,6 +42,7 @@
Service<IPointer>::run("pointer");
Service<IMultithread>::run("multithread");
Service<ITrie>::run("trie");
+ Service<ICppSafeUnion>::run("default");
Service<ISafeUnion>::run("safeunion");
}
diff --git a/test/hidl_test/hidl_test_client.cpp b/test/hidl_test/hidl_test_client.cpp
index 40da761..e986fc6 100644
--- a/test/hidl_test/hidl_test_client.cpp
+++ b/test/hidl_test/hidl_test_client.cpp
@@ -36,6 +36,7 @@
#include <android/hardware/tests/pointer/1.0/IPointer.h>
#include <android/hardware/tests/safeunion/1.0/IOtherInterface.h>
#include <android/hardware/tests/safeunion/1.0/ISafeUnion.h>
+#include <android/hardware/tests/safeunion/cpp/1.0/ICppSafeUnion.h>
#include <android/hardware/tests/trie/1.0/ITrie.h>
#include <gtest/gtest.h>
@@ -138,6 +139,7 @@
using ::android::hardware::tests::multithread::V1_0::IMultithread;
using ::android::hardware::tests::pointer::V1_0::IGraph;
using ::android::hardware::tests::pointer::V1_0::IPointer;
+using ::android::hardware::tests::safeunion::cpp::V1_0::ICppSafeUnion;
using ::android::hardware::tests::safeunion::V1_0::IOtherInterface;
using ::android::hardware::tests::safeunion::V1_0::ISafeUnion;
using ::android::hardware::tests::trie::V1_0::ITrie;
@@ -372,6 +374,7 @@
sp<IPointer> validationPointerInterface;
sp<IMultithread> multithreadInterface;
sp<ITrie> trieInterface;
+ sp<ICppSafeUnion> cppSafeunionInterface;
sp<ISafeUnion> safeunionInterface;
TestMode mode;
bool enableDelayMeasurementTests;
@@ -443,6 +446,11 @@
ASSERT_NE(trieInterface, nullptr);
ASSERT_EQ(trieInterface->isRemote(), mode == BINDERIZED);
+ cppSafeunionInterface =
+ ICppSafeUnion::getService("default", mode == PASSTHROUGH /* getStub */);
+ ASSERT_NE(cppSafeunionInterface, nullptr);
+ ASSERT_EQ(cppSafeunionInterface->isRemote(), mode == BINDERIZED);
+
safeunionInterface = ISafeUnion::getService("safeunion", mode == PASSTHROUGH /* getStub */);
ASSERT_NE(safeunionInterface, nullptr);
ASSERT_EQ(safeunionInterface->isRemote(), mode == BINDERIZED);
@@ -470,6 +478,7 @@
sp<IPointer> pointerInterface;
sp<IPointer> validationPointerInterface;
sp<ITrie> trieInterface;
+ sp<ICppSafeUnion> cppSafeunionInterface;
sp<ISafeUnion> safeunionInterface;
TestMode mode = TestMode::PASSTHROUGH;
@@ -488,6 +497,7 @@
pointerInterface = gHidlEnvironment->pointerInterface;
validationPointerInterface = gHidlEnvironment->validationPointerInterface;
trieInterface = gHidlEnvironment->trieInterface;
+ cppSafeunionInterface = gHidlEnvironment->cppSafeunionInterface;
safeunionInterface = gHidlEnvironment->safeunionInterface;
mode = gHidlEnvironment->mode;
ALOGI("Test setup complete");
@@ -2428,6 +2438,26 @@
EXPECT_EQ(1, otherInterface->getStrongCount());
}
+TEST_F(HidlTest, SafeUnionCppSpecificTest) {
+ ICppSafeUnion::PointerFmqSafeUnion pointerFmqSafeUnion;
+ pointerFmqSafeUnion.fmqSync({std::vector<GrantorDescriptor>(), native_handle_create(0, 1), 5});
+
+ EXPECT_OK(cppSafeunionInterface->repeatPointerFmqSafeUnion(
+ pointerFmqSafeUnion, [&](const ICppSafeUnion::PointerFmqSafeUnion& fmq) {
+ ASSERT_EQ(pointerFmqSafeUnion.getDiscriminator(), fmq.getDiscriminator());
+ checkMQDescriptorEquality(pointerFmqSafeUnion.fmqSync(), fmq.fmqSync());
+ }));
+
+ ICppSafeUnion::FmqSafeUnion fmqSafeUnion;
+ fmqSafeUnion.fmqUnsync({std::vector<GrantorDescriptor>(), native_handle_create(0, 1), 5});
+
+ EXPECT_OK(cppSafeunionInterface->repeatFmqSafeUnion(
+ fmqSafeUnion, [&](const ICppSafeUnion::FmqSafeUnion& fmq) {
+ ASSERT_EQ(fmqSafeUnion.getDiscriminator(), fmq.getDiscriminator());
+ checkMQDescriptorEquality(fmqSafeUnion.fmqUnsync(), fmq.fmqUnsync());
+ }));
+}
+
class HidlMultithreadTest : public ::testing::Test {
public:
sp<IMultithread> multithreadInterface;