Merge changes from topic "b131356202-safe_union-round-three" into qt-dev
* changes:
Delegate all safe-union constructors.
Tests for safe_union initialization.
hidl_test*: working around breaking build changes.
diff --git a/Interface.cpp b/Interface.cpp
index 073e44c..b0ffa34 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -385,23 +385,23 @@
{IMPL_INTERFACE,
[](auto &out) {
// getDebugInfo returns N/A for local objects.
- out << "_hidl_cb({ -1 /* pid */, 0 /* ptr */, \n"
- << sArch
- << "});\n"
- << "return ::android::hardware::Void();\n";
+ out << "::android::hidl::base::V1_0::DebugInfo info = {};\n";
+ out << "info.pid = -1;\n";
+ out << "info.ptr = 0;\n";
+ out << "info.arch = \n" << sArch << ";\n";
+ out << "_hidl_cb(info);\n";
+ out << "return ::android::hardware::Void();\n";
}
},
{IMPL_STUB_IMPL,
[](auto &out) {
- out << "_hidl_cb(";
- out.block([&] {
- out << "::android::hardware::details::getPidIfSharable(),\n"
- << "::android::hardware::details::debuggable()"
- << "? reinterpret_cast<uint64_t>(this) : 0 /* ptr */,\n"
- << sArch << "\n";
- });
- out << ");\n"
- << "return ::android::hardware::Void();\n";
+ out << "::android::hidl::base::V1_0::DebugInfo info = {};\n";
+ out << "info.pid = ::android::hardware::details::getPidIfSharable();\n";
+ out << "info.ptr = ::android::hardware::details::debuggable()"
+ << "? reinterpret_cast<uint64_t>(this) : 0;\n";
+ out << "info.arch = \n" << sArch << ";\n";
+ out << "_hidl_cb(info);\n";
+ out << "return ::android::hardware::Void();\n";
}
}
}, /* cppImpl */
diff --git a/test/hidl_test/hidl_test_client.cpp b/test/hidl_test/hidl_test_client.cpp
index ea712ef..9a1adcb 100644
--- a/test/hidl_test/hidl_test_client.cpp
+++ b/test/hidl_test/hidl_test_client.cpp
@@ -1732,6 +1732,9 @@
//do nothing, this is expected
}
+ // further calls fail
+ EXPECT_FAIL(dyingBaz->ping());
+
std::unique_lock<std::mutex> lock(recipient->mutex);
recipient->condition.wait_for(lock, std::chrono::milliseconds(100), [&recipient]() {
return recipient->fired;
@@ -1892,31 +1895,44 @@
TEST_F(HidlTest, InvalidTransactionTest) {
using ::android::hardware::tests::bar::V1_0::BnHwBar;
- using ::android::hardware::tests::bar::V1_0::BpHwBar;
using ::android::hardware::IBinder;
using ::android::hardware::Parcel;
- using ::android::status_t;
- using ::android::OK;
+
+ sp<IBinder> binder = ::android::hardware::toBinder(bar);
Parcel request, reply;
- sp<IBinder> binder;
- status_t status = request.writeInterfaceToken(::android::hardware::tests::bar::V1_0::IBar::descriptor);
+ EXPECT_EQ(::android::OK, request.writeInterfaceToken(IBar::descriptor));
+ EXPECT_EQ(::android::UNKNOWN_TRANSACTION, binder->transact(1234, request, &reply));
- EXPECT_EQ(status, OK);
+ EXPECT_OK(bar->ping()); // still works
+}
- if (mode == BINDERIZED) {
- EXPECT_TRUE(bar->isRemote());
- binder = ::android::hardware::toBinder<IBar>(bar);
- } else {
- // For a local test, just wrap the implementation with a BnHwBar
- binder = new BnHwBar(bar);
- }
+TEST_F(HidlTest, EmptyTransactionTest) {
+ using ::android::hardware::IBinder;
+ using ::android::hardware::Parcel;
+ using ::android::hardware::tests::bar::V1_0::BnHwBar;
- status = binder->transact(1234, request, &reply);
+ sp<IBinder> binder = ::android::hardware::toBinder(bar);
- EXPECT_EQ(status, ::android::UNKNOWN_TRANSACTION);
- // Try another call, to make sure nothing is messed up
- EXPECT_OK(bar->thisIsNew());
+ Parcel request, reply;
+ EXPECT_EQ(::android::BAD_TYPE, binder->transact(2 /*someBoolMethod*/, request, &reply));
+
+ EXPECT_OK(bar->ping()); // still works
+}
+
+TEST_F(HidlTest, WrongDescriptorTest) {
+ using ::android::hardware::IBinder;
+ using ::android::hardware::Parcel;
+ using ::android::hardware::tests::bar::V1_0::BnHwBar;
+
+ sp<IBinder> binder = ::android::hardware::toBinder(bar);
+
+ Parcel request, reply;
+ // wrong descriptor
+ EXPECT_EQ(::android::OK, request.writeInterfaceToken("not a real descriptor"));
+ EXPECT_EQ(::android::BAD_TYPE, binder->transact(2 /*someBoolMethod*/, request, &reply));
+
+ EXPECT_OK(bar->ping()); // still works
}
TEST_F(HidlTest, TrieSimpleTest) {