From c49f6b7bc6b7a958123a7821ade1648875d8419e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 2 Jun 2009 12:24:43 +0200 Subject: nss_wrapper: refactor test_nwrap_membership_user() in testsuite. Guenther --- lib/nss_wrapper/testsuite.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'lib/nss_wrapper') diff --git a/lib/nss_wrapper/testsuite.c b/lib/nss_wrapper/testsuite.c index d63e7363ca..a98c141e3e 100644 --- a/lib/nss_wrapper/testsuite.c +++ b/lib/nss_wrapper/testsuite.c @@ -297,6 +297,28 @@ static bool test_nwrap_getgrouplist(struct torture_context *tctx, return true; } +static bool test_nwrap_membership_user(struct torture_context *tctx, + const struct passwd *pwd) +{ + int num_user_groups = 0; + gid_t *user_groups = NULL; + int g; + + torture_assert(tctx, test_nwrap_getgrouplist(tctx, + pwd->pw_name, + pwd->pw_gid, + &user_groups, + &num_user_groups), + "failed to test getgrouplist"); + + for (g=0; g < num_user_groups; g++) { + torture_assert(tctx, test_nwrap_getgrgid(tctx, user_groups[g]), + "failed to find the group the user is a member of"); + } + + return true; +} + static bool test_nwrap_membership(struct torture_context *tctx) { const char *old_pwd = getenv("NSS_WRAPPER_PASSWD"); @@ -315,21 +337,9 @@ static bool test_nwrap_membership(struct torture_context *tctx) for (i=0; i < num_pwd; i++) { - int num_user_groups = 0; - gid_t *user_groups = NULL; - int g; + torture_assert(tctx, test_nwrap_membership_user(tctx, &pwd[i]), + "failde to test membership for user"); - torture_assert(tctx, test_nwrap_getgrouplist(tctx, - pwd[i].pw_name, - pwd[i].pw_gid, - &user_groups, - &num_user_groups), - "failed to test getgrouplist"); - - for (g=0; g < num_user_groups; g++) { - torture_assert(tctx, test_nwrap_getgrgid(tctx, user_groups[g]), - "failed to find the group the user is a member of"); - } } return true; -- cgit