test-journal: move tests to /var/tmp/ and set FS_NOCOW_FL

The journal files might not be tiny hence let's write them to /var/tmp/
instead of /tmp. Also, let's turn on NOCOW on the files, as these tests
might apparently be slow on btrfs.

Fixes: #12210
This commit is contained in:
Lennart Poettering 2019-04-04 10:04:26 +02:00
parent 6e79d2b5a4
commit 949082ac21
6 changed files with 42 additions and 18 deletions

View File

@ -6,6 +6,7 @@
#include "sd-journal.h"
#include "alloc-util.h"
#include "chattr-util.h"
#include "journal-file.h"
#include "journal-internal.h"
#include "macro.h"
@ -20,6 +21,8 @@ int main(int argc, char *argv[]) {
int r;
assert_se(mkdtemp(dn));
(void) chattr_path(dn, FS_NOCOW_FL, FS_NOCOW_FL, NULL);
fn = strappend(dn, "/test.journal");
r = journal_file_open(-1, fn, O_CREAT|O_RDWR, 0644, false, 0, false, NULL, NULL, NULL, NULL, &new_journal);

View File

@ -2,6 +2,7 @@
#include "sd-journal.h"
#include "chattr-util.h"
#include "log.h"
#include "parse-util.h"
#include "rm-rf.h"
@ -11,7 +12,7 @@
int main(int argc, char *argv[]) {
sd_journal *j;
int r, i, I = 100;
char t[] = "/tmp/journal-stream-XXXXXX";
char t[] = "/var/tmp/journal-stream-XXXXXX";
test_setup_logging(LOG_DEBUG);
@ -24,6 +25,7 @@ int main(int argc, char *argv[]) {
log_info("Running %d loops", I);
assert_se(mkdtemp(t));
(void) chattr_path(t, FS_NOCOW_FL, FS_NOCOW_FL, NULL);
for (i = 0; i < I; i++) {
r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY);

View File

@ -6,6 +6,7 @@
#include "sd-journal.h"
#include "alloc-util.h"
#include "chattr-util.h"
#include "io-util.h"
#include "journal-file.h"
#include "journal-vacuum.h"
@ -130,13 +131,21 @@ static void setup_interleaved(void) {
test_close(two);
}
static void mkdtemp_chdir_chattr(char *path) {
assert_se(mkdtemp(path));
assert_se(chdir(path) >= 0);
/* Speed up things a bit on btrfs, ensuring that CoW is turned off for all files created in our
* directory during the test run */
(void) chattr_path(path, FS_NOCOW_FL, FS_NOCOW_FL, NULL);
}
static void test_skip(void (*setup)(void)) {
char t[] = "/tmp/journal-skip-XXXXXX";
char t[] = "/var/tmp/journal-skip-XXXXXX";
sd_journal *j;
int r;
assert_se(mkdtemp(t));
assert_se(chdir(t) >= 0);
mkdtemp_chdir_chattr(t);
setup();
@ -189,13 +198,12 @@ static void test_skip(void (*setup)(void)) {
static void test_sequence_numbers(void) {
char t[] = "/tmp/journal-seq-XXXXXX";
char t[] = "/var/tmp/journal-seq-XXXXXX";
JournalFile *one, *two;
uint64_t seqnum = 0;
sd_id128_t seqnum_id;
assert_se(mkdtemp(t));
assert_se(chdir(t) >= 0);
mkdtemp_chdir_chattr(t);
assert_se(journal_file_open(-1, "one.journal", O_RDWR|O_CREAT, 0644,
true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &one) == 0);

View File

@ -6,6 +6,7 @@
#include "sd-journal.h"
#include "alloc-util.h"
#include "chattr-util.h"
#include "journal-file.h"
#include "journal-internal.h"
#include "log.h"
@ -59,7 +60,7 @@ static void verify_contents(sd_journal *j, unsigned skip) {
int main(int argc, char *argv[]) {
JournalFile *one, *two, *three;
char t[] = "/tmp/journal-stream-XXXXXX";
char t[] = "/var/tmp/journal-stream-XXXXXX";
unsigned i;
_cleanup_(sd_journal_closep) sd_journal *j = NULL;
char *z;
@ -75,6 +76,7 @@ int main(int argc, char *argv[]) {
assert_se(mkdtemp(t));
assert_se(chdir(t) >= 0);
(void) chattr_path(t, FS_NOCOW_FL, FS_NOCOW_FL, NULL);
assert_se(journal_file_open(-1, "one.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &one) == 0);
assert_se(journal_file_open(-1, "two.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &two) == 0);

View File

@ -4,6 +4,7 @@
#include <stdio.h>
#include <unistd.h>
#include "chattr-util.h"
#include "fd-util.h"
#include "io-util.h"
#include "journal-file.h"
@ -51,7 +52,7 @@ static int raw_verify(const char *fn, const char *verification_key) {
}
int main(int argc, char *argv[]) {
char t[] = "/tmp/journal-XXXXXX";
char t[] = "/var/tmp/journal-XXXXXX";
unsigned n;
JournalFile *f;
const char *verification_key = argv[1];
@ -70,6 +71,7 @@ int main(int argc, char *argv[]) {
assert_se(mkdtemp(t));
assert_se(chdir(t) >= 0);
(void) chattr_path(t, FS_NOCOW_FL, FS_NOCOW_FL, NULL);
log_info("Generating...");

View File

@ -3,6 +3,7 @@
#include <fcntl.h>
#include <unistd.h>
#include "chattr-util.h"
#include "io-util.h"
#include "journal-authenticate.h"
#include "journal-file.h"
@ -13,6 +14,15 @@
static bool arg_keep = false;
static void mkdtemp_chdir_chattr(char *path) {
assert_se(mkdtemp(path));
assert_se(chdir(path) >= 0);
/* Speed up things a bit on btrfs, ensuring that CoW is turned off for all files created in our
* directory during the test run */
(void) chattr_path(path, FS_NOCOW_FL, FS_NOCOW_FL, NULL);
}
static void test_non_empty(void) {
dual_timestamp ts;
JournalFile *f;
@ -21,12 +31,11 @@ static void test_non_empty(void) {
Object *o;
uint64_t p;
sd_id128_t fake_boot_id;
char t[] = "/tmp/journal-XXXXXX";
char t[] = "/var/tmp/journal-XXXXXX";
test_setup_logging(LOG_DEBUG);
assert_se(mkdtemp(t));
assert_se(chdir(t) >= 0);
mkdtemp_chdir_chattr(t);
assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, true, NULL, NULL, NULL, NULL, &f) == 0);
@ -109,12 +118,11 @@ static void test_non_empty(void) {
static void test_empty(void) {
JournalFile *f1, *f2, *f3, *f4;
char t[] = "/tmp/journal-XXXXXX";
char t[] = "/var/tmp/journal-XXXXXX";
test_setup_logging(LOG_DEBUG);
assert_se(mkdtemp(t));
assert_se(chdir(t) >= 0);
mkdtemp_chdir_chattr(t);
assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, false, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &f1) == 0);
@ -156,7 +164,7 @@ static bool check_compressed(uint64_t compress_threshold, uint64_t data_size) {
struct iovec iovec;
Object *o;
uint64_t p;
char t[] = "/tmp/journal-XXXXXX";
char t[] = "/var/tmp/journal-XXXXXX";
char data[2048] = {0};
bool is_compressed;
int r;
@ -165,8 +173,7 @@ static bool check_compressed(uint64_t compress_threshold, uint64_t data_size) {
test_setup_logging(LOG_DEBUG);
assert_se(mkdtemp(t));
assert_se(chdir(t) >= 0);
mkdtemp_chdir_chattr(t);
assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, compress_threshold, true, NULL, NULL, NULL, NULL, &f) == 0);