[PATCH] D60644: [compiler-rt][builtins][sanitizers] Update compiler-rt test cases for compatibility with system's toolchain
Amy Kwan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 25 18:57:07 PDT 2019
amyk updated this revision to Diff 196778.
amyk retitled this revision from "[compiler-rt][builtins][sanitizers] Guard test cases with macros with GLIBC* macros " to "[compiler-rt][builtins][sanitizers] Update compiler-rt test cases for compatibility with system's toolchain ".
amyk edited the summary of this revision.
amyk added a comment.
With the assistance of @hubert.reinterpretcast, I have updated the sanitizer-common test case, `getpw_getgr.cc` to avoid the use of `std::string` as this can result in a false positive.
The `compiler_rt_logb_test.c` test case remains the same; with checks for the GLIBC version macro in place.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60644/new/
https://reviews.llvm.org/D60644
Files:
compiler-rt/test/builtins/Unit/compiler_rt_logb_test.c
compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cc
Index: compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cc
===================================================================
--- compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cc
+++ compiler-rt/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 @@
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 @@
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 @@
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 = [] {
Index: compiler-rt/test/builtins/Unit/compiler_rt_logb_test.c
===================================================================
--- compiler-rt/test/builtins/Unit/compiler_rt_logb_test.c
+++ compiler-rt/test/builtins/Unit/compiler_rt_logb_test.c
@@ -36,6 +36,11 @@
};
int main() {
+ // Run the compiler-rt logb test case if the GLIBC
+ // version is >= 2.23. Older versions of libm may not
+ // compute to the same value as the compiler-rt value.
+#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \
+ defined (__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 23)
const unsigned N = sizeof(cases) / sizeof(cases[0]);
unsigned i;
for (i = 0; i < N; ++i) {
@@ -57,6 +62,7 @@
if (test__compiler_rt_logb(fromRep(signBit ^ x))) return 1;
x >>= 1;
}
+#endif
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60644.196778.patch
Type: text/x-patch
Size: 2183 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190426/12329a6a/attachment.bin>
More information about the llvm-commits
mailing list