<!DOCTYPE html>
<html data-lt-installed="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body style="padding-bottom: 1px;">
<p>Hi, Sergey!</p>
<p>Updated and force-pushed.</p>
<p>Sergey<br>
</p>
<div class="moz-cite-prefix">On 05.03.2025 13:57, Sergey Kaplun
wrote:<br>
</div>
<blockquote type="cite" cite="mid:Z8guGWHLs6jPHS3T@root">
<pre wrap="" class="moz-quote-pre">Hi, Sergey!
See my answer below.
On 24.02.25, Sergey Bronnikov wrote:
</pre>
<blockquote type="cite">
<pre wrap="" class="moz-quote-pre">Hi, Sergey,
thanks for review!
</pre>
</blockquote>
<pre wrap="" class="moz-quote-pre">
<snipped>
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="" class="moz-quote-pre">---
+
+ local default_output_file = 'memprof.bin'
+ os.remove(default_output_file)
+
+ local _, _ = misc.memprof.start()
</pre>
</blockquote>
<pre wrap="" class="moz-quote-pre">Minor: Do we want to check that the profiler starts successfully?
I suppose we should, since this is the expected behaviour for this
feature. In case the profiler is not started (old behaviour) we would
get an error from the branch below: profiler not running. This isn't a
verbose definition of what goes wrong.
</pre>
</blockquote>
<pre wrap="" class="moz-quote-pre">
I don't get why we should check that profiler is started in a test for
default output file.
</pre>
</blockquote>
<pre wrap="" class="moz-quote-pre">
If the `memprof.start()` call will fail in the test (for any reason),
the next call of `memprof.stop()` will return `false, "profiler is not
running"`. So, when debugging the test, we have no clue about the reason
for the not-started profiler, which is not very convenient.</pre>
</blockquote>
<p>The patch below handles error from memprof start and stop:</p>
<p>diff --git
a/test/tarantool-tests/profilers/misclib-memprof-lapi-default-file.test.lua
b/test/tarantool-tests/profilers/misclib-memprof-lapi-default-file.test.lua<br>
index ae8a73c9..55b5c60b 100644<br>
---
a/test/tarantool-tests/profilers/misclib-memprof-lapi-default-file.test.lua<br>
+++
b/test/tarantool-tests/profilers/misclib-memprof-lapi-default-file.test.lua<br>
@@ -16,21 +16,26 @@ <a class="moz-txt-link-freetext" href="test:test('default-output-file">test:test('default-output-file</a>',
function(subtest)<br>
local default_output_file = 'memprof.bin'<br>
os.remove(default_output_file)<br>
<br>
- local _, _ = misc.memprof.start()<br>
-<br>
- local res, err = misc.memprof.stop()<br>
+ local res, err = misc.memprof.start()<br>
+ -- Want to cleanup carefully if something went wrong.<br>
+ if not res then<br>
+ <a class="moz-txt-link-freetext" href="test:fail('sysprof">test:fail('sysprof</a> was not started: ' .. err)<br>
+ os.remove(default_output_file)<br>
+ end<br>
<br>
+ res, err = misc.memprof.stop()<br>
-- Want to cleanup carefully if something went wrong.<br>
if not res then<br>
+ <a class="moz-txt-link-freetext" href="test:fail('sysprof">test:fail('sysprof</a> was not started: ' .. err)<br>
os.remove(default_output_file)<br>
- error(err)<br>
end<br>
<br>
+<br>
local profile_buf = tools.read_file(default_output_file)<br>
<a class="moz-txt-link-freetext" href="subtest:ok(profile_buf">subtest:ok(profile_buf</a> ~= nil and #profile_buf ~= 0,<br>
'default output file is not empty')<br>
<br>
- -- We don't need it any more.<br>
+ -- We don't need it anymore.<br>
os.remove(default_output_file)<br>
end)<br>
<br>
<br>
</p>
<blockquote type="cite" cite="mid:Z8guGWHLs6jPHS3T@root">
<pre wrap="" class="moz-quote-pre">
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="" class="moz-quote-pre">I suppose we may use `goto` here like the following:
| local res, err = misc.memprof.start()
| -- Should start successfully.
| if not res then
| goto err_handling
| end
|
| res, err = misc.memprof.stop()
|
| ::err_handling::
| -- Want to cleanup carefully if something went wrong.
| if not res then
</pre>
<blockquote type="cite">
<pre wrap="" class="moz-quote-pre">+
+ local res, err = misc.memprof.stop()
+
+ -- Want to cleanup carefully if something went wrong.
+ if not res then
+ os.remove(default_output_file)
+ error(err)
+ end
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap="" class="moz-quote-pre">
<snipped>
</pre>
</blockquote>
</body>
<lt-container></lt-container>
</html>