File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -36,20 +36,35 @@ jobs:
3636 sudo apt-get update
3737 sudo apt-get install -y cmake hwloc libhwloc-dev libnuma-dev libtbb-dev
3838
39+ - name : Find Clang fuzzer lib
40+ run : |
41+ CLANG_LIBS_DIR=$(find /usr/lib -name "libclang_rt.fuzzer_no_main-x86_64.a" -exec dirname {} \; | head -n 1)
42+ echo "CLANG_LIBS_DIR=${CLANG_LIBS_DIR}" >> $GITHUB_ENV
43+
3944 - name : Configure CMake
4045 run : >
4146 cmake
4247 -B ${{github.workspace}}/build
48+ -DCMAKE_PREFIX_PATH=${{env.CLANG_LIBS_DIR}}
4349 -DCMAKE_BUILD_TYPE=${{matrix.build_type}}
4450 -DCMAKE_C_COMPILER=${{matrix.compiler.c}}
4551 -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
52+ -DUMF_BUILD_SHARED_LIBRARY=ON
4653 -DUMF_TESTS_FAIL_ON_SKIP=ON
4754 -DUMF_DEVELOPER_MODE=ON
4855 -DUMF_BUILD_FUZZTESTS=ON
4956
5057 - name : Build
5158 run : cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} --verbose -j$(nproc)
5259
60+ - name : Run regular tests
61+ working-directory : ${{github.workspace}}/build
62+ run : ctest -C ${{matrix.build_type}} --output-on-failure -E "fuzz|test_init_teardown"
63+
64+ - name : Run regular tests with proxy library
65+ working-directory : ${{env.BUILD_DIR}}
66+ run : LD_PRELOAD=./lib/libumf_proxy.so ctest -C ${{matrix.build_type}} --output-on-failure -E "fuzz|test_init_teardown"
67+
5368 - name : Fuzz long test
5469 working-directory : ${{github.workspace}}/build
5570 run : ctest -C ${{matrix.build_type}} --output-on-failure --verbose -L "fuzz-long"
Original file line number Diff line number Diff line change @@ -586,6 +586,20 @@ if(UMF_BUILD_FUZZTESTS)
586586 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND LINUX)
587587 add_compile_options ("-fsanitize=fuzzer-no-link" )
588588 add_link_options ("-fsanitize=fuzzer-no-link" )
589+
590+ # We need to find the fuzzer lib in the LLVM installation dir and link
591+ # it statically as UMF does not define the main function used by fuzzer
592+ # as well as __sancov_* functions
593+ find_library (FUZZER_NO_MAIN_LIB
594+ NAMES libclang_rt.fuzzer_no_main-x86_64.a)
595+
596+ if (FUZZER_NO_MAIN_LIB)
597+ message (STATUS "Found fuzzer lib: ${FUZZER_NO_MAIN_LIB} " )
598+ # Fuzzer lib requires libstdc++
599+ link_libraries (${FUZZER_NO_MAIN_LIB} "stdc++" )
600+ else ()
601+ message (FATAL_ERROR "libclang_rt.fuzzer_no_main-x86_64 not found!" )
602+ endif ()
589603 else ()
590604 message (
591605 FATAL_ERROR
Original file line number Diff line number Diff line change @@ -97,6 +97,20 @@ List of sanitizers available on Windows:
9797
9898Listed sanitizers can be enabled with appropriate [ CMake options] ( #cmake-standard-options ) .
9999
100+ ### Fuzz testing
101+
102+ To enable fuzz testing, the ` UMF_BUILD_FUZZTESTS ` CMake configuration flag must
103+ be set to ` ON ` . Note, that this feature is supported only on Linux and requires
104+ Clang. Additionally, ensure that the ` CMAKE_PREFIX_PATH ` includes the directory
105+ containing the libraries necessary for fuzzing (e.g., Clang's
106+ libclang_rt.fuzzer_no_main-x86_64.a).
107+
108+ Example:
109+
110+ ``` bash
111+ cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DUMF_BUILD_FUZZTESTS=ON -DCMAKE_PREFIX_PATH=/path/to/fuzzer/libs
112+ ```
113+
100114### CMake standard options
101115
102116List of options provided by CMake:
You can’t perform that action at this time.
0 commit comments