test-journal-verify.c revision cf0fbc49e67b55f8d346fc94de28c90113505297
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2012 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include "fd-util.h"
#include "journal-file.h"
#include "journal-verify.h"
#include "log.h"
#include "rm-rf.h"
#include "terminal-util.h"
#include "util.h"
#define N_ENTRIES 6000
#define RANDOM_RANGE 77
uint8_t b;
ssize_t r;
int fd;
assert_se(r == 1);
b ^= 1 << (p % 8);
assert_se(r == 1);
safe_close(fd);
}
JournalFile *f;
int r;
if (r < 0)
return r;
return r;
}
char t[] = "/tmp/journal-XXXXXX";
unsigned n;
JournalFile *f;
char a[FORMAT_TIMESTAMP_MAX];
char b[FORMAT_TIMESTAMP_MAX];
char c[FORMAT_TIMESPAN_MAX];
uint64_t p;
/* journal_file_open requires a valid machine id */
return EXIT_TEST_SKIP;
log_info("Generating...");
assert_se(journal_file_open("test.journal", O_RDWR|O_CREAT, 0666, true, !!verification_key, NULL, NULL, NULL, &f) == 0);
for (n = 0; n < N_ENTRIES; n++) {
struct dual_timestamp ts;
char *test;
}
log_info("Verifying...");
assert_se(journal_file_open("test.journal", O_RDONLY, 0666, true, !!verification_key, NULL, NULL, NULL, &f) == 0);
/* journal_file_print_header(f); */
log_info("=> Validated from %s to %s, %s missing",
format_timestamp(a, sizeof(a), from),
format_timestamp(b, sizeof(b), to),
if (verification_key) {
log_info("Toggling bits...");
bit_toggle("test.journal", p);
log_notice(ANSI_HIGHLIGHT_RED ">>>> %"PRIu64" (bit %"PRIu64") can be toggled without detection." ANSI_NORMAL, p / 8, p % 8);
bit_toggle("test.journal", p);
}
}
log_info("Exiting...");
return 0;
}