|
29 | 29 | cmake_args=( |
30 | 30 | -DUSE_LUAJIT=ON |
31 | 31 | -DOSS_FUZZ=ON |
| 32 | + -DENABLE_LAPI_TESTS=ON |
32 | 33 | $SANITIZERS_ARGS |
33 | 34 |
|
34 | 35 | # C compiler |
|
87 | 88 | zip -urj $OUT/"$name"_seed_corpus.zip "$options_path" |
88 | 89 | fi |
89 | 90 | done |
| 91 | + |
| 92 | +# Code coverage is not supported. |
| 93 | +if [[ "$SANITIZER" == "coverage" ]]; then |
| 94 | + exit |
| 95 | +fi |
| 96 | + |
| 97 | +LUA_RUNTIME_NAME=luajit |
| 98 | +LUAJIT_PATH=build/luajit-v2.1/source/src/$LUA_RUNTIME_NAME |
| 99 | +LUA_MODULES_DIR=lua_modules |
| 100 | + |
| 101 | +apt install -y luarocks liblua5.1-0 liblua5.1-0-dev liblua5.1-0-dbg lua5.1 |
| 102 | + |
| 103 | +# Required by luzer installed using luarocks. |
| 104 | +export OSS_FUZZ=1 |
| 105 | +luarocks install --lua-version 5.1 --server=https://luarocks.org/dev --tree=$LUA_MODULES_DIR luzer |
| 106 | +unset OSS_FUZZ |
| 107 | + |
| 108 | +cp tests/lapi/lib.lua $OUT |
| 109 | + |
| 110 | +LUZER_TESTS_DIR="tests/lapi/" |
| 111 | +# Generating test wrappers for luzer-based tests. |
| 112 | +for test_path in $(find $LUZER_TESTS_DIR -name "*_test.lua" -type f); |
| 113 | +do |
| 114 | + test_file=$(basename $test_path); |
| 115 | + test_name_we="${test_file%.*}"; |
| 116 | + # The following tests made for the functions that unsupported by |
| 117 | + # LuaJIT. |
| 118 | + if [[ $test_name_we == "math_tointeger_test" || |
| 119 | + $test_name_we == "math_ult_test" || |
| 120 | + $test_name_we == "string_pack_test" || |
| 121 | + $test_name_we == "string_packsize_test" || |
| 122 | + $test_name_we == "string_unpack_test" || |
| 123 | + $test_name_we == "table_pack_test" || |
| 124 | + $test_name_we == "utf8_char_test" || |
| 125 | + $test_name_we == "utf8_codepoint_test" || |
| 126 | + $test_name_we == "utf8_codes_test" || |
| 127 | + $test_name_we == "utf8_len_test" || |
| 128 | + $test_name_we == "utf8_offset_test" ]]; then |
| 129 | + continue |
| 130 | + fi |
| 131 | + module_name=$(echo $test_name_we | sed 's/_test//' ) |
| 132 | + "$SRC/compile_lua_fuzzer" "$LUA_RUNTIME_NAME" $test_file |
| 133 | + cp "$test_path" "$OUT/" |
| 134 | + corpus_dir="corpus/corpus/$test_name_we" |
| 135 | + if [ -e "$corpus_dir" ]; then |
| 136 | + zip -j $OUT/"$test_name_we"_seed_corpus.zip $corpus_dir/* |
| 137 | + echo "Build corpus '$OUT/"$test_name_we"_seed_corpus.zip' for the test '$test_name_we'" |
| 138 | + fi |
| 139 | +done |
| 140 | + |
| 141 | +cp $LUAJIT_PATH "$OUT/$LUA_RUNTIME_NAME" |
| 142 | +cp -R $LUA_MODULES_DIR "$OUT/" |
0 commit comments