|
48 | 48 | : ${LDFLAGS:="${CXXFLAGS}"} # to make sure we link with sanitizer runtime |
49 | 49 |
|
50 | 50 | cmake_args=( |
51 | | - # Specific to Tarantool |
| 51 | + # Specific to Tarantool. |
| 52 | + # Tarantool executable binary is needed for running Lua tests, |
| 53 | + # it should not have any dependencies. |
| 54 | + -DBUILD_STATIC=ON |
| 55 | + # XXX: Sysprof requires ENABLE_BACKTRACE=ON. |
52 | 56 | -DENABLE_BACKTRACE=OFF |
53 | 57 | -DENABLE_FUZZER=ON |
54 | 58 | -DOSS_FUZZ=ON |
@@ -82,18 +86,22 @@ cmake_args=( |
82 | 86 |
|
83 | 87 | # To deal with a host filesystem from inside of container. |
84 | 88 | git config --global --add safe.directory '*' |
| 89 | +git pull --rebase |
| 90 | + |
| 91 | +# Required by luzer and tarantool. |
| 92 | +export OSS_FUZZ=1 |
85 | 93 |
|
86 | 94 | # Build the project and fuzzers. |
87 | 95 | [[ -e build ]] && rm -rf build |
88 | 96 | cmake "${cmake_args[@]}" -S . -B build |
89 | | -cmake --build build --target fuzzers --parallel --verbose |
| 97 | +cmake --build build --target fuzzers --target tarantool --parallel --verbose |
90 | 98 |
|
91 | 99 | # Archive and copy to $OUT seed corpus if the build succeeded. |
92 | 100 | # Postfix `_fuzzer` is used in Tarantool, postfix `_test` is |
93 | | -# used in Lua C API tests [1]. |
| 101 | +# used in additional tests [1]. |
94 | 102 | # |
95 | 103 | # 1. https://github.com/ligurio/lunapark |
96 | | -cp test/static/*.dict test/static/*.options $OUT/ |
| 104 | +# cp test/static/*.dict test/static/*.options $OUT/ |
97 | 105 | for f in $(find build/test/fuzz/ \( -name '*_fuzzer' -o -name '*_test' \) -type f); |
98 | 106 | do |
99 | 107 | name=$(basename $f); |
|
105 | 113 | zip --quiet -j $OUT/"$name"_seed_corpus.zip $corpus_dir/* |
106 | 114 | fi |
107 | 115 | done |
| 116 | + |
| 117 | +# Finish execution if libFuzzer is not used, because luzer |
| 118 | +# is libFuzzer-based, UndefinedSanitizer is not supported. |
| 119 | +if [[ "$FUZZING_ENGINE" != libfuzzer ]] || |
| 120 | + [[ "$SANITIZER" == "undefined" ]]; then |
| 121 | + exit |
| 122 | +fi |
| 123 | + |
| 124 | +LUA_RUNTIME_NAME=tarantool |
| 125 | +TARANTOOL_PATH=build/src/$LUA_RUNTIME_NAME |
| 126 | +LUA_MODULES_DIR=lua_modules |
| 127 | + |
| 128 | +apt install -y luarocks liblua5.1-0 liblua5.1-0-dev liblua5.1-0-dbg lua5.1 |
| 129 | + |
| 130 | +luarocks install --lua-version 5.1 --server=https://luarocks.org/dev --tree=$LUA_MODULES_DIR luzer |
| 131 | + |
| 132 | +cp build/test/fuzz/lua-tests/src/tests/lapi/lib.lua "$OUT" |
| 133 | +# Copying luzer-based tests to build/luzer_tests. |
| 134 | +cmake --build build --parallel --verbose --target copy_tests |
| 135 | +# Generating test wrappers for luzer-based tests. |
| 136 | +for test_file in $(find build/luzer_tests -name "*.lua" -type f); |
| 137 | +do |
| 138 | + "$SRC/compile_lua_fuzzer" "$LUA_RUNTIME_NAME" $(basename "$test_file") |
| 139 | + cp "$test_file" "$OUT/" |
| 140 | +done |
| 141 | + |
| 142 | +cp $TARANTOOL_PATH "$OUT/$LUA_RUNTIME_NAME" |
| 143 | +cp -R $LUA_MODULES_DIR "$OUT/" |
0 commit comments