summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-02-20 22:10:45 +0100
committerSven Eden <yamakuzure@gmx.net>2018-05-30 07:59:01 +0200
commitf6b10c7beb8048e772b4d659faaf8a44d4d11190 (patch)
treed4439d7235360b01267157c861b011cd04c73a77 /src/test
parent28fc018d92357cc8d0d1c76def150dc793930781 (diff)
test-user-util: print function delimiters
This makes it easier to see what is going on. Crashes may happen in a nested test_{uid,gid}_to_name_one() function, and the default backtrace doesn't show the actual string being tested.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-user-util.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/src/test/test-user-util.c b/src/test/test-user-util.c
index 2b4daf172..799065cda 100644
--- a/src/test/test-user-util.c
+++ b/src/test/test-user-util.c
@@ -32,10 +32,6 @@ static void test_uid_to_name_one(uid_t uid, const char *name) {
log_info("/* %s("UID_FMT", \"%s\") */", __func__, uid, name);
assert_se(t = uid_to_name(uid));
- if (!synthesize_nobody() && streq(name, NOBODY_USER_NAME)) {
- log_info("(skipping detailed tests because nobody is not synthesized)");
- return;
- }
assert_se(streq_ptr(t, name));
}
@@ -45,10 +41,6 @@ static void test_gid_to_name_one(gid_t gid, const char *name) {
log_info("/* %s("GID_FMT", \"%s\") */", __func__, gid, name);
assert_se(t = gid_to_name(gid));
- if (!synthesize_nobody() && streq(name, NOBODY_GROUP_NAME)) {
- log_info("(skipping detailed tests because nobody is not synthesized)");
- return;
- }
assert_se(streq_ptr(t, name));
}
@@ -168,23 +160,17 @@ static void test_valid_home(void) {
}
static void test_get_user_creds_one(const char *id, const char *name, uid_t uid, gid_t gid, const char *home, const char *shell) {
- const char *rhome = NULL;
- const char *rshell = NULL;
- uid_t ruid = UID_INVALID;
- gid_t rgid = GID_INVALID;
- int r;
+ const char *rhome;
+ const char *rshell;
+ uid_t ruid;
+ gid_t rgid;
log_info("/* %s(\"%s\", \"%s\", "UID_FMT", "GID_FMT", \"%s\", \"%s\") */",
__func__, id, name, uid, gid, home, shell);
- r = get_user_creds(&id, &ruid, &rgid, &rhome, &rshell);
- log_info_errno(r, "got \"%s\", "UID_FMT", "GID_FMT", \"%s\", \"%s\": %m",
- id, ruid, rgid, strnull(rhome), strnull(rshell));
- if (!synthesize_nobody() && streq(name, NOBODY_USER_NAME)) {
- log_info("(skipping detailed tests because nobody is not synthesized)");
- return;
- }
- assert_se(r == 0);
+ assert_se(get_user_creds(&id, &ruid, &rgid, &rhome, &rshell) >= 0);
+ log_info("got \"%s\", "UID_FMT", "GID_FMT", \"%s\", \"%s\"",
+ id, ruid, rgid, rhome, rshell);
assert_se(streq_ptr(id, name));
assert_se(ruid == uid);
assert_se(rgid == gid);
@@ -194,18 +180,12 @@ static void test_get_user_creds_one(const char *id, const char *name, uid_t uid,
#if 0 /// UNNEEDED by elogind
static void test_get_group_creds_one(const char *id, const char *name, gid_t gid) {
- gid_t rgid = GID_INVALID;
- int r;
+ gid_t rgid;
log_info("/* %s(\"%s\", \"%s\", "GID_FMT") */", __func__, id, name, gid);
- r = get_group_creds(&id, &rgid);
- log_info_errno(r, "got \"%s\", "GID_FMT": %m", id, rgid);
- if (!synthesize_nobody() && streq(name, NOBODY_GROUP_NAME)) {
- log_info("(skipping detailed tests because nobody is not synthesized)");
- return;
- }
- assert_se(r == 0);
+ assert_se(get_group_creds(&id, &rgid) >= 0);
+ log_info("got \"%s\", "GID_FMT, id, rgid);
assert_se(streq_ptr(id, name));
assert_se(rgid == gid);
}