diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-hashmap.c | 2 | ||||
-rw-r--r-- | src/test/test-hmac.c | 2 | ||||
-rw-r--r-- | src/test/test-mountpoint-util.c | 2 | ||||
-rw-r--r-- | src/test/test-os-util.c | 51 | ||||
-rw-r--r-- | src/test/test-path-util.c | 8 | ||||
-rw-r--r-- | src/test/test-pretty-print.c | 2 | ||||
-rw-r--r-- | src/test/test-recovery-key.c | 2 | ||||
-rw-r--r-- | src/test/test-user-util.c | 4 |
8 files changed, 37 insertions, 36 deletions
diff --git a/src/test/test-hashmap.c b/src/test/test-hashmap.c index 5daa0e64f6..cf4fca27e3 100644 --- a/src/test/test-hashmap.c +++ b/src/test/test-hashmap.c @@ -42,7 +42,7 @@ TEST(trivial_compare_func) { } TEST(string_compare_func) { - assert_se(string_compare_func("fred", "wilma") != 0); + ASSERT_NE(string_compare_func("fred", "wilma"), 0); assert_se(string_compare_func("fred", "fred") == 0); } diff --git a/src/test/test-hmac.c b/src/test/test-hmac.c index 1b788b191c..18c81adbcd 100644 --- a/src/test/test-hmac.c +++ b/src/test/test-hmac.c @@ -19,7 +19,7 @@ TEST(hmac) { "", result); hex_result = hexmem(result, sizeof(result)); - assert_se(streq_ptr(hex_result, "cadd5e42114351181f3abff477641d88efb57d2b5641a1e5c6d623363a6d3bad")); + ASSERT_STREQ(hex_result, "cadd5e42114351181f3abff477641d88efb57d2b5641a1e5c6d623363a6d3bad"); hex_result = mfree(hex_result); hmac_sha256_by_string("waldo", diff --git a/src/test/test-mountpoint-util.c b/src/test/test-mountpoint-util.c index 6d784a9ae8..affcaccc00 100644 --- a/src/test/test-mountpoint-util.c +++ b/src/test/test-mountpoint-util.c @@ -152,7 +152,7 @@ TEST(path_is_mount_point) { */ /* file mountpoints */ - assert_se(mkdtemp(tmp_dir) != NULL); + ASSERT_NOT_NULL(mkdtemp(tmp_dir)); file1 = path_join(tmp_dir, "file1"); assert_se(file1); file2 = path_join(tmp_dir, "file2"); diff --git a/src/test/test-os-util.c b/src/test/test-os-util.c index 84e55e1754..e51ab9d290 100644 --- a/src/test/test-os-util.c +++ b/src/test/test-os-util.c @@ -14,47 +14,47 @@ #include "tmpfile-util.h" TEST(path_is_os_tree) { - assert_se(path_is_os_tree("/") > 0); - assert_se(path_is_os_tree("/etc") == 0); + ASSERT_GT(path_is_os_tree("/"), 0); + ASSERT_EQ(path_is_os_tree("/etc"), 0); assert_se(path_is_os_tree("/idontexist") == -ENOENT); } TEST(parse_os_release) { /* Let's assume that we're running in a valid system, so os-release is available */ _cleanup_free_ char *id = NULL, *id2 = NULL, *name = NULL, *foobar = NULL; - assert_se(parse_os_release(NULL, "ID", &id) == 0); + ASSERT_EQ(parse_os_release(NULL, "ID", &id), 0); log_info("ID: %s", id); - assert_se(setenv("SYSTEMD_OS_RELEASE", "/dev/null", 1) == 0); - assert_se(parse_os_release(NULL, "ID", &id2) == 0); + ASSERT_EQ(setenv("SYSTEMD_OS_RELEASE", "/dev/null", 1), 0); + ASSERT_EQ(parse_os_release(NULL, "ID", &id2), 0); log_info("ID: %s", strnull(id2)); _cleanup_(unlink_tempfilep) char tmpfile[] = "/tmp/test-os-util.XXXXXX"; - assert_se(write_tmpfile(tmpfile, + ASSERT_EQ(write_tmpfile(tmpfile, "ID=the-id \n" - "NAME=the-name") == 0); + "NAME=the-name"), 0); - assert_se(setenv("SYSTEMD_OS_RELEASE", tmpfile, 1) == 0); - assert_se(parse_os_release(NULL, "ID", &id, "NAME", &name) == 0); + ASSERT_EQ(setenv("SYSTEMD_OS_RELEASE", tmpfile, 1), 0); + ASSERT_EQ(parse_os_release(NULL, "ID", &id, "NAME", &name), 0); log_info("ID: %s NAME: %s", id, name); assert_se(streq(id, "the-id")); assert_se(streq(name, "the-name")); _cleanup_(unlink_tempfilep) char tmpfile2[] = "/tmp/test-os-util.XXXXXX"; - assert_se(write_tmpfile(tmpfile2, + ASSERT_EQ(write_tmpfile(tmpfile2, "ID=\"ignored\" \n" "ID=\"the-id\" \n" - "NAME='the-name'") == 0); + "NAME='the-name'"), 0); - assert_se(setenv("SYSTEMD_OS_RELEASE", tmpfile2, 1) == 0); - assert_se(parse_os_release(NULL, "ID", &id, "NAME", &name) == 0); + ASSERT_EQ(setenv("SYSTEMD_OS_RELEASE", tmpfile2, 1), 0); + ASSERT_EQ(parse_os_release(NULL, "ID", &id, "NAME", &name), 0); log_info("ID: %s NAME: %s", id, name); assert_se(streq(id, "the-id")); assert_se(streq(name, "the-name")); - assert_se(parse_os_release(NULL, "FOOBAR", &foobar) == 0); + ASSERT_EQ(parse_os_release(NULL, "FOOBAR", &foobar), 0); log_info("FOOBAR: %s", strnull(foobar)); - assert_se(foobar == NULL); + ASSERT_NULL(foobar); assert_se(unsetenv("SYSTEMD_OS_RELEASE") == 0); } @@ -70,6 +70,7 @@ TEST(parse_extension_release) { assert_se(a = path_join(tempdir, "/usr/lib/extension-release.d/extension-release.test")); assert_se(mkdir_parents(a, 0777) >= 0); + ASSERT_GE(mkdir_parents(a, 0777), 0); r = write_string_file(a, "ID=the-id \n VERSION_ID=the-version-id", WRITE_STRING_FILE_CREATE); if (r < 0) @@ -87,42 +88,42 @@ TEST(parse_extension_release) { if (r < 0) log_error_errno(r, "Failed to write file: %m"); - assert_se(parse_extension_release(tempdir, IMAGE_CONFEXT, "tester", false, "ID", &id, "VERSION_ID", &version_id) == 0); + ASSERT_EQ(parse_extension_release(tempdir, IMAGE_CONFEXT, "tester", false, "ID", &id, "VERSION_ID", &version_id), 0); log_info("ID: %s VERSION_ID: %s", id, version_id); assert_se(streq(id, "the-id")); assert_se(streq(version_id, "the-version-id")); assert_se(parse_extension_release(tempdir, IMAGE_CONFEXT, "tester", false, "FOOBAR", &foobar) == 0); log_info("FOOBAR: %s", strnull(foobar)); - assert_se(foobar == NULL); + ASSERT_NULL(foobar); assert_se(parse_extension_release(tempdir, IMAGE_SYSEXT, "test", false, "FOOBAR", &foobar) == 0); log_info("FOOBAR: %s", strnull(foobar)); - assert_se(foobar == NULL); + ASSERT_NULL(foobar); } TEST(load_os_release_pairs) { _cleanup_(unlink_tempfilep) char tmpfile[] = "/tmp/test-os-util.XXXXXX"; - assert_se(write_tmpfile(tmpfile, + ASSERT_EQ(write_tmpfile(tmpfile, "ID=\"ignored\" \n" "ID=\"the-id\" \n" - "NAME='the-name'") == 0); + "NAME='the-name'"), 0); - assert_se(setenv("SYSTEMD_OS_RELEASE", tmpfile, 1) == 0); + ASSERT_EQ(setenv("SYSTEMD_OS_RELEASE", tmpfile, 1), 0); _cleanup_strv_free_ char **pairs = NULL; - assert_se(load_os_release_pairs(NULL, &pairs) == 0); + ASSERT_EQ(load_os_release_pairs(NULL, &pairs), 0); assert_se(strv_equal(pairs, STRV_MAKE("ID", "the-id", "NAME", "the-name"))); - assert_se(unsetenv("SYSTEMD_OS_RELEASE") == 0); + ASSERT_EQ(unsetenv("SYSTEMD_OS_RELEASE"), 0); } TEST(os_release_support_ended) { int r; - assert_se(os_release_support_ended("1999-01-01", false, NULL) == true); - assert_se(os_release_support_ended("2037-12-31", false, NULL) == false); + ASSERT_TRUE(os_release_support_ended("1999-01-01", false, NULL)); + ASSERT_FALSE(os_release_support_ended("2037-12-31", false, NULL)); assert_se(os_release_support_ended("-1-1-1", true, NULL) == -EINVAL); r = os_release_support_ended(NULL, false, NULL); diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c index ca11bf3a29..ceff01967a 100644 --- a/src/test/test-path-util.c +++ b/src/test/test-path-util.c @@ -506,24 +506,24 @@ TEST(prefixes) { log_error("---%s---", s); assert_se(streq(s, values[i++])); } - assert_se(values[i] == NULL); + ASSERT_NULL(values[i]); i = 1; PATH_FOREACH_PREFIX(s, "/a/b/c/d") { log_error("---%s---", s); assert_se(streq(s, values[i++])); } - assert_se(values[i] == NULL); + ASSERT_NULL(values[i]); i = 0; PATH_FOREACH_PREFIX_MORE(s, "////a////b////c///d///////") assert_se(streq(s, values[i++])); - assert_se(values[i] == NULL); + ASSERT_NULL(values[i]); i = 1; PATH_FOREACH_PREFIX(s, "////a////b////c///d///////") assert_se(streq(s, values[i++])); - assert_se(values[i] == NULL); + ASSERT_NULL(values[i]); PATH_FOREACH_PREFIX(s, "////") assert_not_reached(); diff --git a/src/test/test-pretty-print.c b/src/test/test-pretty-print.c index 52b2bc861e..9ab52c6012 100644 --- a/src/test/test-pretty-print.c +++ b/src/test/test-pretty-print.c @@ -22,7 +22,7 @@ static void test_draw_cylon_one(unsigned pos) { memset(buf, 0xff, sizeof(buf)); draw_cylon(buf, sizeof(buf), CYLON_WIDTH, pos); - assert_se(strlen(buf) < sizeof(buf)); + ASSERT_LE(strlen(buf), sizeof(buf)); } TEST(draw_cylon) { diff --git a/src/test/test-recovery-key.c b/src/test/test-recovery-key.c index 909ef4ccf2..2e901dc9bc 100644 --- a/src/test/test-recovery-key.c +++ b/src/test/test-recovery-key.c @@ -17,7 +17,7 @@ TEST(make_recovery_key) { /* Check for successful recovery-key creation */ r = make_recovery_key(&recovery_key); assert_se(r == 0); - assert_se(recovery_key != NULL); + ASSERT_NOT_NULL(recovery_key); /* Check that length of formatted key is 72 with 64 modhex characters */ length = strlen(recovery_key); diff --git a/src/test/test-user-util.c b/src/test/test-user-util.c index db76cde0a2..f115a47773 100644 --- a/src/test/test-user-util.c +++ b/src/test/test-user-util.c @@ -137,8 +137,8 @@ TEST(parse_uid) { } TEST(uid_ptr) { - assert_se(UID_TO_PTR(0) != NULL); - assert_se(UID_TO_PTR(1000) != NULL); + ASSERT_NOT_NULL(UID_TO_PTR(0)); + ASSERT_NOT_NULL(UID_TO_PTR(1000)); assert_se(PTR_TO_UID(UID_TO_PTR(0)) == 0); assert_se(PTR_TO_UID(UID_TO_PTR(1000)) == 1000); |