From: Vsevolod Stakhov Date: Fri, 5 Dec 2025 17:27:55 +0000 (+0000) Subject: [Test] Fix cffi-lua compatibility issues X-Git-Tag: 3.14.2~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2012775dec71a1236dd8550cf217611440d4e413;p=thirdparty%2Frspamd.git [Test] Fix cffi-lua compatibility issues - base32: Use tostring() for size_t values in format strings - expressions: Use %s instead of %d for float values (Lua 5.4 strict) - fpconv: Skip variadic function tests on cffi-lua (not supported) --- diff --git a/test/lua/unit/base32.lua b/test/lua/unit/base32.lua index 0996f4efd0..e6eaf7f686 100644 --- a/test/lua/unit/base32.lua +++ b/test/lua/unit/base32.lua @@ -47,8 +47,9 @@ context("Base32 encodning", function() local nl = ffi.new("size_t [1]") local nb = ffi.C.rspamd_decode_base32(bs, #bs, nl, how) - assert_equal(tonumber(nl[0]), l, - string.format("invalid size reported: %d reported vs %d expected", tonumber(nl[0]), l)) + local reported_len = tonumber(nl[0]) or 0 + assert_equal(reported_len, l, + string.format("invalid size reported: %s reported vs %s expected", tostring(reported_len), tostring(l))) local cmp = ffi.C.memcmp(b, nb, l) ffi.C.g_free(ben) ffi.C.g_free(nb) diff --git a/test/lua/unit/expressions.lua b/test/lua/unit/expressions.lua index 3d05685b07..3ea2627593 100644 --- a/test/lua/unit/expressions.lua +++ b/test/lua/unit/expressions.lua @@ -104,8 +104,8 @@ context("Rspamd expressions", function() assert_not_nil(expr, "Cannot parse " .. c[1] .. '; error: ' .. (err or 'wut??')) res = expr:process(atoms) - assert_equal(res, c[2], string.format("Processed expr '%s'{%s} returned '%d', expected: '%d'", - expr:to_string(), c[1], res, c[2])) + assert_equal(res, c[2], string.format("Processed expr '%s'{%s} returned '%s', expected: '%s'", + expr:to_string(), c[1], tostring(res), tostring(c[2]))) end) end end) diff --git a/test/lua/unit/fpconv.lua b/test/lua/unit/fpconv.lua index 6858b192a8..ee008708e3 100644 --- a/test/lua/unit/fpconv.lua +++ b/test/lua/unit/fpconv.lua @@ -2,9 +2,18 @@ context("Fpconv printf functions", function() local ok, ffi = pcall(require, "ffi") + local is_luajit_ffi = ok if not ok then ffi = require("cffi") end + + -- cffi-lua doesn't support variadic functions properly, skip these tests + if not is_luajit_ffi then + test("Skipped: cffi-lua does not support variadic functions", function() + -- This test suite requires LuaJIT FFI for variadic function support + end) + return + end local niter_fuzz = 100000 local function small_double() return math.random()