forked from LuaJIT/LuaJIT
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
memprof: set default path to profiling output file
sysprof has an optional parameter `path`, that set a path to profiling output file, by default the path is `sysprof.bin`. `misc.memprof.start()` requires to set a path to profiling output file. The patch fixes this inconsistency by introducing a default path to memprof profiling output file - `memprof.bin`.
- Loading branch information
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
test/tarantool-tests/profilers/misclib-memprof-lapi-default-file.test.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
local tap = require("tap") | ||
local test = tap.test("misc-memprof-lapi-default-file"):skipcond({ | ||
["Memprof is implemented for x86_64 only"] = jit.arch ~= "x86" and | ||
jit.arch ~= "x64", | ||
["Memprof is disabled"] = os.getenv('LUAJIT_DISABLE_MEMPROF'), | ||
}) | ||
|
||
test:plan(1) | ||
|
||
local tools = require "utils.tools" | ||
|
||
test:test("default-output-file", function(subtest) | ||
|
||
subtest:plan(1) | ||
|
||
local def_output_file = 'memprof.bin' | ||
os.remove(def_output_file) | ||
|
||
local res, err = misc.memprof.start() | ||
-- Should start successfully. | ||
assert(res, err) | ||
|
||
res, err = misc.memprof.stop() | ||
-- Should stop successfully. | ||
assert(res, err) | ||
|
||
-- Want to cleanup carefully if something went wrong. | ||
if not res then | ||
os.remove(def_output_file) | ||
error(err) | ||
end | ||
|
||
local profile_buf = tools.read_file(def_output_file) | ||
subtest:ok(profile_buf ~= nil and #profile_buf ~= 0, | ||
'default output file is not empty') | ||
|
||
-- We don't need it any more. | ||
os.remove(def_output_file) | ||
end) | ||
|
||
test:done(true) |