Skip to content

Commit

Permalink
test/fuzz: enable sysprof
Browse files Browse the repository at this point in the history
Follows up tarantool#8594

NO_CHANGELOG=testing
NO_DOC=testing
NO_TEST=testing
  • Loading branch information
ligurio committed Nov 8, 2023
1 parent 45f9759 commit 70d6841
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/fuzz/luaL_loadbuffer/luaL_loadbuffer_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ DEFINE_PROTO_FUZZER(const lua_grammar::Block &message)
if (!L)
return;

struct luam_Sysprof_Options opt = {};
opt.mode = LUAM_SYSPROF_DEFAULT;
opt.interval = 25;

std::string code = luajit_fuzzer::MainBlockToString(message);

if (::getenv("LPM_DUMP_NATIVE_INPUT") && code.size() != 0) {
Expand All @@ -133,6 +137,10 @@ DEFINE_PROTO_FUZZER(const lua_grammar::Block &message)
goto end;
}

/* Profiler staring. */
int status = luaM_sysprof_start(L, &opt);
assert(status == PROFILE_SUCCESS);

/*
* Using lua_pcall (protected call) to catch errors due to
* wrong semantics of some generated code chunks.
Expand All @@ -143,6 +151,10 @@ DEFINE_PROTO_FUZZER(const lua_grammar::Block &message)
if (lua_pcall(L, 0, 0, 0) != LUA_OK)
report_error(L, "lua_pcall()");

/* Profiler stopping. */
status = luaM_sysprof_stop(L);
assert(status == PROFILE_SUCCESS);

end:
metrics.total_num++;
collect_lj_metrics(&metrics, L);
Expand Down

0 comments on commit 70d6841

Please sign in to comment.