1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-10 01:17:44 +03:00

Added unit test for strv_env_name_is_valid() function listed in env-util.c (#27100)

tests: add test for strv_env_name_is_valid function listed in env-util.c
(cherry picked from commit 6cc19afac1)
This commit is contained in:
taniishkaaa 2023-04-02 18:57:29 +05:30 committed by Luca Boccassi
parent 0430078cfb
commit eda7bf237f

View File

@ -452,4 +452,13 @@ TEST(getenv_steal_erase) {
assert_se(r > 0);
}
TEST(strv_env_name_is_valid) {
const char *valid_env_names[] = {"HOME", "USER", "SHELL", "PATH", NULL};
const char *invalid_env_names[] = {"", "PATH", "home", "user", "SHELL", NULL};
const char *repeated_env_names[] = {"HOME", "USER", "SHELL", "USER", NULL};
assert_se(strv_env_name_is_valid((char **) valid_env_names));
assert_se(!strv_env_name_is_valid((char **) invalid_env_names));
assert_se(!strv_env_name_is_valid((char **) repeated_env_names));
}
DEFINE_TEST_MAIN(LOG_DEBUG);