summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2023-04-25 17:58:34 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2023-04-25 18:08:15 +0200
commit55ace8e5c58441d1a2c64b297a38b232ef0c0e28 (patch)
treef1947154f32a1afc8216d36c4171de70cc66cad5 /src/test
parent4a75704b166de533cedf8f9fab16ffae77bf2093 (diff)
downloadsystemd-55ace8e5c58441d1a2c64b297a38b232ef0c0e28.tar.gz
shared/creds-util: return 0 for missing creds in read_credential_strings_many
Realistically, the only thing that the caller can do is ignore failures related to missing credentials. If the caller requires some credentials to be present, they should just check which output variables are not NULL. One of the callers was already doing that, and the other wanted to, but missed -ENOENT. By suppressing -ENOENT and -ENXIO, both callers are simplified. Fixes a warning at boot: systemd-vconsole-setup[221]: Failed to import credentials, ignoring: No such file or directory
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-creds.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/test/test-creds.c b/src/test/test-creds.c
index 44022e7324..25b0c34a59 100644
--- a/src/test/test-creds.c
+++ b/src/test/test-creds.c
@@ -16,7 +16,7 @@ TEST(read_credential_strings) {
if (e)
assert_se(saved = strdup(e));
- assert_se(read_credential_strings_many("foo", &x, "bar", &y) == -ENXIO);
+ assert_se(read_credential_strings_many("foo", &x, "bar", &y) == 0);
assert_se(x == NULL);
assert_se(y == NULL);
@@ -24,20 +24,20 @@ TEST(read_credential_strings) {
assert_se(setenv("CREDENTIALS_DIRECTORY", tmp, /* override= */ true) >= 0);
- assert_se(read_credential_strings_many("foo", &x, "bar", &y) == -ENOENT);
+ assert_se(read_credential_strings_many("foo", &x, "bar", &y) == 0);
assert_se(x == NULL);
assert_se(y == NULL);
assert_se(p = path_join(tmp, "bar"));
assert_se(write_string_file(p, "piff", WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_AVOID_NEWLINE) >= 0);
- assert_se(read_credential_strings_many("foo", &x, "bar", &y) == -ENOENT);
+ assert_se(read_credential_strings_many("foo", &x, "bar", &y) == 0);
assert_se(x == NULL);
assert_se(streq(y, "piff"));
assert_se(write_string_file(p, "paff", WRITE_STRING_FILE_TRUNCATE|WRITE_STRING_FILE_AVOID_NEWLINE) >= 0);
- assert_se(read_credential_strings_many("foo", &x, "bar", &y) == -ENOENT);
+ assert_se(read_credential_strings_many("foo", &x, "bar", &y) == 0);
assert_se(x == NULL);
assert_se(streq(y, "piff"));