Merge "Update Android.bp to match Android.mk" into nyc-dev
diff --git a/tests/getauxval_test.cpp b/tests/getauxval_test.cpp
index 6499f89..54458c4 100644
--- a/tests/getauxval_test.cpp
+++ b/tests/getauxval_test.cpp
@@ -67,7 +67,11 @@
   // If this test fails, apps that use getauxval to decide at runtime whether crypto hardware is
   // available will incorrectly assume that it isn't, and will have really bad performance.
   // If this test fails, ensure that you've enabled COMPAT_BINFMT_ELF in your kernel configuration.
-  ASSERT_NE(0UL, getauxval(AT_HWCAP2)) << "kernel not reporting AT_HWCAP2 to 32-bit ARM process";
+  // Note that 0 ("I don't support any of these things") is a legitimate response --- we need
+  // to check errno to see whether we got a "true" 0 or a "not found" 0.
+  errno = 0;
+  getauxval(AT_HWCAP2);
+  ASSERT_EQ(0, errno) << "kernel not reporting AT_HWCAP2 to 32-bit ARM process";
 #else
   GTEST_LOG_(INFO) << "This test is only meaningful for 32-bit ARM code.\n";
 #endif
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp
index d11ea3f..aab78ad 100755
--- a/tests/pthread_test.cpp
+++ b/tests/pthread_test.cpp
@@ -1347,6 +1347,9 @@
 // the wrong map with [stack]. This test verifies that when the above situation happens, the main
 // thread's stack is found correctly.
 TEST(pthread, pthread_attr_getstack_in_signal_handler) {
+  // This test is only meaningful for the main thread, so make sure we're running on it!
+  ASSERT_EQ(getpid(), syscall(__NR_gettid));
+
   const size_t sig_stack_size = 16 * 1024;
   void* sig_stack = mmap(NULL, sig_stack_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
                          -1, 0);
@@ -1358,6 +1361,12 @@
   stack_t oss;
   ASSERT_EQ(0, sigaltstack(&ss, &oss));
 
+  pthread_attr_t attr;
+  ASSERT_EQ(0, pthread_getattr_np(pthread_self(), &attr));
+  void* main_stack_base;
+  size_t main_stack_size;
+  ASSERT_EQ(0, pthread_attr_getstack(&attr, &main_stack_base, &main_stack_size));
+
   ScopedSignalHandler handler(SIGUSR1, getstack_signal_handler, SA_ONSTACK);
   getstack_signal_handler_arg.done = false;
   kill(getpid(), SIGUSR1);
@@ -1369,9 +1378,8 @@
             getstack_signal_handler_arg.signal_handler_sp);
 
   // Verify if the main thread's stack got in the signal handler is correct.
-  ASSERT_LE(getstack_signal_handler_arg.main_stack_base, &ss);
-  ASSERT_GE(reinterpret_cast<char*>(getstack_signal_handler_arg.main_stack_base) +
-            getstack_signal_handler_arg.main_stack_size, reinterpret_cast<void*>(&ss));
+  ASSERT_EQ(main_stack_base, getstack_signal_handler_arg.main_stack_base);
+  ASSERT_LE(main_stack_size, getstack_signal_handler_arg.main_stack_size);
 
   ASSERT_EQ(0, sigaltstack(&oss, nullptr));
   ASSERT_EQ(0, munmap(sig_stack, sig_stack_size));