Skip to content

Commit 34cfaeb

Browse files
committed
tarantool: support luzer-based testing
cd infra/base-images/base-runner/ sudo docker build -f ubuntu-24-04.Dockerfile -t gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04 . 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 /tmp/not-out/tmpl_6fepn3/tarantool: error while loading shared libraries: libncurses.so.6: cannot open shared object file: No such file or directory Depends on google#13929 Depends on ligurio/luzer#74
1 parent 0a2b430 commit 34cfaeb

File tree

5 files changed

+84
-5
lines changed

5 files changed

+84
-5
lines changed

infra/base-images/base-runner/ubuntu-20-04.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ COPY --from=base-ruby /usr/local/bin/gem /usr/local/bin/gem
117117
COPY --from=base-ruby /usr/local/lib/ruby /usr/local/lib/ruby
118118
COPY --from=base-ruby /usr/local/include/ruby-3.3.0 /usr/local/include/ruby-3.3.0
119119

120+
RUN apt-get update && apt-get install -y luarocks
121+
120122
# Do this last to make developing these files easier/faster due to caching.
121123
COPY bad_build_check \
122124
coverage \

infra/base-images/base-runner/ubuntu-24-04.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ COPY --from=base-ruby /usr/local/bin/gem /usr/local/bin/gem
117117
COPY --from=base-ruby /usr/local/lib/ruby /usr/local/lib/ruby
118118
COPY --from=base-ruby /usr/local/include/ruby-3.3.0 /usr/local/include/ruby-3.3.0
119119

120+
RUN apt-get update && apt-get install -y luarocks
121+
120122
# Do this last to make developing these files easier/faster due to caching.
121123
COPY bad_build_check \
122124
coverage \

projects/tarantool/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ RUN apt-get update && apt-get install -y \
2222
libunwind-dev luajit wget ninja-build \
2323
libzstd-dev libyaml-dev libcurl4-openssl-dev
2424

25-
RUN git clone --jobs $(nproc) --recursive https://github.com/tarantool/tarantool
25+
RUN git clone --branch ligurio/gh-12097-support-oss-fuzz --jobs $(nproc) --recursive https://github.com/ligurio/tarantool
2626
WORKDIR $SRC/tarantool
2727

2828
# Download a seed corpus.
29-
RUN rm -rf test/static
30-
RUN git clone https://github.com/ligurio/tarantool-corpus test/static
29+
# RUN rm -rf test/static
30+
# 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: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ fi
4949

5050
cmake_args=(
5151
# Specific to Tarantool
52+
-DBUILD_STATIC=ON
5253
-DENABLE_BACKTRACE=OFF
5354
-DENABLE_FUZZER=ON
5455
-DOSS_FUZZ=ON
@@ -82,18 +83,22 @@ cmake_args=(
8283

8384
# To deal with a host filesystem from inside of container.
8485
git config --global --add safe.directory '*'
86+
git pull --rebase
87+
88+
# Required by luzer and tarantool.
89+
export OSS_FUZZ=1
8590

8691
# Build the project and fuzzers.
8792
[[ -e build ]] && rm -rf build
8893
cmake "${cmake_args[@]}" -S . -B build
89-
cmake --build build --target fuzzers --parallel --verbose
94+
cmake --build build --parallel --verbose --target tarantool --target fuzzers
9095

9196
# Archive and copy to $OUT seed corpus if the build succeeded.
9297
# Postfix `_fuzzer` is used in Tarantool, postfix `_test` is
9398
# used in Lua C API tests [1].
9499
#
95100
# 1. https://github.com/ligurio/lua-c-api-tests/
96-
cp test/static/*.dict test/static/*.options $OUT/
101+
# cp test/static/*.dict test/static/*.options $OUT/
97102
for f in $(find build/test/fuzz/ \( -name '*_fuzzer' -o -name '*_test' \) -type f);
98103
do
99104
name=$(basename $f);
@@ -105,3 +110,36 @@ do
105110
zip --quiet -j $OUT/"$name"_seed_corpus.zip $corpus_dir/*
106111
fi
107112
done
113+
114+
# Finish execution if libFuzzer is not used, because luzer
115+
# is libFuzzer-based.
116+
if [[ "$FUZZING_ENGINE" != libfuzzer ]]; then
117+
return
118+
fi
119+
120+
apt install -y cmake luarocks liblua5.1-0 liblua5.1-0-dev liblua5.1-0-dbg lua5.1
121+
122+
luarocks install --lua-version 5.1 --server=https://luarocks.org/dev --tree=lua_modules luzer
123+
124+
LUA_RUNTIME_NAME=tarantool
125+
TARANTOOL_PATH=build/src/$LUA_RUNTIME_NAME
126+
127+
for f in $(find test/fuzz/lua -name '*_test.lua' -type f);
128+
do
129+
$SRC/compile_lua_fuzzer $LUA_RUNTIME_NAME $(basename $f)
130+
cp $f "$OUT/"
131+
done
132+
133+
$SRC/compile_lua_fuzzer $LUA_RUNTIME_NAME test/fuzz/lua/test_engine.lua
134+
cp test/fuzz/lua/test_engine.lua "$OUT/"
135+
136+
# ./test/fuzz/lua-tests/src/tests/lapi/math_atan_test.lua
137+
for f in $(find build/test/fuzz -name '*_test.lua' -type f);
138+
do
139+
$SRC/compile_lua_fuzzer $LUA_RUNTIME_NAME $(basename $f)
140+
cp $f "$OUT/"
141+
done
142+
cp build/test/fuzz/lua-tests/src/tests/lapi/lib.lua "$OUT"
143+
144+
cp $TARANTOOL_PATH "$OUT/$LUA_RUNTIME_NAME"
145+
cp -R lua_modules "$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 2025 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)