From owner-dev-commits-src-branches@freebsd.org Sat Feb 20 16:35:52 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D633854D6A4; Sat, 20 Feb 2021 16:35:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DjYwS5jXdz3sfT; Sat, 20 Feb 2021 16:35:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B69B0224A7; Sat, 20 Feb 2021 16:35:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11KGZq36028791; Sat, 20 Feb 2021 16:35:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11KGZqJh028790; Sat, 20 Feb 2021 16:35:52 GMT (envelope-from git) Date: Sat, 20 Feb 2021 16:35:52 GMT Message-Id: <202102201635.11KGZqJh028790@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: e1cbe25f5f36 - stable/12 - libc/nss tests: Style MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e1cbe25f5f36839b9ce042dfb0ce2a89b91f5d05 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Feb 2021 16:35:52 -0000 The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e1cbe25f5f36839b9ce042dfb0ce2a89b91f5d05 commit e1cbe25f5f36839b9ce042dfb0ce2a89b91f5d05 Author: Mark Johnston AuthorDate: 2021-01-21 19:30:18 +0000 Commit: Mark Johnston CommitDate: 2021-02-20 16:35:32 +0000 libc/nss tests: Style Sponsored by: The FreeBSD Foundation (cherry picked from commit ed14c69d5679b9a6b86722be698b3060d4b74946) --- lib/libc/tests/nss/getgr_test.c | 32 ++++++++++++++++---------------- lib/libc/tests/nss/getpw_test.c | 39 ++++++++++++++++++++------------------- lib/libc/tests/nss/testutil.h | 2 +- 3 files changed, 37 insertions(+), 36 deletions(-) diff --git a/lib/libc/tests/nss/getgr_test.c b/lib/libc/tests/nss/getgr_test.c index 757382b02f39..ec06d5cf2f6c 100644 --- a/lib/libc/tests/nss/getgr_test.c +++ b/lib/libc/tests/nss/getgr_test.c @@ -62,8 +62,7 @@ static void free_group(struct group *); static void sdump_group(struct group *, char *, size_t); static int group_read_snapshot_func(struct group *, char *); -static int group_check_ambiguity(struct group_test_data *, - struct group *); +static int group_check_ambiguity(struct group_test_data *, struct group *); static int group_fill_test_data(struct group_test_data *); static int group_test_correctness(struct group *, void *); static int group_test_getgrnam(struct group *, void *); @@ -175,7 +174,7 @@ sdump_group(struct group *grp, char *buffer, size_t buflen) int written; written = snprintf(buffer, buflen, "%s:%s:%d:", - grp->gr_name, grp->gr_passwd, grp->gr_gid); + grp->gr_name, grp->gr_passwd, grp->gr_gid); buffer += written; if (written > (int)buflen) return; @@ -340,8 +339,8 @@ static int group_check_ambiguity(struct group_test_data *td, struct group *pwd) { - return (TEST_DATA_FIND(group, td, pwd, compare_group, - NULL) != NULL ? 0 : -1); + return (TEST_DATA_FIND(group, td, pwd, compare_group, NULL) != + NULL ? 0 : -1); } static int @@ -377,18 +376,19 @@ group_test_getgrgid(struct group *grp_model, void *mdata) grp = getgrgid(grp_model->gr_gid); if (group_test_correctness(grp, NULL) != 0 || (compare_group(grp, grp_model, NULL) != 0 && - group_check_ambiguity((struct group_test_data *)mdata, grp) != 0)) { + group_check_ambiguity((struct group_test_data *)mdata, grp) != 0)) return (-1); - } else { + else return (0); - } } static int group_test_getgrent(struct group *grp, void *mdata __unused) { - /* Only correctness can be checked when doing 1-pass test for - * getgrent(). */ + /* + * Only correctness can be checked when doing 1-pass test for + * getgrent(). + */ return (group_test_correctness(grp, NULL)); } @@ -451,12 +451,12 @@ run_tests(const char *snapshot_file, enum test_methods method) compare_group, NULL); break; case TEST_GETGRENT_2PASS: - TEST_DATA_INIT(group, &td_2pass, clone_group, free_group); - rv = group_fill_test_data(&td_2pass); - if (rv != -1) - rv = DO_2PASS_TEST(group, &td, &td_2pass, - compare_group, NULL); - TEST_DATA_DESTROY(group, &td_2pass); + TEST_DATA_INIT(group, &td_2pass, clone_group, free_group); + rv = group_fill_test_data(&td_2pass); + if (rv != -1) + rv = DO_2PASS_TEST(group, &td, &td_2pass, + compare_group, NULL); + TEST_DATA_DESTROY(group, &td_2pass); break; case TEST_BUILD_SNAPSHOT: if (snapshot_file != NULL) diff --git a/lib/libc/tests/nss/getpw_test.c b/lib/libc/tests/nss/getpw_test.c index c7ad2e5a4889..e7c5304005ec 100644 --- a/lib/libc/tests/nss/getpw_test.c +++ b/lib/libc/tests/nss/getpw_test.c @@ -302,8 +302,8 @@ static int passwd_check_ambiguity(struct passwd_test_data *td, struct passwd *pwd) { - return (TEST_DATA_FIND(passwd, td, pwd, compare_passwd, - NULL) != NULL ? 0 : -1); + return (TEST_DATA_FIND(passwd, td, pwd, compare_passwd, NULL) != + NULL ? 0 : -1); } static int @@ -320,10 +320,9 @@ passwd_test_getpwnam(struct passwd *pwd_model, void *mdata) if (passwd_test_correctness(pwd, NULL) != 0) goto errfin; - if ((compare_passwd(pwd, pwd_model, NULL) != 0) && - (passwd_check_ambiguity((struct passwd_test_data *)mdata, pwd) - !=0)) - goto errfin; + if (compare_passwd(pwd, pwd_model, NULL) != 0 && + passwd_check_ambiguity((struct passwd_test_data *)mdata, pwd) != 0) + goto errfin; #ifdef DEBUG printf("ok\n"); @@ -348,10 +347,10 @@ passwd_test_getpwuid(struct passwd *pwd_model, void *mdata) #endif pwd = getpwuid(pwd_model->pw_uid); - if ((passwd_test_correctness(pwd, NULL) != 0) || - ((compare_passwd(pwd, pwd_model, NULL) != 0) && - (passwd_check_ambiguity((struct passwd_test_data *)mdata, pwd) - != 0))) { + if (passwd_test_correctness(pwd, NULL) != 0 || + (compare_passwd(pwd, pwd_model, NULL) != 0 && + passwd_check_ambiguity((struct passwd_test_data *)mdata, + pwd) != 0)) { #ifdef DEBUG printf("not ok\n"); #endif @@ -367,8 +366,10 @@ passwd_test_getpwuid(struct passwd *pwd_model, void *mdata) static int passwd_test_getpwent(struct passwd *pwd, void *mdata __unused) { - /* Only correctness can be checked when doing 1-pass test for - * getpwent(). */ + /* + * Only correctness can be checked when doing 1-pass test for + * getpwent(). + */ return (passwd_test_correctness(pwd, NULL)); } @@ -397,7 +398,7 @@ run_tests(const char *snapshot_file, enum test_methods method) } TEST_SNAPSHOT_FILE_READ(passwd, snapshot_file, - &td_snap, passwd_read_snapshot_func); + &td_snap, passwd_read_snapshot_func); } } @@ -409,26 +410,26 @@ run_tests(const char *snapshot_file, enum test_methods method) case TEST_GETPWNAM: if (snapshot_file == NULL) rv = DO_1PASS_TEST(passwd, &td, - passwd_test_getpwnam, (void *)&td); + passwd_test_getpwnam, (void *)&td); else rv = DO_1PASS_TEST(passwd, &td_snap, - passwd_test_getpwnam, (void *)&td_snap); + passwd_test_getpwnam, (void *)&td_snap); break; case TEST_GETPWUID: if (snapshot_file == NULL) rv = DO_1PASS_TEST(passwd, &td, - passwd_test_getpwuid, (void *)&td); + passwd_test_getpwuid, (void *)&td); else rv = DO_1PASS_TEST(passwd, &td_snap, - passwd_test_getpwuid, (void *)&td_snap); + passwd_test_getpwuid, (void *)&td_snap); break; case TEST_GETPWENT: if (snapshot_file == NULL) rv = DO_1PASS_TEST(passwd, &td, passwd_test_getpwent, - (void *)&td); + (void *)&td); else rv = DO_2PASS_TEST(passwd, &td, &td_snap, - compare_passwd, NULL); + compare_passwd, NULL); break; case TEST_GETPWENT_2PASS: TEST_DATA_INIT(passwd, &td_2pass, clone_passwd, free_passwd); diff --git a/lib/libc/tests/nss/testutil.h b/lib/libc/tests/nss/testutil.h index ff9e8f0a9304..7b55e16580d1 100644 --- a/lib/libc/tests/nss/testutil.h +++ b/lib/libc/tests/nss/testutil.h @@ -325,6 +325,6 @@ __##ent##_2pass_test(struct ent##_test_data *td1, \ { \ int rv; \ \ - rv = __##ent##_test_data_compare(td1, td2, cmp_func, cmp_mdata); \ + rv = __##ent##_test_data_compare(td1, td2, cmp_func, cmp_mdata);\ return (rv); \ }