File tree 3 files changed +43
-0
lines changed
3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -36,20 +36,35 @@ jobs:
36
36
sudo apt-get update
37
37
sudo apt-get install -y cmake hwloc libhwloc-dev libnuma-dev libtbb-dev
38
38
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
+
39
44
- name : Configure CMake
40
45
run : >
41
46
cmake
42
47
-B ${{github.workspace}}/build
48
+ -DCMAKE_PREFIX_PATH=${{env.CLANG_LIBS_DIR}}
43
49
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
44
50
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
45
51
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
52
+ -DUMF_BUILD_SHARED_LIBRARY=ON
46
53
-DUMF_TESTS_FAIL_ON_SKIP=ON
47
54
-DUMF_DEVELOPER_MODE=ON
48
55
-DUMF_BUILD_FUZZTESTS=ON
49
56
50
57
- name : Build
51
58
run : cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} --verbose -j$(nproc)
52
59
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
+
53
68
- name : Fuzz long test
54
69
working-directory : ${{github.workspace}}/build
55
70
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)
586
586
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND LINUX)
587
587
add_compile_options ("-fsanitize=fuzzer-no-link" )
588
588
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 ()
589
603
else ()
590
604
message (
591
605
FATAL_ERROR
Original file line number Diff line number Diff line change @@ -97,6 +97,20 @@ List of sanitizers available on Windows:
97
97
98
98
Listed sanitizers can be enabled with appropriate [ CMake options] ( #cmake-standard-options ) .
99
99
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
+
100
114
### CMake standard options
101
115
102
116
List of options provided by CMake:
You can’t perform that action at this time.
0 commit comments