diff options
author | Ricardo Cerqueira <ricardo@cyngn.com> | 2015-11-05 00:40:50 +0000 |
---|---|---|
committer | Ricardo Cerqueira <ricardo@cyngn.com> | 2015-11-05 14:38:19 +0000 |
commit | 6cfec1a5b66fe113ffbe81c125ea700f21b30439 (patch) | |
tree | a1753b317adea2c440b98cb8854a0ee152f8bcb0 | |
parent | e2f0539dee416d6770493a0d90e1bdffa874acf1 (diff) | |
parent | 7ed993ad49ebcb0c702f000978f42f52e9f423ab (diff) | |
download | bionic-6cfec1a5b66fe113ffbe81c125ea700f21b30439.zip bionic-6cfec1a5b66fe113ffbe81c125ea700f21b30439.tar.gz bionic-6cfec1a5b66fe113ffbe81c125ea700f21b30439.tar.bz2 |
Merge tag 'android-6.0.0_r26' into cm-13.0
Android 6.0.0 release 26
Change-Id: Ic73500c2330af39a735307c153fbe3e71b7f2040
-rw-r--r-- | libc/bionic/pthread_internal.h | 7 | ||||
-rw-r--r-- | tests/Android.mk | 7 | ||||
-rw-r--r-- | tests/gtest_main.cpp | 10 | ||||
-rw-r--r-- | tests/pthread_test.cpp | 24 | ||||
-rw-r--r-- | tests/stack_unwinding_test.cpp | 2 |
5 files changed, 44 insertions, 6 deletions
diff --git a/libc/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h index 3b91e6a..6a39a21 100644 --- a/libc/bionic/pthread_internal.h +++ b/libc/bionic/pthread_internal.h @@ -130,8 +130,13 @@ __LIBC_HIDDEN__ void pthread_key_clean_all(void); */ #define PTHREAD_STACK_SIZE_DEFAULT ((1 * 1024 * 1024) - SIGSTKSZ) -/* Leave room for a guard page in the internally created signal stacks. */ +// Leave room for a guard page in the internally created signal stacks. +#if defined(__LP64__) +// SIGSTKSZ is not big enough for 64-bit arch. See http://b/23041777. +#define SIGNAL_STACK_SIZE (16 * 1024 + PAGE_SIZE) +#else #define SIGNAL_STACK_SIZE (SIGSTKSZ + PAGE_SIZE) +#endif /* Needed by fork. */ __LIBC_HIDDEN__ extern void __bionic_atfork_run_prepare(); diff --git a/tests/Android.mk b/tests/Android.mk index cd60668..dc2e410 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -241,7 +241,12 @@ libBionicCtsGtestMain_src_files := gtest_main.cpp libBionicCtsGtestMain_cflags := $(test_cflags) -libBionicCtsGtestMain_cppflags := $(test_cppflags) -DUSING_GTEST_OUTPUT_FORMAT +libBionicCtsGtestMain_cppflags := $(test_cppflags) -DUSING_GTEST_OUTPUT_FORMAT \ + +# Temporarily fix the job count to 1 for CTS since on some devices the +# number of online cores is incorrectly read as the total number of cores +# in the system. When b/24376925 is fixed, this should be removed. +libBionicCtsGtestMain_cppflags += -DJOB_COUNT_FIXED=1 module := libBionicCtsGtestMain module_tag := optional diff --git a/tests/gtest_main.cpp b/tests/gtest_main.cpp index 692b7e8..5d25a4c 100644 --- a/tests/gtest_main.cpp +++ b/tests/gtest_main.cpp @@ -59,7 +59,7 @@ using testing::internal::COLOR_GREEN; using testing::internal::COLOR_YELLOW; using testing::internal::ColoredPrintf; -constexpr int DEFAULT_GLOBAL_TEST_RUN_DEADLINE_MS = 60000; +constexpr int DEFAULT_GLOBAL_TEST_RUN_DEADLINE_MS = 90000; constexpr int DEFAULT_GLOBAL_TEST_RUN_WARNLINE_MS = 2000; // The time each test can run before killed for the reason of timeout. @@ -839,8 +839,12 @@ static bool RunTestInSeparateProc(int argc, char** argv, std::vector<TestCase>& return all_tests_passed; } -static size_t GetProcessorCount() { +static size_t GetDefaultJobCount() { +#if defined(JOB_COUNT_FIXED) + return JOB_COUNT_FIXED; +#else return static_cast<size_t>(sysconf(_SC_NPROCESSORS_ONLN)); +#endif } static void AddPathSeparatorInTestProgramPath(std::vector<char*>& args) { @@ -950,7 +954,7 @@ static bool PickOptions(std::vector<char*>& args, IsolationTestOptions& options) } // Init default isolation test options. - options.job_count = GetProcessorCount(); + options.job_count = GetDefaultJobCount(); options.test_deadline_ms = DEFAULT_GLOBAL_TEST_RUN_DEADLINE_MS; options.test_warnline_ms = DEFAULT_GLOBAL_TEST_RUN_WARNLINE_MS; options.gtest_color = testing::GTEST_FLAG(color); diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp index 8ae28d8..ad8fac6 100644 --- a/tests/pthread_test.cpp +++ b/tests/pthread_test.cpp @@ -27,6 +27,7 @@ #include <sys/syscall.h> #include <time.h> #include <unistd.h> +#include <unwind.h> #include <atomic> #include <regex> @@ -1571,3 +1572,26 @@ TEST_F(pthread_DeathTest, pthread_mutex_unlock_null_64) { GTEST_LOG_(INFO) << "This test tests bionic implementation details on 64 bit devices."; #endif } + +extern _Unwind_Reason_Code FrameCounter(_Unwind_Context* ctx, void* arg); + +static volatile bool signal_handler_on_altstack_done; + +static void SignalHandlerOnAltStack(int signo, siginfo_t*, void*) { + ASSERT_EQ(SIGUSR1, signo); + // Check if we have enough stack space for unwinding. + int count = 0; + _Unwind_Backtrace(FrameCounter, &count); + ASSERT_GT(count, 0); + // Check if we have enough stack space for logging. + std::string s(2048, '*'); + GTEST_LOG_(INFO) << s; + signal_handler_on_altstack_done = true; +} + +TEST(pthread, big_enough_signal_stack_for_64bit_arch) { + signal_handler_on_altstack_done = false; + ScopedSignalHandler handler(SIGUSR1, SignalHandlerOnAltStack, SA_SIGINFO | SA_ONSTACK); + kill(getpid(), SIGUSR1); + ASSERT_TRUE(signal_handler_on_altstack_done); +} diff --git a/tests/stack_unwinding_test.cpp b/tests/stack_unwinding_test.cpp index d1b3402..afd9e7f 100644 --- a/tests/stack_unwinding_test.cpp +++ b/tests/stack_unwinding_test.cpp @@ -34,7 +34,7 @@ #define noinline __attribute__((__noinline__)) #define __unused __attribute__((__unused__)) -static _Unwind_Reason_Code FrameCounter(_Unwind_Context* ctx __unused, void* arg) { +_Unwind_Reason_Code FrameCounter(_Unwind_Context* ctx __unused, void* arg) { int* count_ptr = reinterpret_cast<int*>(arg); #if SHOW_FRAME_LOCATIONS |