2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2013-08-02 17:01:10 +02:00
|
|
|
|
2015-10-25 13:14:12 +01:00
|
|
|
#include "sd-journal.h"
|
2013-08-02 17:01:10 +02:00
|
|
|
|
2019-04-04 10:04:26 +02:00
|
|
|
#include "chattr-util.h"
|
2013-08-02 17:01:10 +02:00
|
|
|
#include "log.h"
|
2015-10-26 16:18:16 +01:00
|
|
|
#include "parse-util.h"
|
2015-04-04 11:52:57 +02:00
|
|
|
#include "rm-rf.h"
|
2018-09-13 14:31:13 +02:00
|
|
|
#include "tests.h"
|
2015-10-25 13:14:12 +01:00
|
|
|
#include "util.h"
|
2013-08-02 17:01:10 +02:00
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
sd_journal *j;
|
|
|
|
int r, i, I = 100;
|
2019-04-04 10:04:26 +02:00
|
|
|
char t[] = "/var/tmp/journal-stream-XXXXXX";
|
2013-08-02 17:01:10 +02:00
|
|
|
|
2018-09-13 14:31:13 +02:00
|
|
|
test_setup_logging(LOG_DEBUG);
|
2013-08-02 17:01:10 +02:00
|
|
|
|
2014-09-19 01:43:04 +02:00
|
|
|
if (argc >= 2) {
|
|
|
|
r = safe_atoi(argv[1], &I);
|
|
|
|
if (r < 0)
|
|
|
|
log_info("Could not parse loop count argument. Using default.");
|
|
|
|
}
|
|
|
|
|
2013-08-02 17:01:10 +02:00
|
|
|
log_info("Running %d loops", I);
|
|
|
|
|
|
|
|
assert_se(mkdtemp(t));
|
2019-04-04 10:04:26 +02:00
|
|
|
(void) chattr_path(t, FS_NOCOW_FL, FS_NOCOW_FL, NULL);
|
2013-08-02 17:01:10 +02:00
|
|
|
|
|
|
|
for (i = 0; i < I; i++) {
|
|
|
|
r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY);
|
|
|
|
assert_se(r == 0);
|
|
|
|
|
|
|
|
sd_journal_close(j);
|
|
|
|
|
|
|
|
r = sd_journal_open_directory(&j, t, 0);
|
|
|
|
assert_se(r == 0);
|
|
|
|
|
|
|
|
sd_journal_close(j);
|
|
|
|
|
|
|
|
j = NULL;
|
|
|
|
r = sd_journal_open_directory(&j, t, SD_JOURNAL_LOCAL_ONLY);
|
|
|
|
assert_se(r == -EINVAL);
|
|
|
|
assert_se(j == NULL);
|
|
|
|
}
|
|
|
|
|
2015-04-04 11:52:57 +02:00
|
|
|
assert_se(rm_rf(t, REMOVE_ROOT|REMOVE_PHYSICAL) >= 0);
|
2013-08-02 17:01:10 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|