-
Notifications
You must be signed in to change notification settings - Fork 3
Introduce infrastructure for running Lua API tests and add bitop tests #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
6593cea
to
9461590
Compare
https://github.com/ligurio/lua-c-api-tests/actions/runs/13946406205/job/39034554410?pr=121 |
9461590
to
b89866c
Compare
88cdf48
to
2a1da10
Compare
Build Tarantool: ``` CFLAGS="-fsanitize=fuzzer-no-link" LDFLAGS="-fsanitize=fuzzer-no-link" CC=clang CXX=clang++ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_FUZZER=ON -DLUAJIT_NUMMODE=2 ``` Build luzer: ``` git clone https://github.com/ligurio/luzer CC=clang-21 CXX=clang++-21 cmake -S . -B build cmake --build build/ --parallel ``` Run test: ``` LUA_CPATH='./luzer/build/luzer/?.so;;' LUA_PATH='./luzer/?/init.lua;;' ./src/tarantool ./test/fuzz/lua-tests/src/tests/lapi/bitop_bxor_test.lua LSAN_OPTIONS=suppressions=$(pwd)/asan/lsan.supp ASAN_OPTIONS=heap_profile=0:unmap_shadow_on_exit=1:print_suppressions=0 tarantool tarantool_csv.lua ``` Follows up commit 8ad443d ("cmake: introduce a module to build fuzzing tests"). TODO: - integrate with LSAN_OPTIONS and ASAN_OPTIONS 1. ligurio/lua-c-api-tests#121 NO_CHANGELOG=internal NO_DOC=internal NO_TEST=internal
Build Tarantool: ``` CFLAGS="-fsanitize=fuzzer-no-link" LDFLAGS="-fsanitize=fuzzer-no-link" CC=clang CXX=clang++ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_FUZZER=ON -DLUAJIT_NUMMODE=2 ``` Build luzer: ``` git clone https://github.com/ligurio/luzer CC=clang-21 CXX=clang++-21 cmake -S . -B build cmake --build build/ --parallel ``` Run test: ``` LUA_CPATH='./luzer/build/luzer/?.so;;' LUA_PATH='./luzer/?/init.lua;;' ./src/tarantool ./test/fuzz/lua-tests/src/tests/lapi/bitop_bxor_test.lua LSAN_OPTIONS=suppressions=$(pwd)/asan/lsan.supp ASAN_OPTIONS=heap_profile=0:unmap_shadow_on_exit=1:print_suppressions=0 tarantool tarantool_csv.lua ``` Follows up commit 8ad443d ("cmake: introduce a module to build fuzzing tests"). TODO: - integrate with LSAN_OPTIONS and ASAN_OPTIONS 1. ligurio/lua-c-api-tests#121 NO_CHANGELOG=internal NO_DOC=internal NO_TEST=internal
37d8d5e
to
6a381f9
Compare
The commit 8ad443d ("cmake: introduce a module to build fuzzing tests") has added tests for LuaJIT. These tests mostly written in C and tests LuaJIT via Lua C API. The patch integrates tests that written in Lua and tests LuaJIT via Lua API, see [1]. Depends on: 1. ligurio/lua-c-api-tests#121 2. tarantool#11056 NO_CHANGELOG=testing NO_DOC=testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, Sergey!
Thanks for the patch!
I believe that the most part of problems are from the bit library API misuse. It expects 32-bit integers for inputs, see details here.
Also we may provide more checks like the following.
The commit 8ad443d ("cmake: introduce a module to build fuzzing tests") has added tests for LuaJIT. These tests mostly written in C and tests LuaJIT via Lua C API. The patch integrates tests that written in Lua and tests LuaJIT via Lua API, see [1]. Depends on: 1. ligurio/lua-c-api-tests#121 2. tarantool#11056 NO_CHANGELOG=testing NO_DOC=testing
4a0af62
to
84f2aa3
Compare
84f2aa3
to
f234fcb
Compare
26c535a
to
7fb04d3
Compare
3770f24
to
b7b0525
Compare
b7b0525
to
c3c3f05
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fixes!
LGTM.
The patch add a CMake module that builds a luzer [1], a coverage-guided, native Lua fuzzing engine. Needed for the following commit. 1. https://github.com/ligurio/luzer
While extending tests it is often required to append additional path where Lua or Lua C auxiliary modules are located to LUA_PATH or LUA_CPATH environment variables. Due to insane semicolon interpolation in CMake strings (that converts such string to a list as a result), we need to escape semicolon in LUA_PATH/LUA_CPATH strings while building the resulting value. The patch introduce MakeLuaPath.cmake module to make LUA_PATH and LUA_CPATH definition convenient with <lapi_tests_make_lua_path> helper. This function takes all paths given as a variable list argument, joins them in a reverse order by a semicolon and yields the resulting string to a specified CMake variable. Needed for the following commit.
The patch adds initial infrastructure for Lua API tests and changes existed infrastructure for running these tests and adds a fuzzing tests for bitwise operations in PUC Rio (since 5.2) [1] Lua and bitwise functions in LuaJIT [2][3]. Lua API tests can be enabled by CMake option ENABLE_LAPI_TESTS. The option is disabled by default, because necessary dependencies are not installed in OSS Fuzz and thus workflow is failed. PUC Rio Lua provided auto-coercion of string arguments to numbers by default, but it has been removed from the core language in 5.4. LuaJIT provides auto-coercion of string arguments to numbers by default, but it doesn not tested by proposed tests. The patch requires commit "cmake: allow to set a Lua library outside" [4] in the `luzer` project. The proposed bitop tests are capable to reproduce a LuaJIT issue with bit op coercion for shifts in DUALNUM builds [5]. Rules from boolean algebra [6] has been used as invariants for bitwise expressions. 1. https://www.lua.org/manual/5.2/manual.html#6.7 2. https://bitop.luajit.org/semantics.html 3. https://bitop.luajit.org/api.html 4. ligurio/luzer@4ce52a6 5. LuaJIT/LuaJIT@69bbf3c1 6. https://en.wikipedia.org/wiki/Bitwise_operation#Boolean_algebra
c3c3f05
to
5715005
Compare
The commit "tests/lapi: add bitop tests" [1]. 1. ligurio/lua-c-api-tests@d4b91f6 Follows up ligurio/lua-c-api-tests#121 Related to tarantool/tarantool#11401 Related to tarantool/tarantool#11301
The commit "tests/lapi: add bitop tests" [1]. 1. ligurio/lua-c-api-tests@d4b91f6 Follows up ligurio/lua-c-api-tests#121 Related to tarantool/tarantool#11401 Related to tarantool/tarantool#11301
The commit 8ad443d ("cmake: introduce a module to build fuzzing tests") has added tests for LuaJIT. These tests mostly written in C and tests LuaJIT via Lua C API. The patch integrates tests that written in Lua and tests LuaJIT via Lua API, see [1]. Depends on: 1. ligurio/lua-c-api-tests#121 2. tarantool#11056 NO_CHANGELOG=testing NO_DOC=testing
It is needed to discuss the following questions on review:
-O1
,-O2
,-O3
etc.) 1 and apply them?build_luzer()
?Blocked by:
Footnotes
https://luajit.org/running.html ↩