summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorRonny Chevalier <chevalier.ronny@gmail.com>2014-11-30 02:16:19 +0100
committerRonny Chevalier <chevalier.ronny@gmail.com>2014-11-30 02:35:52 +0100
commit787784c4c1b24a13207d18b415d60483cfbdeaa3 (patch)
tree66b49b1a8e589fb38aa34d0208e6bc6c0b1a69f2 /src/journal
parent30fbcf24460263961855e0ce4d8867fd2af3e149 (diff)
tests: use assert_se instead of assert
Otherwise they can be optimized away with -DNDEBUG
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/test-catalog.c16
-rw-r--r--src/journal/test-compress.c18
-rw-r--r--src/journal/test-journal-syslog.c6
-rw-r--r--src/journal/test-journal-verify.c6
-rw-r--r--src/journal/test-journal.c66
-rw-r--r--src/journal/test-mmap-cache.c22
6 files changed, 67 insertions, 67 deletions
diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c
index 5fe2f6a269..c605ee0e70 100644
--- a/src/journal/test-catalog.c
+++ b/src/journal/test-catalog.c
@@ -49,11 +49,11 @@ static void test_import(Hashmap *h, struct strbuf *sb,
_cleanup_close_ int fd;
fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
- assert(fd >= 0);
+ assert_se(fd >= 0);
assert_se(write(fd, contents, size) == size);
r = catalog_import_file(h, sb, name);
- assert(r == code);
+ assert_se(r == code);
unlink(name);
}
@@ -68,7 +68,7 @@ static void test_catalog_importing(void) {
#define BUF "xxx"
test_import(h, sb, BUF, sizeof(BUF), -EINVAL);
#undef BUF
- assert(hashmap_isempty(h));
+ assert_se(hashmap_isempty(h));
log_debug("----------------------------------------");
#define BUF \
@@ -89,7 +89,7 @@ static void test_catalog_importing(void) {
test_import(h, sb, BUF, sizeof(BUF), 0);
#undef BUF
- assert(hashmap_size(h) == 1);
+ assert_se(hashmap_size(h) == 1);
log_debug("----------------------------------------");
@@ -105,22 +105,22 @@ static void test_catalog_update(void) {
int r;
r = mkostemp_safe(name, O_RDWR|O_CLOEXEC);
- assert(r >= 0);
+ assert_se(r >= 0);
database = name;
/* Test what happens if there are no files. */
r = catalog_update(database, NULL, NULL);
- assert(r >= 0);
+ assert_se(r >= 0);
/* Test what happens if there are no files in the directory. */
r = catalog_update(database, NULL, no_catalog_dirs);
- assert(r >= 0);
+ assert_se(r >= 0);
/* Make sure that we at least have some files loaded or the
catalog_list below will fail. */
r = catalog_update(database, NULL, catalog_dirs);
- assert(r >= 0);
+ assert_se(r >= 0);
}
static void test_catalog_file_lang(void) {
diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c
index dbf09d97c3..97577e827c 100644
--- a/src/journal/test-compress.c
+++ b/src/journal/test-compress.c
@@ -64,28 +64,28 @@ static void test_compress_decompress(int compression,
r = compress(data, data_len, compressed, &csize);
if (r == -ENOBUFS) {
log_info_errno(r, "compression failed: %m");
- assert(may_fail);
+ assert_se(may_fail);
} else {
- assert(r == 0);
+ assert_se(r == 0);
r = decompress(compressed, csize,
(void **) &decompressed, &usize, &csize, 0);
- assert(r == 0);
+ assert_se(r == 0);
assert_se(decompressed);
assert_se(memcmp(decompressed, data, data_len) == 0);
}
r = decompress("garbage", 7,
(void **) &decompressed, &usize, &csize, 0);
- assert(r < 0);
+ assert_se(r < 0);
/* make sure to have the minimal lz4 compressed size */
r = decompress("00000000\1g", 9,
(void **) &decompressed, &usize, &csize, 0);
- assert(r < 0);
+ assert_se(r < 0);
r = decompress("\100000000g", 9,
(void **) &decompressed, &usize, &csize, 0);
- assert(r < 0);
+ assert_se(r < 0);
memzero(decompressed, usize);
}
@@ -109,10 +109,10 @@ static void test_decompress_startswith(int compression,
r = compress(data, data_len, compressed, &csize);
if (r == -ENOBUFS) {
log_info_errno(r, "compression failed: %m");
- assert(may_fail);
+ assert_se(may_fail);
return;
}
- assert(r == 0);
+ assert_se(r == 0);
assert_se(decompress_sw(compressed,
csize,
@@ -184,7 +184,7 @@ static void test_compress_stream(int compression,
assert_se(lseek(dst, 1, SEEK_SET) == 1);
r = decompress(dst, dst2, st.st_size);
- assert(r == -EBADMSG);
+ assert_se(r == -EBADMSG);
assert_se(lseek(dst, 0, SEEK_SET) == 0);
assert_se(lseek(dst2, 0, SEEK_SET) == 0);
diff --git a/src/journal/test-journal-syslog.c b/src/journal/test-journal-syslog.c
index c4d407148c..c99ca0654b 100644
--- a/src/journal/test-journal-syslog.c
+++ b/src/journal/test-journal-syslog.c
@@ -30,9 +30,9 @@ static void test_syslog_parse_identifier(const char* str,
ret2 = syslog_parse_identifier(&buf, &ident2, &pid2);
- assert(ret == ret2);
- assert(ident == ident2 || streq_ptr(ident, ident2));
- assert(pid == pid2 || streq_ptr(pid, pid2));
+ assert_se(ret == ret2);
+ assert_se(ident == ident2 || streq_ptr(ident, ident2));
+ assert_se(pid == pid2 || streq_ptr(pid, pid2));
}
int main(void) {
diff --git a/src/journal/test-journal-verify.c b/src/journal/test-journal-verify.c
index 3b181c6794..9da120c0bb 100644
--- a/src/journal/test-journal-verify.c
+++ b/src/journal/test-journal-verify.c
@@ -38,15 +38,15 @@ static void bit_toggle(const char *fn, uint64_t p) {
int fd;
fd = open(fn, O_RDWR|O_CLOEXEC);
- assert(fd >= 0);
+ assert_se(fd >= 0);
r = pread(fd, &b, 1, p/8);
- assert(r == 1);
+ assert_se(r == 1);
b ^= 1 << (p % 8);
r = pwrite(fd, &b, 1, p/8);
- assert(r == 1);
+ assert_se(r == 1);
safe_close(fd);
}
diff --git a/src/journal/test-journal.c b/src/journal/test-journal.c
index 74168b9b83..ff9dc9e170 100644
--- a/src/journal/test-journal.c
+++ b/src/journal/test-journal.c
@@ -66,55 +66,55 @@ static void test_non_empty(void) {
#endif
journal_file_dump(f);
- assert(journal_file_next_entry(f, NULL, 0, DIRECTION_DOWN, &o, &p) == 1);
- assert(le64toh(o->entry.seqnum) == 1);
+ assert_se(journal_file_next_entry(f, NULL, 0, DIRECTION_DOWN, &o, &p) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 1);
- assert(journal_file_next_entry(f, o, p, DIRECTION_DOWN, &o, &p) == 1);
- assert(le64toh(o->entry.seqnum) == 2);
+ assert_se(journal_file_next_entry(f, o, p, DIRECTION_DOWN, &o, &p) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 2);
- assert(journal_file_next_entry(f, o, p, DIRECTION_DOWN, &o, &p) == 1);
- assert(le64toh(o->entry.seqnum) == 3);
+ assert_se(journal_file_next_entry(f, o, p, DIRECTION_DOWN, &o, &p) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 3);
- assert(journal_file_next_entry(f, o, p, DIRECTION_DOWN, &o, &p) == 0);
+ assert_se(journal_file_next_entry(f, o, p, DIRECTION_DOWN, &o, &p) == 0);
- assert(journal_file_next_entry(f, NULL, 0, DIRECTION_DOWN, &o, &p) == 1);
- assert(le64toh(o->entry.seqnum) == 1);
+ assert_se(journal_file_next_entry(f, NULL, 0, DIRECTION_DOWN, &o, &p) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 1);
- assert(journal_file_skip_entry(f, o, p, 2, &o, &p) == 1);
- assert(le64toh(o->entry.seqnum) == 3);
+ assert_se(journal_file_skip_entry(f, o, p, 2, &o, &p) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 3);
- assert(journal_file_skip_entry(f, o, p, -2, &o, &p) == 1);
- assert(le64toh(o->entry.seqnum) == 1);
+ assert_se(journal_file_skip_entry(f, o, p, -2, &o, &p) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 1);
- assert(journal_file_skip_entry(f, o, p, -2, &o, &p) == 1);
- assert(le64toh(o->entry.seqnum) == 1);
+ assert_se(journal_file_skip_entry(f, o, p, -2, &o, &p) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 1);
- assert(journal_file_find_data_object(f, test, strlen(test), NULL, &p) == 1);
- assert(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_DOWN, &o, NULL) == 1);
- assert(le64toh(o->entry.seqnum) == 1);
+ assert_se(journal_file_find_data_object(f, test, strlen(test), NULL, &p) == 1);
+ assert_se(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_DOWN, &o, NULL) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 1);
- assert(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_UP, &o, NULL) == 1);
- assert(le64toh(o->entry.seqnum) == 3);
+ assert_se(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_UP, &o, NULL) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 3);
- assert(journal_file_find_data_object(f, test2, strlen(test2), NULL, &p) == 1);
- assert(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_UP, &o, NULL) == 1);
- assert(le64toh(o->entry.seqnum) == 2);
+ assert_se(journal_file_find_data_object(f, test2, strlen(test2), NULL, &p) == 1);
+ assert_se(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_UP, &o, NULL) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 2);
- assert(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_DOWN, &o, NULL) == 1);
- assert(le64toh(o->entry.seqnum) == 2);
+ assert_se(journal_file_next_entry_for_data(f, NULL, 0, p, DIRECTION_DOWN, &o, NULL) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 2);
- assert(journal_file_find_data_object(f, "quux", 4, NULL, &p) == 0);
+ assert_se(journal_file_find_data_object(f, "quux", 4, NULL, &p) == 0);
- assert(journal_file_move_to_entry_by_seqnum(f, 1, DIRECTION_DOWN, &o, NULL) == 1);
- assert(le64toh(o->entry.seqnum) == 1);
+ assert_se(journal_file_move_to_entry_by_seqnum(f, 1, DIRECTION_DOWN, &o, NULL) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 1);
- assert(journal_file_move_to_entry_by_seqnum(f, 3, DIRECTION_DOWN, &o, NULL) == 1);
- assert(le64toh(o->entry.seqnum) == 3);
+ assert_se(journal_file_move_to_entry_by_seqnum(f, 3, DIRECTION_DOWN, &o, NULL) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 3);
- assert(journal_file_move_to_entry_by_seqnum(f, 2, DIRECTION_DOWN, &o, NULL) == 1);
- assert(le64toh(o->entry.seqnum) == 2);
+ assert_se(journal_file_move_to_entry_by_seqnum(f, 2, DIRECTION_DOWN, &o, NULL) == 1);
+ assert_se(le64toh(o->entry.seqnum) == 2);
- assert(journal_file_move_to_entry_by_seqnum(f, 10, DIRECTION_DOWN, &o, NULL) == 0);
+ assert_se(journal_file_move_to_entry_by_seqnum(f, 10, DIRECTION_DOWN, &o, NULL) == 0);
journal_file_rotate(&f, true, true);
journal_file_rotate(&f, true, true);
diff --git a/src/journal/test-mmap-cache.c b/src/journal/test-mmap-cache.c
index 778e884c3f..1227b62310 100644
--- a/src/journal/test-mmap-cache.c
+++ b/src/journal/test-mmap-cache.c
@@ -38,37 +38,37 @@ int main(int argc, char *argv[]) {
assert_se(m = mmap_cache_new());
x = mkostemp_safe(px, O_RDWR|O_CLOEXEC);
- assert(x >= 0);
+ assert_se(x >= 0);
unlink(px);
y = mkostemp_safe(py, O_RDWR|O_CLOEXEC);
- assert(y >= 0);
+ assert_se(y >= 0);
unlink(py);
z = mkostemp_safe(pz, O_RDWR|O_CLOEXEC);
- assert(z >= 0);
+ assert_se(z >= 0);
unlink(pz);
r = mmap_cache_get(m, x, PROT_READ, 0, false, 1, 2, NULL, &p, NULL);
- assert(r >= 0);
+ assert_se(r >= 0);
r = mmap_cache_get(m, x, PROT_READ, 0, false, 2, 2, NULL, &q, NULL);
- assert(r >= 0);
+ assert_se(r >= 0);
- assert((uint8_t*) p + 1 == (uint8_t*) q);
+ assert_se((uint8_t*) p + 1 == (uint8_t*) q);
r = mmap_cache_get(m, x, PROT_READ, 1, false, 3, 2, NULL, &q, NULL);
- assert(r >= 0);
+ assert_se(r >= 0);
- assert((uint8_t*) p + 2 == (uint8_t*) q);
+ assert_se((uint8_t*) p + 2 == (uint8_t*) q);
r = mmap_cache_get(m, x, PROT_READ, 0, false, 16ULL*1024ULL*1024ULL, 2, NULL, &p, NULL);
- assert(r >= 0);
+ assert_se(r >= 0);
r = mmap_cache_get(m, x, PROT_READ, 1, false, 16ULL*1024ULL*1024ULL+1, 2, NULL, &q, NULL);
- assert(r >= 0);
+ assert_se(r >= 0);
- assert((uint8_t*) p + 1 == (uint8_t*) q);
+ assert_se((uint8_t*) p + 1 == (uint8_t*) q);
mmap_cache_unref(m);