Skip to content

Commit

Permalink
Add test for systemd journal with compact mode and ZSTD
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael K. Ashburn committed Sep 29, 2023
1 parent 94e7ed3 commit 368cb45
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Binary file added test_data/systemd/journal/user-1000.journal
Binary file not shown.
29 changes: 29 additions & 0 deletions tests/parsers/systemd_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,35 @@ def testParseLZ4(self):
event_data = storage_writer.GetAttributeContainerByIndex('event_data', 84)
self.CheckEventData(event_data, expected_event_values)

def testParseCompactZSTD(self):
"""Tests the Parse function on a journal with compact mode and ZSTD."""
parser = systemd_journal.SystemdJournalParser()
storage_writer = self._ParseFile([
'systemd', 'journal', 'user-1000.journal'], parser)

number_of_event_data = storage_writer.GetNumberOfAttributeContainers(
'event_data')
self.assertEqual(number_of_event_data, 1)

number_of_warnings = storage_writer.GetNumberOfAttributeContainers(
'extraction_warning')
self.assertEqual(number_of_warnings, 0)

number_of_warnings = storage_writer.GetNumberOfAttributeContainers(
'recovery_warning')
self.assertEqual(number_of_warnings, 0)

expected_event_values = {
'body': 'Some large string: ' + 'A'*512,
'data_type': 'systemd:journal',
'hostname': 'DESKTOP-QCDE2BT',
'pid': '197',
'reporter': 'testapp',
'written_time': '2023-09-26T07:42:46.445209+00:00'}

event_data = storage_writer.GetAttributeContainerByIndex('event_data', 0)
self.CheckEventData(event_data, expected_event_values)

def testParseDirty(self):
"""Tests the Parse function on a 'dirty' journal file."""
parser = systemd_journal.SystemdJournalParser()
Expand Down

0 comments on commit 368cb45

Please sign in to comment.