summaryrefslogtreecommitdiff
path: root/lib/interception/tests
diff options
context:
space:
mode:
authorJulian Lettner <jlettner@apple.com>2019-05-01 20:57:59 +0000
committerJulian Lettner <jlettner@apple.com>2019-05-01 20:57:59 +0000
commit91448959dae346b8ccb85693f3f94f79f9e0b33d (patch)
treeef53c52d0e072bdf4d85d23119f11d9a9f381c12 /lib/interception/tests
parent99cd89c106a10f18ccbaeda9a920d28ae3e943cf (diff)
downloadcompiler-rt-91448959dae346b8ccb85693f3f94f79f9e0b33d.tar.gz
[Sanitizer] Reland "Cleanup INTERCEPT_FUNCTION macro"
On Linux both version of the INTERCEPT_FUNCTION macro now return true when interception was successful. Adapt and cleanup some usages. Also note that `&(func) == &WRAP(func)` is a link-time property, but we do a runtime check. Tested on Linux and macOS. Previous attempt reverted by: 5642c3feb03d020dc06a62e3dc54f3206a97a391 This attempt to bring order to the interceptor macro goes the other direction and aligns the Linux implementation with the way things are done on Windows. Reviewed By: vitalybuka, rnk Differential Revision: https://reviews.llvm.org/D61358 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359725 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/interception/tests')
-rw-r--r--lib/interception/tests/interception_linux_test.cc15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/interception/tests/interception_linux_test.cc b/lib/interception/tests/interception_linux_test.cc
index 5a1ca6ecb..3e859cb1a 100644
--- a/lib/interception/tests/interception_linux_test.cc
+++ b/lib/interception/tests/interception_linux_test.cc
@@ -33,24 +33,19 @@ INTERCEPTOR(int, isdigit, int d) {
namespace __interception {
-TEST(Interception, GetRealFunctionAddress) {
+TEST(Interception, InterceptFunction) {
uptr malloc_address = 0;
- EXPECT_TRUE(GetRealFunctionAddress("malloc", &malloc_address, 0, 0));
+ EXPECT_TRUE(InterceptFunction("malloc", &malloc_address, 0, 0));
EXPECT_NE(0U, malloc_address);
+ EXPECT_FALSE(InterceptFunction("malloc", &malloc_address, 0, 1));
uptr dummy_address = 0;
- EXPECT_TRUE(
- GetRealFunctionAddress("dummy_doesnt_exist__", &dummy_address, 0, 0));
+ EXPECT_FALSE(InterceptFunction("dummy_doesnt_exist__", &dummy_address, 0, 0));
EXPECT_EQ(0U, dummy_address);
}
-TEST(Interception, GetFuncAddr) {
- EXPECT_NE(GetFuncAddr("malloc"), nullptr);
- EXPECT_EQ(GetFuncAddr("does_not_exist"), nullptr);
-}
-
TEST(Interception, Basic) {
- INTERCEPT_FUNCTION(isdigit);
+ EXPECT_TRUE(INTERCEPT_FUNCTION(isdigit));
// After interception, the counter should be incremented.
InterceptorFunctionCalled = 0;