Skip to content

Commit 854eba8

Browse files
committed
tests/lapi: fix require string.buffer
The patch add a check for presence of string.buffer module to the tests. The module string.buffer built into LuaJIT, but not available in Tarantool and before the patch the tests were failed. Needed for google/oss-fuzz#14656
1 parent f0224a7 commit 854eba8

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

tests/lapi/string_buffer_encode_test.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ if test_lib.lua_version() ~= "LuaJIT" then
2727
os.exit(0)
2828
end
2929

30-
local string_buf = require("string.buffer")
30+
local has_string_buf, string_buf = pcall(require, "string.buffer")
31+
if not has_string_buf then
32+
print("Unsupported version.")
33+
os.exit(0)
34+
end
3135

3236
local function TestOneInput(buf, _size)
3337
local fdp = luzer.FuzzedDataProvider(buf)

tests/lapi/string_buffer_torture_test.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ if test_lib.lua_version() ~= "LuaJIT" then
3737
end
3838

3939
local ffi = require("ffi")
40-
local string_buf = require("string.buffer")
40+
local has_string_buf, string_buf = pcall(require, "string.buffer")
41+
if not has_string_buf then
42+
print("Unsupported version.")
43+
os.exit(0)
44+
end
4145
local unpack = unpack or table.unpack
4246

4347
local MAX_N = 1e2

0 commit comments

Comments
 (0)