summaryrefslogtreecommitdiff
path: root/src/test/test-condition.c
diff options
context:
space:
mode:
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>2017-08-06 00:25:19 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-08-05 19:25:19 -0400
commitecaa5ad89f4c9832deb7d0cf7960f363a3c6f068 (patch)
tree91ef729001b91b79c4d5562031528f83346a22ee /src/test/test-condition.c
parentd7cefe8b2b236a8642aaffd0b782fa3323e6cefc (diff)
downloadsystemd-ecaa5ad89f4c9832deb7d0cf7960f363a3c6f068.tar.gz
test-condition: fix test_condition_test_group() (#6531)
I hit a test failure with the `max_gid+1` test. Problem is that we loop over 0..r, but set `r` again within the loop (to 1). So max_gid is only set based on the first supplementary GID. ConditionGroup=1000 → 1 ConditionGroup=4 → 1 ConditionGroup=adm → 1 ConditionGroup=1001 → 1 Assertion 'r == 0' failed at ../src/test/test-condition.c:462, function test_condition_test_group(). Aborting. $ id uid=1000(alan-sysop) gid=1000(alan-sysop) groups=1000(alan-sysop),4(adm), 10(wheel),1001(sshlogin)
Diffstat (limited to 'src/test/test-condition.c')
-rw-r--r--src/test/test-condition.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/test/test-condition.c b/src/test/test-condition.c
index b15f1b98c0..278ac2ab6c 100644
--- a/src/test/test-condition.c
+++ b/src/test/test-condition.c
@@ -402,7 +402,7 @@ static void test_condition_test_group(void) {
char* gid;
char* groupname;
gid_t *gids, max_gid;
- int ngroups_max, r, i;
+ int ngroups_max, ngroups, r, i;
assert_se(0 < asprintf(&gid, "%u", UINT32_C(0xFFFF)));
condition = condition_new(CONDITION_GROUP, gid, false, false);
@@ -427,11 +427,11 @@ static void test_condition_test_group(void) {
gids = alloca(sizeof(gid_t) * ngroups_max);
- r = getgroups(ngroups_max, gids);
- assert(r >= 0);
+ ngroups = getgroups(ngroups_max, gids);
+ assert(ngroups >= 0);
max_gid = getgid();
- for (i = 0; i < r; i++) {
+ for (i = 0; i < ngroups; i++) {
assert_se(0 < asprintf(&gid, "%u", gids[i]));
condition = condition_new(CONDITION_GROUP, gid, false, false);
assert_se(condition);