commit 2b2050d05a7da14260e11d1d279486a40670cd51 from: Sergey Bronnikov via: Sergey Bronnikov date: Wed Apr 05 06:51:12 2023 UTC tests: add json test commit - 2167dc2f43915029dc216124beb0debcddd59e4e commit + 2b2050d05a7da14260e11d1d279486a40670cd51 blob - /dev/null blob + f100719f4f1c8061b588944b4f9204e6308a71a9 (mode 644) --- /dev/null +++ tests/tarantool_json.lua @@ -0,0 +1,36 @@ +-- https://github.com/tarantool/tarantool/issues/4366 +-- https://www.tarantool.io/en/doc/latest/reference/reference_lua/json/ + +local json = require("json") +local luzer = require("luzer") +local math = require("math") + +local function TestOneInput(buf) + local ok, obj = pcall(json.decode, buf) + if obj == math.inf or + obj == 0/0 then + return -1 + end + if ok == true then + assert(json.encode(obj) ~= nil) + end +end + +if arg[1] then + local fh = io.open(arg[1]) + local testcase = fh:read("*all") + TestOneInput(testcase) + os.exit() +end + +local script_path = debug.getinfo(1).source:match("@?(.*/)") + +local args = { + max_len = 4096, + dict = script_path .. "/tarantool-corpus/json_decode.dict", + corpus = script_path .. "/tarantool-corpus/json_decode", + artifact_prefix = "json_decode_", + max_total_time = 60, + print_final_stats = 1, +} +luzer.Fuzz(TestOneInput, nil, args)