Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gzip support #171

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

ecalifornica
Copy link

*Issue number of the reported bug or feature request: #168 *

Describe your changes
Add check for core dump file ending in .gz. If so, decompress to temporary file and run analyzer on temporary file.

Testing performed
Added a unit test following the pattern of current tests. It mocks calls to gzip and tempfile, asserts that the analyzer was called with the correct path. It does not test for any failure modes, and really only tests the mocks. Happy to add more tests if requested.

Additional context

Signed-off-by: Robert Queenin <2177841+ecalifornica@users.noreply.github.com>
Signed-off-by: Robert Queenin <2177841+ecalifornica@users.noreply.github.com>
Signed-off-by: Robert Queenin <2177841+ecalifornica@users.noreply.github.com>
@@ -319,6 +321,19 @@ def process_core(parser: argparse.ArgumentParser, args: argparse.Namespace) -> N
if not corefile.exists():
parser.error(f"Core {corefile} does not exist")

temp_file = None
if corefile.suffix == ".gz":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can improve this to not rely on the filename by checking the gz magic number: 1f 8b from the header

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In making this change I hit a small snag: other tests mock the pathlib.Path().exists() check, causing them to fail when attempting to open the non-existent corefile in order to check the header. What do you think the correct approach would be here?

  • Update those tests to expect the read error?
  • Create a corefile fixture?
  • Something else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this code to a function and mock/patch it in those tests to return None or whatever indicates that this operation doesn't make sense

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I should've done this to begin with. Thanks!

@pablogsal
Copy link
Member

Thanks a lot for the PR! I will try to review it this week :)

Signed-off-by: Robert Queenin <2177841+ecalifornica@users.noreply.github.com>
Signed-off-by: Robert Queenin <2177841+ecalifornica@users.noreply.github.com>
Signed-off-by: Robert Queenin <2177841+ecalifornica@users.noreply.github.com>
@pablogsal
Copy link
Member

pablogsal commented May 13, 2024

Great job! We are almost there

You need a news entry - an .rst file in the news folder (the other error in the Lint step you can ignore as we are fixing this in other PR).

Signed-off-by: Robert Queenin <2177841+ecalifornica@users.noreply.github.com>
@ecalifornica
Copy link
Author

Is this the correct format for the news entry?

Signed-off-by: Robert Queenin <2177841+ecalifornica@users.noreply.github.com>
@ecalifornica
Copy link
Author

Thanks for running the checks yesterday @godlygeek. I've picked up your fix for the Alpine test failure and removed the code that was causing the Python3.7 failure. Hopefully those changes should cause this PR to go green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants