diff options
author | Yabin Cui <yabinc@google.com> | 2015-02-03 17:52:32 -0800 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2015-02-04 12:27:06 -0800 |
commit | f4fe6937aa5ac5a424b63bc68c5a953aaf46e1c6 (patch) | |
tree | cb4065d1b47a960be80b5ecd6c8a62a7e6634d97 /tests/fortify_test.cpp | |
parent | d80ec66121b5af96c6b3d07ba34353b3d517f5b3 (diff) | |
download | android_bionic-f4fe6937aa5ac5a424b63bc68c5a953aaf46e1c6.tar.gz android_bionic-f4fe6937aa5ac5a424b63bc68c5a953aaf46e1c6.tar.bz2 android_bionic-f4fe6937aa5ac5a424b63bc68c5a953aaf46e1c6.zip |
Fix poll/ppoll fortify test to avoid hanging in failed fortify clang test.
Bug: 19220800
Change-Id: Ie75c640183c4a41a499556fefb4f824a134a5fb1
Diffstat (limited to 'tests/fortify_test.cpp')
-rw-r--r-- | tests/fortify_test.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/fortify_test.cpp b/tests/fortify_test.cpp index 6cbc69585..5cc728f29 100644 --- a/tests/fortify_test.cpp +++ b/tests/fortify_test.cpp @@ -26,6 +26,7 @@ #include <sys/socket.h> #include <sys/stat.h> #include <sys/types.h> +#include <time.h> #if __BIONIC__ #define ASSERT_FORTIFY(expr) ASSERT_EXIT(expr, testing::KilledBySignal(SIGABRT), "FORTIFY") @@ -938,11 +939,15 @@ TEST(TEST_NAME, s_n_printf_macro_expansion) { TEST_F(DEATHTEST, poll_fortified) { nfds_t fd_count = atoi("2"); // suppress compiler optimizations pollfd buf[1] = {{0, POLLIN, 0}}; - ASSERT_FORTIFY(poll(buf, fd_count, -1)); + // Set timeout to zero to prevent waiting in poll when fortify test fails. + ASSERT_FORTIFY(poll(buf, fd_count, 0)); } TEST_F(DEATHTEST, ppoll_fortified) { nfds_t fd_count = atoi("2"); // suppress compiler optimizations pollfd buf[1] = {{0, POLLIN, 0}}; - ASSERT_FORTIFY(ppoll(buf, fd_count, NULL, NULL)); + // Set timeout to zero to prevent waiting in ppoll when fortify test fails. + timespec timeout; + timeout.tv_sec = timeout.tv_nsec = 0; + ASSERT_FORTIFY(ppoll(buf, fd_count, &timeout, NULL)); } |