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

tests: Use seek_realtime when saving journal data #1284

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/tests/dbus-tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import atexit
import traceback
import yaml
import gzip
from datetime import datetime


Expand Down Expand Up @@ -446,6 +447,12 @@ def parse_args():
except Exception as e:
print('Failed to save journal: %s' % str(e), file=outfile)

# compress the flight record log
with open(udiskstestcase.FLIGHT_RECORD_FILE, "rb") as f_in:
with gzip.open(udiskstestcase.FLIGHT_RECORD_FILE + ".gz", "wb") as f_out:
shutil.copyfileobj(f_in, f_out)
os.unlink(udiskstestcase.FLIGHT_RECORD_FILE)

if result.wasSuccessful():
sys.exit(0)
else:
Expand Down
9 changes: 4 additions & 5 deletions src/tests/dbus-tests/udiskstestcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,20 +571,19 @@ def __init__(self, desc, store):
self._stopped = None

def _start(self):
self._started = monotonic()
self._started = time.time()

def _stop(self):
self._stopped = monotonic()
self._stopped = time.time()

def _save(self):
j = journal.Reader(converters={"MESSAGE": lambda x: x.decode(errors="replace")})
j.this_boot()
j.seek_monotonic(self._started)
j.seek_realtime(self._started)
journal_data = ""

entry = j.get_next()
# entry["__MONOTONIC_TIMESTAMP"] is a tuple of (datetime.timedelta, boot_id)
while entry and entry["__MONOTONIC_TIMESTAMP"][0].seconds <= int(self._stopped):
while entry and int(entry["__REALTIME_TIMESTAMP"].timestamp()) <= int(self._stopped):
if "_COMM" in entry and "_PID" in entry:
source = "%s[%d]" % (entry["_COMM"], entry["_PID"])
else:
Expand Down
Loading