Skip to content

Commit e409734

Browse files
committed
tests/capi: dump Lua samples
mkdir /tmp/corpus RUNS=1 ctest -R luaL_loadbuffer_proto_test --verbose /home/sergeyb/sources/lua-c-api-tests/build/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test -print_final_stats=1 -print_pcs=1 -reduce_inputs=1 -reload=1 -runs=1 -workers=22 -timeout=5 -jobs=5 /home/sergeyb/sources/lua-c-api-tests/corpus/corpus/luaL_loadbuffer_proto_test LUA_FUZZER_VERBOSE=1 LPM_DUMP_NATIVE_INPUT=1 /home/sergeyb/sources/lua-c-api-tests/build/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test -print_final_stats=1 -print_pcs=1 -reduce_inputs=1 -reload=1 -runs=1 -workers=22 -timeout=5 /home/sergeyb/sources/lua-c-api-tests/corpus/corpus/luaL_loadbuffer_proto_test 2>&1 | tee log.txt ``` mkdir /tmp/lua-corpus/ go install github.com/yuin/gopher-lua/cmd/glua stat $GOPATH/bin/glua for f in /tmp/lua-corpus/*; do echo $f; glua $f; done ```
1 parent fc84243 commit e409734

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
* Copyright 2022, Tarantool AUTHORS.
66
*/
77

8+
#include <fstream>
9+
#include <string>
10+
#include <iostream>
11+
812
extern "C"
913
{
1014
#include "lua.h"
@@ -304,6 +308,11 @@ DEFINE_PROTO_FUZZER(const lua_grammar::Block &message)
304308
luaJIT_profile_dumpstack(L, "pfFlz", len, &depth);
305309
#endif /* LUAJIT */
306310

311+
std::size_t hash = std::hash<std::string>{}(code);
312+
std::ofstream out("/tmp/corpus/" + std::to_string(hash) + ".lua");
313+
out << code;
314+
out.close();
315+
307316
if (luaL_loadbuffer(L, code.c_str(), code.size(), "fuzz") != LUA_OK) {
308317
report_error(L, "luaL_loadbuffer()");
309318
goto end;

0 commit comments

Comments
 (0)