From 686852d9d87d1e940efb7bb3d2c7c17a4282c32e Mon Sep 17 00:00:00 2001 From: Joshua Peraza Date: Mon, 1 Jun 2020 14:55:26 -0700 Subject: [PATCH] linux: update test expectations Android 9+ sets the executable's dynamic array address in the link map. Improve tests to verify that the dynamic array address in the link map matches the address in the executable. Bug: chromium:1050178 Change-Id: I4c938f804092c8f35578389a7e7d7267144ad80c Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1967972 Reviewed-by: Mark Mentovai Commit-Queue: Joshua Peraza --- snapshot/linux/debug_rendezvous_test.cc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/snapshot/linux/debug_rendezvous_test.cc b/snapshot/linux/debug_rendezvous_test.cc index be22c903..bbedddfe 100644 --- a/snapshot/linux/debug_rendezvous_test.cc +++ b/snapshot/linux/debug_rendezvous_test.cc @@ -74,6 +74,13 @@ void TestAgainstTarget(PtraceConnection* connection) { LinuxVMAddress debug_address; ASSERT_TRUE(exe_reader.GetDebugAddress(&debug_address)); + VMAddress exe_dynamic_address = 0; + if (exe_reader.GetDynamicArrayAddress(&exe_dynamic_address)) { + CheckedLinuxAddressRange exe_range( + connection->Is64Bit(), exe_reader.Address(), exe_reader.Size()); + EXPECT_TRUE(exe_range.ContainsValue(exe_dynamic_address)); + } + // start the actual tests DebugRendezvous debug; ASSERT_TRUE(debug.Initialize(range, debug_address)); @@ -85,8 +92,13 @@ void TestAgainstTarget(PtraceConnection* connection) { EXPECT_NE(debug.Executable()->name.find("crashpad_snapshot_test"), std::string::npos); - // Android's loader never sets the dynamic array for the executable. - EXPECT_EQ(debug.Executable()->dynamic_array, 0u); + // Android's loader doesn't set the dynamic array for the executable in the + // link map until Android 9.0 (API 28). + if (android_runtime_api >= 28) { + EXPECT_EQ(debug.Executable()->dynamic_array, exe_dynamic_address); + } else { + EXPECT_EQ(debug.Executable()->dynamic_array, 0u); + } #else // glibc's loader implements most of the tested features that Android's was // missing but has since gained. @@ -94,9 +106,7 @@ void TestAgainstTarget(PtraceConnection* connection) { // glibc's loader does not set the name for the executable. EXPECT_TRUE(debug.Executable()->name.empty()); - CheckedLinuxAddressRange exe_range( - connection->Is64Bit(), exe_reader.Address(), exe_reader.Size()); - EXPECT_TRUE(exe_range.ContainsValue(debug.Executable()->dynamic_array)); + EXPECT_EQ(debug.Executable()->dynamic_array, exe_dynamic_address); #endif // OS_ANDROID // Android's loader doesn't set the load bias until Android 4.3 (API 18).