aboutsummaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2021-01-21 19:30:18 +0000
committerMark Johnston <markj@FreeBSD.org>2021-01-21 19:30:18 +0000
commited14c69d5679b9a6b86722be698b3060d4b74946 (patch)
treeb20c0406d162599058b9b95abf1570a8d032e6f6 /lib/libc
parentaa37baf3d7cf51da92fd367476182802e71838ae (diff)
downloadsrc-ed14c69d5679b9a6b86722be698b3060d4b74946.tar.gz
src-ed14c69d5679b9a6b86722be698b3060d4b74946.zip
libc/nss tests: Style
Sponsored by: The FreeBSD Foundation MFC after: 1 month
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/tests/nss/getgr_test.c32
-rw-r--r--lib/libc/tests/nss/getpw_test.c39
-rw-r--r--lib/libc/tests/nss/testutil.h2
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); \
}