From de6577d6ebaf68877429d96293c90cb24eff84fc Mon Sep 17 00:00:00 2001 From: doodspav Date: Mon, 27 Nov 2023 00:57:08 +0200 Subject: [PATCH] GHI #20 Remove `patomic-test-ci` and CI tests --- test/CMakeLists.txt | 8 ----- test/ci/CMakeLists.txt | 10 ------ test/ci/check_asan.cpp | 69 ------------------------------------- test/ci/check_ubsan.cpp | 57 ------------------------------ test/cmake/CreateTest.cmake | 30 ---------------- 5 files changed, 174 deletions(-) delete mode 100644 test/ci/CMakeLists.txt delete mode 100644 test/ci/check_asan.cpp delete mode 100644 test/ci/check_ubsan.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8bcd4a2c5..d5e97c8ab 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -86,14 +86,6 @@ else() message(STATUS "Skipping unit tests; not building as sub-project of patomic") endif() -# only add CIs if running in CI -if($ENV{CI}) - add_subdirectory(ci) - message(STATUS "Enabled continuous integration tests") -else() - message(STATUS "Skipping continuous integration tests; not building as part of pipeline run") -endif() - # ---- Support Packaging Library ---- diff --git a/test/ci/CMakeLists.txt b/test/ci/CMakeLists.txt deleted file mode 100644 index b0b075d3a..000000000 --- a/test/ci/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -include(../cmake/CreateTest.cmake) - - -# ---- Setup Tests ---- - -add_custom_target(patomic-test-ci) -add_dependencies(patomic-test patomic-test-ci) - -create_ci(NAME check-asan SOURCE check_asan.cpp) -create_ci(NAME check-ubsan SOURCE check_ubsan.cpp) diff --git a/test/ci/check_asan.cpp b/test/ci/check_asan.cpp deleted file mode 100644 index d067060cd..000000000 --- a/test/ci/check_asan.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include - - -class CiAsanDeathTest : public testing::Test -{}; - - -TEST_F(CiAsanDeathTest, UseAfterFree) -{ -#if !PATOMIC_CI_ASAN - GTEST_SKIP() << "Address Sanitizer is not enabled"; -#else - auto fn = []() noexcept -> void { - int *p = new int(5); - volatile int val = *p; - delete p; - - volatile int _ = *p; // <-- use after free (intentional) - }; - EXPECT_DEATH(fn(), ".*AddressSanitizer: heap-use-after-free.*"); -#endif -} - -TEST_F(CiAsanDeathTest, HeapBufferOverflow) -{ -#if !PATOMIC_CI_ASAN - GTEST_SKIP() << "Address Sanitizer is not enabled"; -#else - auto fn = []() noexcept -> void { - int *arr = new int[100]{}; - int i = 1; - - volatile int _ = arr[100 + i]; // <-- buffer overflow (intentional) - - delete[] arr; - }; - EXPECT_DEATH(fn(), ".*AddressSanitizer: heap-buffer-overflow.*"); -#endif -} - -TEST_F(CiAsanDeathTest, StackBufferOverflow) -{ -#if !PATOMIC_CI_ASAN - GTEST_SKIP() << "Address Sanitizer is not enabled"; -#else - auto fn = []() noexcept -> void { - int arr[100]{}; - int i = 1; - - volatile int _ = arr[100 + i]; // <-- buffer overflow (intentional) - }; - EXPECT_DEATH(fn(), ".*AddressSanitizer: stack-buffer-overflow.*"); -#endif -} - -TEST_F(CiAsanDeathTest, GlobalBufferOverflow) -{ -#if !PATOMIC_CI_ASAN - GTEST_SKIP() << "Address Sanitizer is not enabled"; -#else - auto fn = []() noexcept -> void { - static int arr[100]{}; - int i = 1; - - volatile int _ = arr[100 + i]; // <-- buffer overflow (intentional) - }; - EXPECT_DEATH(fn(), ".*AddressSanitizer: global-buffer-overflow.*"); -#endif -} diff --git a/test/ci/check_ubsan.cpp b/test/ci/check_ubsan.cpp deleted file mode 100644 index d01091593..000000000 --- a/test/ci/check_ubsan.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include - -#include -#include - - -class CiUbsanDeathTest : public testing::Test -{}; - - -TEST_F(CiUbsanDeathTest, ShiftExponentTooLarge) -{ -#if !PATOMIC_CI_UBSAN - GTEST_SKIP() << "Undefined Behaviour Sanitizer is not enabled"; -#else - EXPECT_FATAL_FAILURE({ - volatile int _ = sizeof(int) * CHAR_BIT; - int x = 10; - int e = _; - - _ = x << e; // <-- shift exponent too large (intentional) - }, "ubsan"); -#endif -} - -TEST_F(CiUbsanDeathTest, SignedIntegerOverflow) -{ -#if !PATOMIC_CI_UBSAN - GTEST_SKIP() << "Undefined Behaviour Sanitizer is not enabled"; -#else - EXPECT_FATAL_FAILURE({ - volatile int _ = 5; - int x = _; - - x += INT_MAX; // <-- signed integer overflow (intentional) - - _ = x; - }, "ubsan"); -#endif -} - -TEST_F(CiUbsanDeathTest, FloatCastOverflow) -{ -#if !PATOMIC_CI_UBSAN - GTEST_SKIP() << "Undefined Behaviour Sanitizer is not enabled"; -#else - EXPECT_FATAL_FAILURE({ - volatile auto _ = std::numeric_limits::max(); - int x; - - x = static_cast(_); // <-- float cast overflow (intentional) - - _ = x; - }, "ubsan"); -#endif -} diff --git a/test/cmake/CreateTest.cmake b/test/cmake/CreateTest.cmake index 4f53aab66..1393d7224 100644 --- a/test/cmake/CreateTest.cmake +++ b/test/cmake/CreateTest.cmake @@ -328,33 +328,3 @@ function(create_ut) target_compile_definitions(${target_name} PRIVATE PATOMIC_STATIC_DEFINE) endfunction() - - -# Creates target patomic-test-ci-${name} corresponding to CI test executable. -# Note: intended to test CI environment, e.g. ensure sanitizer works. -# -# create_ci( -# NAME -# [INCLUDE ...] -# [SOURCE ...] -# [LINK ...] -# ) -function(create_ci) - - cmake_parse_arguments( - "ARG" - "" - "NAME" - "INCLUDE;SOURCE;LINK" - ${ARGN} - ) - - _create_test( - ${ARG_UNPARSED_ARGUMENTS} - CI ${ARG_NAME} - INCLUDE ${ARG_INCLUDE} - SOURCE ${ARG_SOURCE} - LINK ${ARG_LINK} - ) - -endfunction()