aboutsummaryrefslogtreecommitdiff
path: root/tests/strings_test.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2016-01-13 13:47:58 -0800
committerChristopher Ferris <cferris@google.com>2016-01-13 17:13:21 -0800
commit13f26a7b2bff5ed88b925b7206256e07596f3626 (patch)
treeea09999fc3508607d5bae97bbe0cf58edc23eed4 /tests/strings_test.cpp
parent9817c6c0cfa01f6bf7e0700e2b7aab2c1220fe28 (diff)
downloadbionic-13f26a7b2bff5ed88b925b7206256e07596f3626.tar.gz
Add method to run fortified versions of funcs.
Add a way to turn fortify off for the files that test fortify functions. This method involves simply compiling the same file with fortify off and changing the test name slightly. It's not very pretty, and it assumes that only these few files test functions that can be fortified. Bug: 15195631 Change-Id: Iba9db1d508b7d28a1d6968019cb70fe08864827b
Diffstat (limited to 'tests/strings_test.cpp')
-rw-r--r--tests/strings_test.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/strings_test.cpp b/tests/strings_test.cpp
index 823aa4f0f..171684362 100644
--- a/tests/strings_test.cpp
+++ b/tests/strings_test.cpp
@@ -20,7 +20,13 @@
#include <locale.h>
#include <strings.h>
-TEST(strings, ffs) {
+#if defined(NOFORTIFY)
+#define STRINGS_TEST strings_nofortify
+#else
+#define STRINGS_TEST strings
+#endif
+
+TEST(STRINGS_TEST, ffs) {
ASSERT_EQ( 0, ffs(0x00000000));
ASSERT_EQ( 1, ffs(0x00000001));
ASSERT_EQ( 6, ffs(0x00000020));
@@ -32,13 +38,13 @@ TEST(strings, ffs) {
ASSERT_EQ(32, ffs(0x80000000));
}
-TEST(strings, strcasecmp) {
+TEST(STRINGS_TEST, strcasecmp) {
ASSERT_EQ(0, strcasecmp("hello", "HELLO"));
ASSERT_LT(strcasecmp("hello1", "hello2"), 0);
ASSERT_GT(strcasecmp("hello2", "hello1"), 0);
}
-TEST(strings, strcasecmp_l) {
+TEST(STRINGS_TEST, strcasecmp_l) {
locale_t l = newlocale(LC_ALL, "C", 0);
ASSERT_EQ(0, strcasecmp_l("hello", "HELLO", l));
ASSERT_LT(strcasecmp_l("hello1", "hello2", l), 0);
@@ -46,14 +52,14 @@ TEST(strings, strcasecmp_l) {
freelocale(l);
}
-TEST(strings, strncasecmp) {
+TEST(STRINGS_TEST, strncasecmp) {
ASSERT_EQ(0, strncasecmp("hello", "HELLO", 3));
ASSERT_EQ(0, strncasecmp("abcXX", "ABCYY", 3));
ASSERT_LT(strncasecmp("hello1", "hello2", 6), 0);
ASSERT_GT(strncasecmp("hello2", "hello1", 6), 0);
}
-TEST(strings, strncasecmp_l) {
+TEST(STRINGS_TEST, strncasecmp_l) {
locale_t l = newlocale(LC_ALL, "C", 0);
ASSERT_EQ(0, strncasecmp_l("hello", "HELLO", 3, l));
ASSERT_EQ(0, strncasecmp_l("abcXX", "ABCYY", 3, l));