diff --git a/.gitignore b/.gitignore index 67cc1b237a..23b84112cd 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,8 @@ target/ ## VSCode IDE .vscode + +#Generated files +cufile.log +rmm_log.txt +sanitizer_for_pid_*.log diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 817a9b9c07..1c045a137b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -224,6 +224,40 @@ in errors finding libraries. The script `build/run-in-docker` was created to hel situation. A test can be run directly using this script or the script can be run without any arguments to get into an interactive shell inside the container. ```build/run-in-docker target/cmake-build/gtests/ROW_CONVERSION``` + +#### Testing with Compute Sanitizer +[Compute Sanitizer](https://docs.nvidia.com/compute-sanitizer/ComputeSanitizer/index.html) is a +functional correctness checking suite included in the CUDA toolkit. The RAPIDS Accelerator JNI +supports leveraging the Compute Sanitizer in memcheck mode in the unit tests to help catch any kernels +that may be doing something incorrectly. To run the unit tests with the Compute Sanitizer, append the +`-DUSE_SANITIZER=ON` to the build command. e.g. +``` +> ./build/build-in-docker clean package -DUSE_SANITIZER=ON +``` + +The Compute Sanitizer will output its report into one or multiple log files named as +`sanitizer_for_pid_.log` under the current workspace root path. + +Please note not all the unit tests can run with Compute Sanitizer. For example, `RmmTest#testEventHandler`, +a problematic test, intentionally tries an illegal allocation because of a too big size as part of the +test, but Compute Sanitizer will still report the errors and fail the whole build process. +`UnsafeMemoryAccessorTest` is for host memory only, so there is no need to run it with +Compute Sanitizer either. + +If you think your tests are not suitable for Compute Sanitizer, please add the JUnit5 tag (`@Tag("noSanitizer")`) +to the tests or the test class. +``` +@Tag("noSanitizer") +class ExceptionCaseTest { ... } + +# or for a single test +class NormalCaseTest { + + @Tag("noSanitizer") + public void testOneErrorCase(){ ... } +} +``` + ### Benchmarks Benchmarks exist for c++ benchmarks using NVBench and are in the `src/main/cpp/benchmarks` directory. To build these benchmarks requires the `-DBUILD_BENCHMARKS` build option. Once built, the benchmarks diff --git a/build/sanitizer-java/bin/java b/build/sanitizer-java/bin/java new file mode 100755 index 0000000000..4e1c991c1a --- /dev/null +++ b/build/sanitizer-java/bin/java @@ -0,0 +1,25 @@ +#!/bin/bash +# +# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# This special Java executable is specified to the "jvm" configuration of the +# the surefire plugin to intercept forking the processes for tests. Then +# the tests will run with the compute-sanitizer tool. +exec compute-sanitizer --tool memcheck \ + --launch-timeout 600 \ + --error-exitcode -2 \ + --log-file "./sanitizer_for_pid_%p.log" \ + java "$@" diff --git a/ci/nightly-build.sh b/ci/nightly-build.sh index b073abbae9..668d650c5c 100755 --- a/ci/nightly-build.sh +++ b/ci/nightly-build.sh @@ -31,4 +31,5 @@ ${MVN} clean package ${MVN_MIRROR} \ -DCPP_PARALLEL_LEVEL=${PARALLEL_LEVEL} \ -Dlibcudf.build.configure=true \ -DUSE_GDS=${USE_GDS} -Dtest=*,!CuFileTest,!CudaFatalTest,!ColumnViewNonEmptyNullsTest \ - -DBUILD_TESTS=ON -Dcuda.version=$CUDA_VER + -DBUILD_TESTS=ON -Dcuda.version=$CUDA_VER \ + -DUSE_SANITIZER=ON diff --git a/ci/premerge-build.sh b/ci/premerge-build.sh index 9a3cd41184..a2b340cd5f 100755 --- a/ci/premerge-build.sh +++ b/ci/premerge-build.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -27,4 +27,5 @@ ${MVN} verify ${MVN_MIRROR} \ -DCPP_PARALLEL_LEVEL=${PARALLEL_LEVEL} \ -Dlibcudf.build.configure=true \ -DUSE_GDS=ON -Dtest=*,!CuFileTest,!CudaFatalTest,!ColumnViewNonEmptyNullsTest \ - -DBUILD_TESTS=ON + -DBUILD_TESTS=ON \ + -DUSE_SANITIZER=ON diff --git a/pom.xml b/pom.xml index 507c191cdc..1b1787919c 100644 --- a/pom.xml +++ b/pom.xml @@ -141,6 +141,12 @@ ${junit.version} test + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + org.junit.jupiter junit-jupiter-params @@ -199,14 +205,51 @@ + + + + + + + test-with-sanitizer + + + USE_SANITIZER + ON + + + + + + maven-surefire-plugin + + + default-test + + test + + + !noSanitizer + ${project.basedir}/build/sanitizer-java/bin/java + + + + + sanitizer-excluded-cases-test + + test + + + noSanitizer + + non-empty-null-test test - -da:ai.rapids.cudf.AssertEmptyNulls - ColumnViewNonEmptyNullsTest + ${project.basedir}/build/sanitizer-java/bin/java @@ -250,7 +293,7 @@ - + test-cpp