summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-06-17 20:37:19 +0200
committerLennart Poettering <lennart@poettering.net>2015-06-17 20:37:19 +0200
commit98d2a5341788b49e82d628dfdc2e241af6d70dcd (patch)
treec1dd128de56008f206ef47d846b6539df5f3d312 /src/journal
parent07d210255b629ea97f9dc77c0fadcbc1c02be12c (diff)
journal: ensure test-journal-stream doesn't get confused by crappy clocks
This ensures that we write strictly monotonic timestamps into the journal files, to ensure that we can properly interleave everything correctly. See #175 for details.
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/test-journal-stream.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/journal/test-journal-stream.c b/src/journal/test-journal-stream.c
index e1146c692d..b5ecf2f375 100644
--- a/src/journal/test-journal-stream.c
+++ b/src/journal/test-journal-stream.c
@@ -80,6 +80,7 @@ int main(int argc, char *argv[]) {
char *z;
const void *data;
size_t l;
+ dual_timestamp previous_ts = DUAL_TIMESTAMP_NULL;
/* journal_file_open requires a valid machine id */
if (access("/etc/machine-id", F_OK) != 0)
@@ -101,6 +102,14 @@ int main(int argc, char *argv[]) {
dual_timestamp_get(&ts);
+ if (ts.monotonic <= previous_ts.monotonic)
+ ts.monotonic = previous_ts.monotonic + 1;
+
+ if (ts.realtime <= previous_ts.realtime)
+ ts.realtime = previous_ts.realtime + 1;
+
+ previous_ts = ts;
+
assert_se(asprintf(&p, "NUMBER=%u", i) >= 0);
iovec[0].iov_base = p;
iovec[0].iov_len = strlen(p);