Skip to content

Commit 468543f

Browse files
committed
tarantool: support luzer-based testing
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Depends on ligurio/lunapark#163 Depends on ligurio/luzer#73 Depends on ligurio/luzer#76 Depends on tarantool/tarantool#12097
1 parent 27fa1e9 commit 468543f

File tree

3 files changed

+76
-4
lines changed

3 files changed

+76
-4
lines changed

projects/tarantool/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ RUN rm -rf test/static
3030
RUN git clone https://github.com/ligurio/tarantool-corpus test/static
3131

3232
COPY build.sh $SRC/
33+
COPY compile_lua_fuzzer $SRC/

projects/tarantool/build.sh

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ fi
4949

5050
cmake_args=(
5151
# Specific to Tarantool
52-
-DENABLE_BACKTRACE=OFF
52+
# Tarantool executable binary is needed for running Lua tests,
53+
# it should not have any dependencies.
54+
-DBUILD_STATIC=ON
55+
-DENABLE_BACKTRACE=ON
5356
-DENABLE_FUZZER=ON
5457
-DOSS_FUZZ=ON
5558
-DLUA_USE_APICHECK=ON
@@ -76,21 +79,25 @@ cmake_args=(
7679

7780
# Dependencies
7881
-DENABLE_BUNDLED_ICU=ON
79-
-DENABLE_BUNDLED_LIBUNWIND=OFF
82+
-DENABLE_BUNDLED_LIBUNWIND=ON
8083
-DENABLE_BUNDLED_ZSTD=OFF
8184
)
8285

8386
# To deal with a host filesystem from inside of container.
8487
git config --global --add safe.directory '*'
88+
git pull --rebase
89+
90+
# Required by luzer and tarantool.
91+
export OSS_FUZZ=1
8592

8693
# Build the project and fuzzers.
8794
[[ -e build ]] && rm -rf build
8895
cmake "${cmake_args[@]}" -S . -B build
89-
cmake --build build --target fuzzers --parallel --verbose
96+
cmake --build build --target fuzzers --target tarantool --parallel --verbose
9097

9198
# Archive and copy to $OUT seed corpus if the build succeeded.
9299
# Postfix `_fuzzer` is used in Tarantool, postfix `_test` is
93-
# used in Lua C API tests [1].
100+
# used in additional tests [1].
94101
#
95102
# 1. https://github.com/ligurio/lunapark
96103
cp test/static/*.dict test/static/*.options $OUT/
@@ -105,3 +112,31 @@ do
105112
zip --quiet -j $OUT/"$name"_seed_corpus.zip $corpus_dir/*
106113
fi
107114
done
115+
116+
# Finish execution if libFuzzer is not used, because luzer
117+
# is libFuzzer-based, UndefinedSanitizer is not supported.
118+
if [[ "$FUZZING_ENGINE" != libfuzzer ]] ||
119+
[[ "$SANITIZER" == "undefined" ]]; then
120+
exit
121+
fi
122+
123+
LUA_RUNTIME_NAME=tarantool
124+
TARANTOOL_PATH=build/src/$LUA_RUNTIME_NAME
125+
LUA_MODULES_DIR=lua_modules
126+
127+
apt install -y luarocks liblua5.1-0 liblua5.1-0-dev liblua5.1-0-dbg lua5.1
128+
129+
luarocks install --lua-version 5.1 --server=https://luarocks.org/dev --tree=$LUA_MODULES_DIR luzer
130+
131+
cp build/test/fuzz/lua-tests/src/tests/lapi/lib.lua "$OUT"
132+
# Copying luzer-based tests to build/luzer_tests.
133+
cmake --build build --parallel --verbose --target copy_tests
134+
# Generating test wrappers for luzer-based tests.
135+
for test_file in $(find build/luzer_tests -name "*.lua" -type f);
136+
do
137+
"$SRC/compile_lua_fuzzer" "$LUA_RUNTIME_NAME" $(basename "$test_file")
138+
cp "$test_file" "$OUT/"
139+
done
140+
141+
cp $TARANTOOL_PATH "$OUT/$LUA_RUNTIME_NAME"
142+
cp -R $LUA_MODULES_DIR "$OUT/"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash -eu
2+
# Copyright 2026 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
################################################################################
17+
18+
# The Lua runtime name.
19+
lua_runtime=$1
20+
# Path to the fuzz target source file relative to the project's root.
21+
fuzz_target=$2
22+
23+
fuzzer_basename=$(basename -s .lua "$fuzz_target")
24+
25+
# Create an execution wrapper that executes luzer with the correct
26+
# arguments.
27+
echo "#!/bin/bash
28+
29+
# LLVMFuzzerTestOneInput so that the wrapper script is recognized
30+
# as a fuzz target for 'check_build'.
31+
project_dir=\$(dirname \"\$0\")
32+
eval \$(luarocks --lua-version 5.1 --tree lua_modules path)
33+
ASAN_OPTIONS=\$ASAN_OPTIONS:symbolize=1:external_symbolizer_path=\$project_dir/llvm-symbolizer:detect_leaks=0 \
34+
\$project_dir/$lua_runtime \$project_dir/$fuzz_target \$@" > "$OUT/$fuzzer_basename"
35+
36+
chmod +x "$OUT/$fuzzer_basename"

0 commit comments

Comments
 (0)