summaryrefslogtreecommitdiff
path: root/src/test/test-path-lookup.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-03-10 09:47:10 +0100
committerLennart Poettering <lennart@poettering.net>2023-03-10 09:47:39 +0100
commit4870133bfaaf97189a970a29bf47e0e38fa721aa (patch)
treed2fa9a5699a8b4c948179afabf3da2f9da322ce5 /src/test/test-path-lookup.c
parent5f64d2bf332371bdfdcb91b588e57d4c0c20428f (diff)
downloadsystemd-4870133bfaaf97189a970a29bf47e0e38fa721aa.tar.gz
basic: add RuntimeScope enum
In various tools and services we have a per-system and per-user concept. So far we sometimes used a boolean indicating whether we are in system mode, or a reversed boolean indicating whether we are in user mode, or the LookupScope enum used by the lookup path logic. Let's address that, in introduce a common enum for this, we can use all across the board. This is mostly just search/replace, no actual code changes.
Diffstat (limited to 'src/test/test-path-lookup.c')
-rw-r--r--src/test/test-path-lookup.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/test/test-path-lookup.c b/src/test/test-path-lookup.c
index c98a1f4b73..431a85965d 100644
--- a/src/test/test-path-lookup.c
+++ b/src/test/test-path-lookup.c
@@ -11,7 +11,7 @@
#include "tests.h"
#include "tmpfile-util.h"
-static void test_paths_one(LookupScope scope) {
+static void test_paths_one(RuntimeScope scope) {
_cleanup_(rm_rf_physical_and_freep) char *tmp = NULL;
_cleanup_(lookup_paths_free) LookupPaths lp_without_env = {};
_cleanup_(lookup_paths_free) LookupPaths lp_with_env = {};
@@ -34,9 +34,9 @@ static void test_paths_one(LookupScope scope) {
}
TEST(paths) {
- test_paths_one(LOOKUP_SCOPE_SYSTEM);
- test_paths_one(LOOKUP_SCOPE_USER);
- test_paths_one(LOOKUP_SCOPE_GLOBAL);
+ test_paths_one(RUNTIME_SCOPE_SYSTEM);
+ test_paths_one(RUNTIME_SCOPE_USER);
+ test_paths_one(RUNTIME_SCOPE_GLOBAL);
}
TEST(user_and_global_paths) {
@@ -48,8 +48,8 @@ TEST(user_and_global_paths) {
assert_se(unsetenv("XDG_DATA_DIRS") == 0);
assert_se(unsetenv("XDG_CONFIG_DIRS") == 0);
- assert_se(lookup_paths_init(&lp_global, LOOKUP_SCOPE_GLOBAL, 0, NULL) == 0);
- assert_se(lookup_paths_init(&lp_user, LOOKUP_SCOPE_USER, 0, NULL) == 0);
+ assert_se(lookup_paths_init(&lp_global, RUNTIME_SCOPE_GLOBAL, 0, NULL) == 0);
+ assert_se(lookup_paths_init(&lp_user, RUNTIME_SCOPE_USER, 0, NULL) == 0);
g = lp_global.search_path;
u = lp_user.search_path;
@@ -70,7 +70,7 @@ TEST(user_and_global_paths) {
log_info("+ %s", *p);
}
-static void test_generator_binary_paths_one(LookupScope scope) {
+static void test_generator_binary_paths_one(RuntimeScope scope) {
_cleanup_(rm_rf_physical_and_freep) char *tmp = NULL;
_cleanup_strv_free_ char **gp_without_env = NULL;
_cleanup_strv_free_ char **env_gp_without_env = NULL;
@@ -85,13 +85,13 @@ static void test_generator_binary_paths_one(LookupScope scope) {
assert_se(unsetenv("SYSTEMD_ENVIRONMENT_GENERATOR_PATH") == 0);
gp_without_env = generator_binary_paths(scope);
- env_gp_without_env = env_generator_binary_paths(scope == LOOKUP_SCOPE_SYSTEM ? true : false);
+ env_gp_without_env = env_generator_binary_paths(scope);
- log_info("Generators dirs (%s):", scope == LOOKUP_SCOPE_SYSTEM ? "system" : "user");
+ log_info("Generators dirs (%s):", runtime_scope_to_string(scope));
STRV_FOREACH(dir, gp_without_env)
log_info(" %s", *dir);
- log_info("Environment generators dirs (%s):", scope == LOOKUP_SCOPE_SYSTEM ? "system" : "user");
+ log_info("Environment generators dirs (%s):", runtime_scope_to_string(scope));
STRV_FOREACH(dir, env_gp_without_env)
log_info(" %s", *dir);
@@ -104,13 +104,13 @@ static void test_generator_binary_paths_one(LookupScope scope) {
assert_se(setenv("SYSTEMD_ENVIRONMENT_GENERATOR_PATH", systemd_env_generator_path, 1) == 0);
gp_with_env = generator_binary_paths(scope);
- env_gp_with_env = env_generator_binary_paths(scope == LOOKUP_SCOPE_SYSTEM ? true : false);
+ env_gp_with_env = env_generator_binary_paths(scope);
- log_info("Generators dirs (%s):", scope == LOOKUP_SCOPE_SYSTEM ? "system" : "user");
+ log_info("Generators dirs (%s):", runtime_scope_to_string(scope));
STRV_FOREACH(dir, gp_with_env)
log_info(" %s", *dir);
- log_info("Environment generators dirs (%s):", scope == LOOKUP_SCOPE_SYSTEM ? "system" : "user");
+ log_info("Environment generators dirs (%s):", runtime_scope_to_string(scope));
STRV_FOREACH(dir, env_gp_with_env)
log_info(" %s", *dir);
@@ -119,8 +119,8 @@ static void test_generator_binary_paths_one(LookupScope scope) {
}
TEST(generator_binary_paths) {
- test_generator_binary_paths_one(LOOKUP_SCOPE_SYSTEM);
- test_generator_binary_paths_one(LOOKUP_SCOPE_USER);
+ test_generator_binary_paths_one(RUNTIME_SCOPE_SYSTEM);
+ test_generator_binary_paths_one(RUNTIME_SCOPE_USER);
}
DEFINE_TEST_MAIN(LOG_DEBUG);