diff options
Diffstat (limited to 'src/journal')
-rw-r--r-- | src/journal/test-compress-benchmark.c | 18 | ||||
-rw-r--r-- | src/journal/test-compress.c | 4 | ||||
-rw-r--r-- | src/journal/test-journal-flush.c | 7 | ||||
-rw-r--r-- | src/journal/test-journal-interleaving.c | 34 | ||||
-rw-r--r-- | src/journal/test-journal-stream.c | 3 |
5 files changed, 34 insertions, 32 deletions
diff --git a/src/journal/test-compress-benchmark.c b/src/journal/test-compress-benchmark.c index b3bc3ec2fe..c8e5b76c6c 100644 --- a/src/journal/test-compress-benchmark.c +++ b/src/journal/test-compress-benchmark.c @@ -32,7 +32,7 @@ static char* make_buf(size_t count) { size_t i; buf = malloc(count); - assert(buf); + assert_se(buf); for (i = 0; i < count; i++) buf[i] = 'a' + i % ('z' - 'a' + 1); @@ -52,7 +52,7 @@ static void test_compress_decompress(const char* label, text = make_buf(MAX_SIZE); buf = calloc(MAX_SIZE + 1, 1); - assert(text && buf); + assert_se(text && buf); n = now(CLOCK_MONOTONIC); @@ -62,24 +62,24 @@ static void test_compress_decompress(const char* label, r = compress(text, i, buf, &j); /* assume compression must be successful except for small inputs */ - assert(r == 0 || (i < 2048 && r == -ENOBUFS)); + assert_se(r == 0 || (i < 2048 && r == -ENOBUFS)); /* check for overwrites */ - assert(buf[i] == 0); + assert_se(buf[i] == 0); if (r != 0) { skipped += i; continue; } - assert(j > 0); + assert_se(j > 0); if (j >= i) log_error("%s \"compressed\" %zu -> %zu", label, i, j); r = decompress(buf, j, &buf2, &buf2_allocated, &k, 0); - assert(r == 0); - assert(buf2_allocated >= k); - assert(k == i); + assert_se(r == 0); + assert_se(buf2_allocated >= k); + assert_se(k == i); - assert(memcmp(text, buf2, i) == 0); + assert_se(memcmp(text, buf2, i) == 0); total += i; compressed += j; diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c index 97577e827c..ae41c0c4c7 100644 --- a/src/journal/test-compress.c +++ b/src/journal/test-compress.c @@ -175,7 +175,7 @@ static void test_compress_stream(int compression, assert_se(lseek(dst, 0, SEEK_SET) == 0); r = decompress(dst, dst2, st.st_size); - assert(r == 0); + assert_se(r == 0); assert_se(asprintf(&cmd2, "diff %s %s", srcfile, pattern2) > 0); assert_se(system(cmd2) == 0); @@ -189,7 +189,7 @@ static void test_compress_stream(int compression, assert_se(lseek(dst, 0, SEEK_SET) == 0); assert_se(lseek(dst2, 0, SEEK_SET) == 0); r = decompress(dst, dst2, st.st_size - 1); - assert(r == -EFBIG); + assert_se(r == -EFBIG); assert_se(unlink(pattern) == 0); assert_se(unlink(pattern2) == 0); diff --git a/src/journal/test-journal-flush.c b/src/journal/test-journal-flush.c index 40ede4a926..914ca0b4d1 100644 --- a/src/journal/test-journal-flush.c +++ b/src/journal/test-journal-flush.c @@ -22,6 +22,7 @@ #include <fcntl.h> #include "sd-journal.h" +#include "macro.h" #include "journal-file.h" #include "journal-internal.h" @@ -49,13 +50,13 @@ int main(int argc, char *argv[]) { JournalFile *f; f = j->current_file; - assert(f && f->current_offset > 0); + assert_se(f && f->current_offset > 0); r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &o); - assert(r >= 0); + assert_se(r >= 0); r = journal_file_copy_entry(f, new_journal, o, f->current_offset, NULL, NULL, NULL); - assert(r >= 0); + assert_se(r >= 0); n++; if (n > 10000) diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c index 23a26c43f6..3c706018e9 100644 --- a/src/journal/test-journal-interleaving.c +++ b/src/journal/test-journal-interleaving.c @@ -212,43 +212,43 @@ static void test_sequence_numbers(void) { append_number(one, 1, &seqnum); printf("seqnum=%"PRIu64"\n", seqnum); - assert(seqnum == 1); + assert_se(seqnum == 1); append_number(one, 2, &seqnum); printf("seqnum=%"PRIu64"\n", seqnum); - assert(seqnum == 2); + assert_se(seqnum == 2); - assert(one->header->state == STATE_ONLINE); - assert(!sd_id128_equal(one->header->file_id, one->header->machine_id)); - assert(!sd_id128_equal(one->header->file_id, one->header->boot_id)); - assert(sd_id128_equal(one->header->file_id, one->header->seqnum_id)); + assert_se(one->header->state == STATE_ONLINE); + assert_se(!sd_id128_equal(one->header->file_id, one->header->machine_id)); + assert_se(!sd_id128_equal(one->header->file_id, one->header->boot_id)); + assert_se(sd_id128_equal(one->header->file_id, one->header->seqnum_id)); memcpy(&seqnum_id, &one->header->seqnum_id, sizeof(sd_id128_t)); assert_se(journal_file_open("two.journal", O_RDWR|O_CREAT, 0644, true, false, NULL, NULL, one, &two) == 0); - assert(two->header->state == STATE_ONLINE); - assert(!sd_id128_equal(two->header->file_id, one->header->file_id)); - assert(sd_id128_equal(one->header->machine_id, one->header->machine_id)); - assert(sd_id128_equal(one->header->boot_id, one->header->boot_id)); - assert(sd_id128_equal(one->header->seqnum_id, one->header->seqnum_id)); + assert_se(two->header->state == STATE_ONLINE); + assert_se(!sd_id128_equal(two->header->file_id, one->header->file_id)); + assert_se(sd_id128_equal(one->header->machine_id, one->header->machine_id)); + assert_se(sd_id128_equal(one->header->boot_id, one->header->boot_id)); + assert_se(sd_id128_equal(one->header->seqnum_id, one->header->seqnum_id)); append_number(two, 3, &seqnum); printf("seqnum=%"PRIu64"\n", seqnum); - assert(seqnum == 3); + assert_se(seqnum == 3); append_number(two, 4, &seqnum); printf("seqnum=%"PRIu64"\n", seqnum); - assert(seqnum == 4); + assert_se(seqnum == 4); test_close(two); append_number(one, 5, &seqnum); printf("seqnum=%"PRIu64"\n", seqnum); - assert(seqnum == 5); + assert_se(seqnum == 5); append_number(one, 6, &seqnum); printf("seqnum=%"PRIu64"\n", seqnum); - assert(seqnum == 6); + assert_se(seqnum == 6); test_close(one); @@ -258,11 +258,11 @@ static void test_sequence_numbers(void) { assert_se(journal_file_open("two.journal", O_RDWR, 0, true, false, NULL, NULL, NULL, &two) == 0); - assert(sd_id128_equal(two->header->seqnum_id, seqnum_id)); + assert_se(sd_id128_equal(two->header->seqnum_id, seqnum_id)); append_number(two, 7, &seqnum); printf("seqnum=%"PRIu64"\n", seqnum); - assert(seqnum == 5); + assert_se(seqnum == 5); /* So..., here we have the same seqnum in two files with the * same seqnum_id. */ diff --git a/src/journal/test-journal-stream.c b/src/journal/test-journal-stream.c index 8ccd813445..3996e778e6 100644 --- a/src/journal/test-journal-stream.c +++ b/src/journal/test-journal-stream.c @@ -28,13 +28,14 @@ #include "journal-internal.h" #include "util.h" #include "log.h" +#include "macro.h" #define N_ENTRIES 200 static void verify_contents(sd_journal *j, unsigned skip) { unsigned i; - assert(j); + assert_se(j); i = 0; SD_JOURNAL_FOREACH(j) { |