[systemd-commits] 3 commits - src/journal src/test
Lennart Poettering
lennart at kemper.freedesktop.org
Tue Aug 26 11:33:12 PDT 2014
src/journal/test-compress.c | 4 ++--
src/test/test-path-util.c | 30 +++++++++++++++---------------
src/test/test-util.c | 2 +-
3 files changed, 18 insertions(+), 18 deletions(-)
New commits:
commit 684fc8927e0f83496d4384ac434e265f7cd7a87b
Author: Filipe Brandenburger <filbranden at google.com>
Date: Mon Aug 25 22:05:04 2014 -0700
test-util: use assert_se() for call to safe_mkdir with side effect
Otherwise it gets optimized out when CPPFLAGS='-DNDEBUG' is used.
Tested:
- make check TESTS='test-util' CPPFLAGS='-DNDEBUG'
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 34d5f2e..4d9b28f 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -863,7 +863,7 @@ static void test_readlink_and_make_absolute(void) {
char name_alias[] = "/tmp/test-readlink_and_make_absolute-alias";
char *r = NULL;
- assert(mkdir_safe(tempdir, 0755, getuid(), getgid()) >= 0);
+ assert_se(mkdir_safe(tempdir, 0755, getuid(), getgid()) >= 0);
assert_se(touch(name) >= 0);
assert_se(symlink(name, name_alias) >= 0);
commit 8d95631ea6c039a60bb7ac456f687a8fdf0c4381
Author: Filipe Brandenburger <filbranden at google.com>
Date: Mon Aug 25 22:05:03 2014 -0700
test-path-util: use assert_se in all assertions
Otherwise they get optimized out when CPPFLAGS='-DNDEBUG' is used, and that
causes the tests to fail.
Tested:
- make check TESTS='test-path-util' CPPFLAGS='-DNDEBUG'
diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c
index c8dcd85..01afb3e 100644
--- a/src/test/test-path-util.c
+++ b/src/test/test-path-util.c
@@ -79,35 +79,35 @@ static void test_path(void) {
char p2[] = "//aaa/.////ccc";
char p3[] = "/./";
- assert(path_equal(path_kill_slashes(p1), "aaa/bbb/ccc"));
- assert(path_equal(path_kill_slashes(p2), "/aaa/./ccc"));
- assert(path_equal(path_kill_slashes(p3), "/./"));
+ assert_se(path_equal(path_kill_slashes(p1), "aaa/bbb/ccc"));
+ assert_se(path_equal(path_kill_slashes(p2), "/aaa/./ccc"));
+ assert_se(path_equal(path_kill_slashes(p3), "/./"));
}
}
static void test_find_binary(const char *self) {
char *p;
- assert(find_binary("/bin/sh", &p) == 0);
+ assert_se(find_binary("/bin/sh", &p) == 0);
puts(p);
- assert(streq(p, "/bin/sh"));
+ assert_se(streq(p, "/bin/sh"));
free(p);
- assert(find_binary(self, &p) == 0);
+ assert_se(find_binary(self, &p) == 0);
puts(p);
- assert(endswith(p, "/test-path-util"));
- assert(path_is_absolute(p));
+ assert_se(endswith(p, "/test-path-util"));
+ assert_se(path_is_absolute(p));
free(p);
- assert(find_binary("sh", &p) == 0);
+ assert_se(find_binary("sh", &p) == 0);
puts(p);
- assert(endswith(p, "/sh"));
- assert(path_is_absolute(p));
+ assert_se(endswith(p, "/sh"));
+ assert_se(path_is_absolute(p));
free(p);
- assert(find_binary("xxxx-xxxx", &p) == -ENOENT);
+ assert_se(find_binary("xxxx-xxxx", &p) == -ENOENT);
- assert(find_binary("/some/dir/xxxx-xxxx", &p) == -ENOENT);
+ assert_se(find_binary("/some/dir/xxxx-xxxx", &p) == -ENOENT);
}
static void test_prefixes(void) {
@@ -156,8 +156,8 @@ static void test_prefixes(void) {
b = false;
PATH_FOREACH_PREFIX_MORE(s, "") {
- assert(!b);
- assert(streq(s, ""));
+ assert_se(!b);
+ assert_se(streq(s, ""));
b = true;
}
}
commit 52754725e185f1331f821d85ed2ef78fb92af1fe
Author: Filipe Brandenburger <filbranden at google.com>
Date: Mon Aug 25 22:05:02 2014 -0700
test-compress: make sure asserts with side effects use assert_se()
Otherwise the test fails when built with CPPFLAGS='-DNDEBUG' which disables
assertions.
Tested:
- make check TESTS='test-compress' CPPFLAGS='-DNDEBUG'
diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c
index f5f5f8d..026d630 100644
--- a/src/journal/test-compress.c
+++ b/src/journal/test-compress.c
@@ -145,11 +145,11 @@ static void test_compress_stream(int compression,
assert_se((dst = mkostemp_safe(pattern, O_RDWR|O_CLOEXEC)) >= 0);
- assert(compress(src, dst, -1) == 0);
+ assert_se(compress(src, dst, -1) == 0);
if (cat) {
assert_se(asprintf(&cmd, "%s %s | diff %s -", cat, pattern, srcfile) > 0);
- assert(system(cmd) == 0);
+ assert_se(system(cmd) == 0);
}
log_debug("/* test decompression */");
More information about the systemd-commits
mailing list