libc/nss tests: Style
Sponsored by: The FreeBSD Foundation MFC after: 1 month
This commit is contained in:
parent
aa37baf3d7
commit
ed14c69d56
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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); \
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user