diff options
author | Nick Kralevich <nnk@google.com> | 2013-06-19 10:40:46 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-06-19 10:40:46 -0700 |
commit | 373ea006ced88b280c4a46ec05eafc60b48e99e0 (patch) | |
tree | f887196271ea7dfdffeaf19cd1063d13f0e07a83 /tests | |
parent | 700b548738d22e79e8b08ce153e3e69de1f47fcf (diff) | |
parent | 1d174a9c17f645a27d766a66e7477d797f955e90 (diff) | |
download | android_bionic-373ea006ced88b280c4a46ec05eafc60b48e99e0.tar.gz android_bionic-373ea006ced88b280c4a46ec05eafc60b48e99e0.tar.bz2 android_bionic-373ea006ced88b280c4a46ec05eafc60b48e99e0.zip |
am 1d174a9c: am 02ca0e31: Merge "Fix FORTIFY_SOURCE unittests."
* commit '1d174a9c17f645a27d766a66e7477d797f955e90':
Fix FORTIFY_SOURCE unittests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fortify1_test_clang.cpp | 8 | ||||
-rw-r--r-- | tests/fortify2_test_clang.cpp | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/tests/fortify1_test_clang.cpp b/tests/fortify1_test_clang.cpp index 2a1b8a7d1..0c0fb2bef 100644 --- a/tests/fortify1_test_clang.cpp +++ b/tests/fortify1_test_clang.cpp @@ -289,10 +289,14 @@ TEST(Fortify1_Clang, strcat2) { __BIONIC_FORTIFY_INLINE size_t test_fortify_inline(char* buf) { - return __bos(buf); + return __bos(buf); } TEST(Fortify1_Clang, fortify_inline) { char buf[1024]; - ASSERT_EQ(test_fortify_inline(buf), sizeof(buf)); + // no-op. Prints nothing. Needed to prevent the compiler + // from optimizing out buf. + buf[0] = '\0'; + printf("%s", buf); + ASSERT_EQ(sizeof(buf), test_fortify_inline(buf)); } diff --git a/tests/fortify2_test_clang.cpp b/tests/fortify2_test_clang.cpp index 2abf85a94..d8a0ba6d8 100644 --- a/tests/fortify2_test_clang.cpp +++ b/tests/fortify2_test_clang.cpp @@ -162,10 +162,14 @@ TEST(Fortify2_Clang_DeathTest, strncpy_fortified) { __BIONIC_FORTIFY_INLINE size_t test_fortify2_inline(char* buf) { - return __bos(buf); + return __bos(buf); } TEST(Fortify2_Clang, fortify_inline) { char buf[1024]; - ASSERT_EQ(test_fortify2_inline(buf), sizeof(buf)); + // no-op. Prints nothing. Needed to prevent the compiler + // from optimizing out buf. + buf[0] = '\0'; + printf("%s", buf); + ASSERT_EQ(sizeof(buf), test_fortify2_inline(buf)); } |