Skip to content

Commit

Permalink
WIP compsan [skip-vdc][skip-docs][skip-rapids]
Browse files Browse the repository at this point in the history
  • Loading branch information
alliepiper committed Jun 28, 2024
1 parent bca1ca3 commit 4edb31e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
1 change: 1 addition & 0 deletions ci/test_cub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ fi
if $COMPUTE_SANITIZER; then
echo "Setting CCCL_TEST_MODE=compute-sanitizer-${TOOL}"
export CCCL_TEST_MODE=compute-sanitizer-${TOOL}
echo "Setting CCCL_SEED_COUNT_OVERRIDE=1"
export CCCL_SEED_COUNT_OVERRIDE=1
fi

Expand Down
2 changes: 2 additions & 0 deletions cub/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ function(cub_add_test target_name_var test_name test_src cub_target launcher_id)
add_test(NAME ${test_target} COMMAND
"${CMAKE_COMMAND}"
"-DTEST=$<TARGET_FILE:${test_target}>"
"-DTYPE=Catch2"
-P "${CUB_SOURCE_DIR}/test/run_test.cmake"
)
else() # Not CUB_SEPARATE_CATCH2
Expand Down Expand Up @@ -251,6 +252,7 @@ function(cub_add_test target_name_var test_name test_src cub_target launcher_id)
add_test(NAME ${config_c2run_target} COMMAND
"${CMAKE_COMMAND}"
"-DTEST=$<TARGET_FILE:${config_c2run_target}>"
"-DTYPE=Catch2"
-P "${CUB_SOURCE_DIR}/test/run_test.cmake"
)
endif() # per config catch2 runner
Expand Down
4 changes: 3 additions & 1 deletion cub/test/catch2_test_device_merge_sort.cu
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,9 @@ CUB_TEST(
REQUIRE(values_expected == values_in_out);
}

CUB_TEST("DeviceMergeSort::StableSortPairs works for large inputs", "[merge][sort][device]", offset_types)
CUB_TEST("DeviceMergeSort::StableSortPairs works for large inputs",
"[merge][sort][device][skip-cs-initcheck][skip-cs-racecheck]",
offset_types)
{
using testing_types_tuple = c2h::get<0, TestType>;
using key_t = typename testing_types_tuple::key_t;
Expand Down
7 changes: 5 additions & 2 deletions cub/test/catch2_test_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ std::size_t adjust_seed_count(std::size_t requested)
// Setting this environment variable forces a fixed number of seeds to be generated, regardless of the requested
// count. Set to 1 to reduce redundant, expensive testing when using sanitizers, etc.
static const char* override_str = std::getenv("CCCL_SEED_COUNT_OVERRIDE");
static int override = override_str ? std::atoi(override_str) : 0;
return override_str ? override : requested;
static int override_seeds = override_str ? std::atoi(override_str) : 0;
return override_str ? override_seeds : requested;
}
} // namespace detail

Expand All @@ -270,3 +270,6 @@ std::size_t adjust_seed_count(std::size_t requested)
detail::adjust_seed_count(N), \
random(std::numeric_limits<unsigned long long int>::min(), std::numeric_limits<unsigned long long int>::max()))) \
}

// Tags to skip compute-sanitizer checks:
CATCH_REGISTER_TAG_ALIAS("[@skip-cs-all]", "[skip-cs-memcheck][skip-cs-racecheck][skip-cs-synccheck][skip-cs-initcheck]")
26 changes: 20 additions & 6 deletions cub/test/run_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
function(usage)
message("Usage:")
message(" cmake -D TEST=bin/test.exe \\")
message(" -D ARGS=\"arg1 arg2\" \\")
message(" -D ARGS=\"arg1;arg2;arg3\" \\")
message(" -D TYPE=Catch2")
message(" -D MODE=compute-sanitizer-memcheck \\")
message(" -P cccl/cub/test/run_test.cmake")
message("")
message(" - TEST: Required. Path to the test executable.")
message(" - ARGS: Optional. Arguments to pass to the test executable.")
message(" - TYPE: Optional.")
message(" - The test framework used by the test executable.")
message(" - Must be one of the following:")
message(" - \"none\" (default)")
message(" - \"Catch2\"")
message(" - MODE: Optional.")
message(" - May be set through CCCL_TEST_MODE env var.")
message(" - Must be one of the following:")
Expand All @@ -28,14 +34,15 @@ endfunction()
# The new process's stdout, sterr are redirected to the current process.
# The current process will exit with an error if the new process exits with a non-zero status.
function(run_command command)
list(APPEND command ${ARGN})
list(JOIN command " " command_str)
set(command_str "${command}")
list(APPEND command_str ${ARGN})
list(JOIN command_str " " command_str)
message(STATUS ">> Running:\n\t${command_str}")
execute_process(COMMAND ${command} RESULT_VARIABLE result)
execute_process(COMMAND ${command} ${ARGN} RESULT_VARIABLE result)
if (NOT result EQUAL 0)
message(FATAL_ERROR ">> Exit Status: ${result}")
else()
message(STATUS ">>Exit Status: ${result}")
message(STATUS ">> Exit Status: ${result}")
endif()
endfunction()

Expand All @@ -48,7 +55,11 @@ if(NOT DEFINED TEST)
endif()

if(NOT DEFINED ARGS)
set(ARGS "")
set(ARGS)
endif()

if(NOT DEFINED TYPE)
set(TYPE "none")
endif()

if(NOT DEFINED MODE)
Expand All @@ -66,6 +77,9 @@ if (MODE STREQUAL "none")
run_command(${TEST} ${ARGS})
elseif (MODE MATCHES "^compute-sanitizer-(.*)$")
set(tool ${CMAKE_MATCH_1})
if (TYPE STREQUAL "Catch2")
list(APPEND ARGS "--durations" "yes")
endif()
run_command(compute-sanitizer
--tool ${tool}
# TODO Figure out what the min version needed is for this:
Expand Down

0 comments on commit 4edb31e

Please sign in to comment.