diff --git a/.gitignore b/.gitignore index 8e7300973dc1cb7e76c8813a7b0a6862b4fa55bd..fa75287bc2a3a416cbe0c15ea99a6cd4720addec 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ env venv Output/ .lit* +.*.swp diff --git a/tests/hwasan/build-id/CMakeLists.txt b/tests/hwasan/build-id/CMakeLists.txt index 89a207ea07be73b51bb49799bd28f9e60e9549a9..9be8db8c227b05b45ea9b8a9167e6a93ee551612 100644 --- a/tests/hwasan/build-id/CMakeLists.txt +++ b/tests/hwasan/build-id/CMakeLists.txt @@ -1,4 +1,4 @@ -initProject(PROJECT_NAME buildIdTest +initProject(PROJECT_NAME hwasanbuildIdTest EXECUTABLES main LIBS a b) add_library(${a} SHARED src/a.c) diff --git a/tests/tsan/data-race-two-libs/CMakeLists.txt b/tests/tsan/data-race-two-libs/CMakeLists.txt index 14540d1ef15599983dc10c440c98ad0e6bcb98a6..b06a9286d9641c2f80d81e23ed77ba30c5861df5 100644 --- a/tests/tsan/data-race-two-libs/CMakeLists.txt +++ b/tests/tsan/data-race-two-libs/CMakeLists.txt @@ -1,5 +1,8 @@ initproject(PROJECT_NAME tsanDataRaceTwoLibs EXECUTABLES main LIBS a b) +# # use share runtime +# set(CMAKE_EXE_LINKER_FLAGS "#{CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread -shared-libsan") + add_library(${a} SHARED src/a.cpp) target_compile_options(${a} PRIVATE "-fsanitize=thread") target_compile_options(${a} PRIVATE "-O0") diff --git a/tests/tsan/data-race-two-libs/src/a.cpp b/tests/tsan/data-race-two-libs/src/a.cpp index 901ccf3de82511c901811b55a98ae676e929a56f..d50ca35f8590c39046d5d0d26dd2cac62d296cf3 100644 --- a/tests/tsan/data-race-two-libs/src/a.cpp +++ b/tests/tsan/data-race-two-libs/src/a.cpp @@ -2,20 +2,20 @@ int globalA = 0; -void *t1(void *p) { +static void *a1(void *p) { globalA++; return NULL; } -void *t2(void *p) { +static void *a2(void *p) { globalA--; return NULL; } void testA() { pthread_t t[2]; - pthread_create(&t[0], NULL, t1, NULL); - pthread_create(&t[1], NULL, t2, NULL); + pthread_create(&t[0], NULL, a1, NULL); + pthread_create(&t[1], NULL, a2, NULL); pthread_join(t[0], NULL); pthread_join(t[1], NULL); } diff --git a/tests/tsan/data-race-two-libs/src/b.cpp b/tests/tsan/data-race-two-libs/src/b.cpp index 0a566d3c4101afebeeb40bdc204617a3784bceda..4e94ade24b969663c8b1003af43f5adb2d9c2642 100644 --- a/tests/tsan/data-race-two-libs/src/b.cpp +++ b/tests/tsan/data-race-two-libs/src/b.cpp @@ -3,14 +3,14 @@ int globalB = 0; pthread_mutex_t lock; -void *t1(void *p) { +static void *b1(void *p) { pthread_mutex_lock(&lock); globalB++; pthread_mutex_unlock(&lock); return NULL; } -void *t2(void *p) { +static void *b2(void *p) { pthread_mutex_lock(&lock); globalB--; pthread_mutex_unlock(&lock); @@ -20,8 +20,8 @@ void *t2(void *p) { void testB() { pthread_t t[2]; pthread_mutex_init(&lock, NULL); - pthread_create(&t[0], NULL, t1, NULL); - pthread_create(&t[1], NULL, t2, NULL); + pthread_create(&t[0], NULL, b1, NULL); + pthread_create(&t[1], NULL, b2, NULL); pthread_join(t[0], NULL); pthread_join(t[1], NULL); pthread_mutex_destroy(&lock); diff --git a/tests/tsan/data-race/CMakeLists.txt b/tests/tsan/data-race/CMakeLists.txt index 39a1f64719cfbc6d10debe70e1bd28bf615eb79b..2cdf5c16364a5c8dad26077e213cb9928779ee17 100644 --- a/tests/tsan/data-race/CMakeLists.txt +++ b/tests/tsan/data-race/CMakeLists.txt @@ -1,5 +1,8 @@ initproject(PROJECT_NAME tsanDataRace EXECUTABLES main LIBS a) +# # use share runtime +# set(CMAKE_EXE_LINKER_FLAGS "#{CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread -shared-libsan") + add_library(${a} SHARED src/a.cpp) target_compile_options(${a} PRIVATE "-fsanitize=thread") target_link_options(${a} PRIVATE "-fsanitize=thread") diff --git a/tests/tsan/data-race/src/a.cpp b/tests/tsan/data-race/src/a.cpp index 8b4bd20d73f277ec8fda6b997cfaad4c76d29f0a..ad5491cfb6a047556112ec9679537ebcbb95c3ec 100644 --- a/tests/tsan/data-race/src/a.cpp +++ b/tests/tsan/data-race/src/a.cpp @@ -2,7 +2,7 @@ extern int global; -void *testThread(void *x) { +static void *testThread(void *x) { global = 42; return x; } diff --git a/tests/ubsan/index-out-of-bounds/CMakeLists.txt b/tests/ubsan/index-out-of-bounds/CMakeLists.txt index c0798b4bbcedea306e6ee3970b074cc920533bde..a17c3ffecfb16491581eacb36208c815561ca3f2 100644 --- a/tests/ubsan/index-out-of-bounds/CMakeLists.txt +++ b/tests/ubsan/index-out-of-bounds/CMakeLists.txt @@ -6,7 +6,7 @@ target_compile_options(${a} PRIVATE "-O0") target_link_options(${a} PRIVATE "-fsanitize=undefined") add_library(${b} SHARED src/b.cpp) -target_compile_options(${a} PRIVATE "-fsanitize=undefined") +target_compile_options(${b} PRIVATE "-fsanitize=undefined") target_compile_options(${b} PRIVATE "-O0") target_link_options(${b} PRIVATE "-fsanitize=undefined")