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.
Reported by Guilherme Batalheiro. (cherry picked from commit fca6633)
- Loading branch information
Showing
4 changed files
with
44 additions
and
3 deletions.
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
25 changes: 25 additions & 0 deletions
25
test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples.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,25 @@ | ||
local tap = require('tap') | ||
local test = tap.test('lj-1304-close-profile-dump-with-0-samples'):skipcond({ | ||
['Test requires /proc filesystem'] = jit.os == 'OSX', | ||
}) | ||
local utils = require('utils') | ||
|
||
test:plan(1) | ||
|
||
local p_filename = '/tmp/profile' | ||
|
||
-- <makecmd> runs %testname%/script.lua by <LUAJIT_TEST_BINARY> | ||
-- with the given environment, launch options and CLI arguments. | ||
local script = utils.exec.makecmd(arg) | ||
-- Execute a Lua script with start and stop LuaJIT profiler, | ||
-- it is expected no samples found by profiler. The script's | ||
-- output is suppressed, it is not interested. | ||
local _ = script(p_filename) | ||
|
||
local p_content = io.open(p_filename):read('a*') | ||
test:is(utils.tools.trim(p_content), '[No samples collected]', 'profile dump has no samples') | ||
|
||
-- Teardown. | ||
os.remove(p_filename) | ||
|
||
test:done(true) |
14 changes: 14 additions & 0 deletions
14
test/tarantool-tests/lj-1304-close-profile-dump-with-0-samples/script.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,14 @@ | ||
local p_options = 'ri1' | ||
local p_filename = assert(arg[1], 'filename argument is missing') | ||
|
||
require('jit.p').start(p_options, p_filename) | ||
|
||
-- No code to generate profiling samples. | ||
|
||
-- Stop profiler to execute `jit/p.lua:prof_fmt()`. With zero | ||
-- samples it triggers early return without closing the file. | ||
require('jit.p').stop() | ||
|
||
-- Make sure LuaJIT profiler is close a file handle. | ||
local ls_output = io.popen('ls -l /proc/$$/fd'):read('a*') | ||
assert(ls_output:find(p_filename) == nil, 'file is open') |
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