summaryrefslogtreecommitdiff
path: root/test/sanitizer_common
diff options
context:
space:
mode:
authorAmy Kwan <amy.kwan1@ibm.com>2019-04-30 20:09:00 +0000
committerAmy Kwan <amy.kwan1@ibm.com>2019-04-30 20:09:00 +0000
commit8a8060f4fdb751a3ccf9a63d7c8ab5928f801abe (patch)
treefb2bc390f3d2b9e5009501b9f604015d798f8855 /test/sanitizer_common
parent92a5e92e9aa2c8dbd6e7c53d258dbefa9125aa29 (diff)
downloadcompiler-rt-8a8060f4fdb751a3ccf9a63d7c8ab5928f801abe.tar.gz
[compiler-rt][builtins][sanitizers] Update compiler-rt test cases for
compatibility with system's toolchain This patch aims to: - Guard ompiler-rt/test/builtins/Unit/compiler_rt_logb_test.c with macros, so the test runs on GLIBC versions >= 2.23. This is because the test relies on comparing its computed values to libm. Oolder versions might not compute to the same value as the compiler-rt value. - Update compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cc so that std::string is not used, since false positives may be detected. Differential Revision: https://reviews.llvm.org/D60644 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359606 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/sanitizer_common')
-rw-r--r--test/sanitizer_common/TestCases/Posix/getpw_getgr.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/test/sanitizer_common/TestCases/Posix/getpw_getgr.cc b/test/sanitizer_common/TestCases/Posix/getpw_getgr.cc
index b4bc9b43d..c373132eb 100644
--- a/test/sanitizer_common/TestCases/Posix/getpw_getgr.cc
+++ b/test/sanitizer_common/TestCases/Posix/getpw_getgr.cc
@@ -8,9 +8,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <string>
-std::string any_group;
+std::unique_ptr<char []> any_group;
const int N = 123456;
void Check(const char *str) {
@@ -48,8 +47,11 @@ void Check(const group *result) {
assert(result->gr_gid != N);
for (char **mem = result->gr_mem; *mem; ++mem)
Check(*mem);
- if (any_group.empty())
- any_group = result->gr_name;
+ if (!any_group) {
+ auto length = strlen(result->gr_name);
+ any_group.reset(new char[length + 1]);
+ memcpy(any_group.get(), result->gr_name, length + 1);
+ }
}
template <class T, class Fn, class... Args>
@@ -72,7 +74,7 @@ int main(int argc, const char *argv[]) {
test<passwd>(&getpwuid, 0);
test<passwd>(&getpwnam, "root");
test<group>(&getgrgid, 0);
- test<group>(&getgrnam, any_group.c_str());
+ test<group>(&getgrnam, any_group.get());
#if !defined(__ANDROID__)
setpwent();
@@ -91,7 +93,7 @@ int main(int argc, const char *argv[]) {
test_r<passwd>(&getpwnam_r, "root");
test_r<group>(&getgrgid_r, 0);
- test_r<group>(&getgrnam_r, any_group.c_str());
+ test_r<group>(&getgrnam_r, any_group.get());
#if defined(__linux__)
auto pwd_file = [] {