summaryrefslogtreecommitdiff
path: root/src/test/test-path-lookup.c
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2021-11-24 12:00:02 +0100
committerJan Janssen <medhefgo@web.de>2021-11-25 15:03:06 +0100
commit4f7452a8eb7a946efea927fae017d4d661097833 (patch)
tree413778cc0fb08fbbed0890130b5ba66c90581e61 /src/test/test-path-lookup.c
parent4d5ad9d951299c905453ac8e3769dc82b0a09fb4 (diff)
downloadsystemd-4f7452a8eb7a946efea927fae017d4d661097833.tar.gz
test: Use TEST macro
This converts to TEST macro where it is trivial. Some additional notable changes: - simplify HAVE_LIBIDN #ifdef in test-dns-domain.c - use saved_argc/saved_argv in test-copy.c, test-path-util.c, test-tmpfiles.c and test-unit-file.c
Diffstat (limited to 'src/test/test-path-lookup.c')
-rw-r--r--src/test/test-path-lookup.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/test/test-path-lookup.c b/src/test/test-path-lookup.c
index f0b716a4c5..a19a33c64b 100644
--- a/src/test/test-path-lookup.c
+++ b/src/test/test-path-lookup.c
@@ -10,7 +10,7 @@
#include "strv.h"
#include "tests.h"
-static void test_paths(UnitFileScope scope) {
+static void test_paths_one(UnitFileScope scope) {
char template[] = "/tmp/test-path-lookup.XXXXXXX";
_cleanup_(lookup_paths_free) LookupPaths lp_without_env = {};
@@ -35,7 +35,13 @@ static void test_paths(UnitFileScope scope) {
assert_se(rm_rf(template, REMOVE_ROOT|REMOVE_PHYSICAL) >= 0);
}
-static void test_user_and_global_paths(void) {
+TEST(paths) {
+ test_paths_one(UNIT_FILE_SYSTEM);
+ test_paths_one(UNIT_FILE_USER);
+ test_paths_one(UNIT_FILE_GLOBAL);
+}
+
+TEST(user_and_global_paths) {
_cleanup_(lookup_paths_free) LookupPaths lp_global = {}, lp_user = {};
char **u, **g, **p;
unsigned k = 0;
@@ -53,7 +59,6 @@ static void test_user_and_global_paths(void) {
* that they also exist in the user search path. Skip any
* entries in user search path which don't exist in the global
* one, but not vice versa. */
- log_info("/* %s */", __func__);
STRV_FOREACH(p, g) {
while (u[k] && !streq(*p, u[k])) {
log_info("+ %s", u[k]);
@@ -67,7 +72,7 @@ static void test_user_and_global_paths(void) {
log_info("+ %s", *p);
}
-static void test_generator_binary_paths(UnitFileScope scope) {
+static void test_generator_binary_paths_one(UnitFileScope scope) {
char template[] = "/tmp/test-path-lookup.XXXXXXX";
_cleanup_strv_free_ char **gp_without_env = NULL;
@@ -117,17 +122,9 @@ static void test_generator_binary_paths(UnitFileScope scope) {
assert_se(strv_equal(env_gp_with_env, STRV_MAKE(systemd_env_generator_path)));
}
-int main(int argc, char **argv) {
- test_setup_logging(LOG_DEBUG);
-
- test_paths(UNIT_FILE_SYSTEM);
- test_paths(UNIT_FILE_USER);
- test_paths(UNIT_FILE_GLOBAL);
-
- test_user_and_global_paths();
-
- test_generator_binary_paths(UNIT_FILE_SYSTEM);
- test_generator_binary_paths(UNIT_FILE_USER);
-
- return EXIT_SUCCESS;
+TEST(generator_binary_paths) {
+ test_generator_binary_paths_one(UNIT_FILE_SYSTEM);
+ test_generator_binary_paths_one(UNIT_FILE_USER);
}
+
+DEFINE_TEST_MAIN(LOG_DEBUG);