diff --git a/changelogs/unreleased/add-asan-flag-to-tarantool-build.md b/changelogs/unreleased/add-asan-flag-to-tarantool-build.md new file mode 100644 index 0000000000000000000000000000000000000000..e04a08f5b2553624b2de663557e51d42ea026a08 --- /dev/null +++ b/changelogs/unreleased/add-asan-flag-to-tarantool-build.md @@ -0,0 +1,4 @@ +## feature/box + +* Added a new flag `tarantool.build.asan` that shows whether build + flag `ENABLE_ASAN` is set. diff --git a/src/lua/init.c b/src/lua/init.c index 94eed570dab6b10dc59ebe040c4fb727ab7190ac..a8e4afbd9e7e634730375bafc5d8dab1f10562aa 100644 --- a/src/lua/init.c +++ b/src/lua/init.c @@ -801,6 +801,15 @@ luaopen_tarantool(lua_State *L) #endif lua_settable(L, -3); + /* build.asan */ + lua_pushstring(L, "asan"); +#ifdef ENABLE_ASAN + lua_pushboolean(L, true); +#else + lua_pushboolean(L, false); +#endif + lua_settable(L, -3); + lua_settable(L, -3); /* box.info.build */ /* debug */ diff --git a/test/app-luatest/gh_7311_malloc_info_test.lua b/test/app-luatest/gh_7311_malloc_info_test.lua index 896b70aa8c2db20bc24548796c1b9a948dd29be7..1a2fefb0866e17ad066b699a10eeb33b5a2b00fe 100644 --- a/test/app-luatest/gh_7311_malloc_info_test.lua +++ b/test/app-luatest/gh_7311_malloc_info_test.lua @@ -21,7 +21,7 @@ local function is_supported() end -- If ASAN is enabled, malloc_info() exists but it is not implemented -- (all counters in the returned document are set to zeros). - if tarantool.build.flags:match('-fsanitize=[%a,]*address') then + if tarantool.build.asan then return false end return true diff --git a/test/app-luatest/tarantool_package_test.lua b/test/app-luatest/tarantool_package_test.lua new file mode 100644 index 0000000000000000000000000000000000000000..9a6b3d1c2fb87d407c0a9045b1e7d3ab837ab0aa --- /dev/null +++ b/test/app-luatest/tarantool_package_test.lua @@ -0,0 +1,10 @@ +local t = require('luatest') +local tarantool = require('tarantool') + +local g = t.group() + +g.test_build_asan = function() + local b = tarantool.build + local asan = b.flags:match('-fsanitize=[%a,]*address') ~= nil + t.assert_equals(b.asan, asan) +end