Skip to content

Commit

Permalink
Add memory leak detection during server process execution
Browse files Browse the repository at this point in the history
Memory leak detection may occur when working with the server:

    g.test_foo = function()
        ...
        g.server:exec(function()
            -- there is an error from LeakSanitizer in `stderr` here
        end)
        g.server:exec(function()
            -- server is alive
        end)
        t.assert(true)
    end)

    g.after_all(function()
        g.server:drop() -- `test_foo` has passed
    end)

We have added a check for the `LeakSanitizer` substring in `stderr` of
the server process. If it's found, an error will be thrown and test will
fail.

Closes #349
  • Loading branch information
Oleg Chaplashkin committed Mar 19, 2024
1 parent f8a1c10 commit db20d97
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Add logging to unified file (gh-324).
- Add memory leak detection during server process execution (gh-349).

## 1.0.1

Expand Down
11 changes: 11 additions & 0 deletions luatest/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,17 @@ function Server:stop()
)
)
end
if self.process.output_beautifier.stderr:find('LeakSanitizer') then
error(
('Memory leak during process execution (alias: %s, workdir: %s, pid: %s)\n%s')
:format(
self.alias,
fio.basename(self.workdir),
self.process.pid,
self.process.output_beautifier.stderr
)
)
end
log.debug('Killed server process PID ' .. self.process.pid)
self.process = nil
end
Expand Down

0 comments on commit db20d97

Please sign in to comment.