test-journal.c revision 510b857f7d1e7e8d38912890536342dd5dd647dd
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2011 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 <unistd.h>
#include <systemd/sd-journal.h>
#include "log.h"
#include "journal-file.h"
#include "journal-authenticate.h"
#include "journal-vacuum.h"
static bool arg_keep = false;
static void test_non_empty(void) {
JournalFile *f;
Object *o;
uint64_t p;
char t[] = "/tmp/journal-XXXXXX";
assert_se(journal_file_open("test.journal", O_RDWR|O_CREAT, 0666, true, true, NULL, NULL, NULL, &f) == 0);
#ifdef HAVE_GCRYPT
#endif
journal_file_rotate(&f, true, true);
journal_file_rotate(&f, true, true);
log_info("Done...");
if (arg_keep)
log_info("Not removing %s", t);
else {
assert_se(rm_rf_dangerous(t, false, true, false) >= 0);
}
puts("------------------------------------------------------------");
}
static void test_empty(void) {
char t[] = "/tmp/journal-XXXXXX";
assert_se(journal_file_open("test.journal", O_RDWR|O_CREAT, 0666, false, false, NULL, NULL, NULL, &f1) == 0);
assert_se(journal_file_open("test-compress.journal", O_RDWR|O_CREAT, 0666, true, false, NULL, NULL, NULL, &f2) == 0);
assert_se(journal_file_open("test-seal.journal", O_RDWR|O_CREAT, 0666, false, true, NULL, NULL, NULL, &f3) == 0);
assert_se(journal_file_open("test-seal-compress.journal", O_RDWR|O_CREAT, 0666, true, true, NULL, NULL, NULL, &f4) == 0);
puts("");
puts("");
puts("");
puts("");
log_info("Done...");
if (arg_keep)
log_info("Not removing %s", t);
else {
assert_se(rm_rf_dangerous(t, false, true, false) >= 0);
}
}
/* journal_file_open requires a valid machine id */
return EXIT_TEST_SKIP;
test_empty();
return 0;
}