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 void sdump_group(struct group *, char *, size_t);
|
||||||
static int group_read_snapshot_func(struct group *, char *);
|
static int group_read_snapshot_func(struct group *, char *);
|
||||||
|
|
||||||
static int group_check_ambiguity(struct group_test_data *,
|
static int group_check_ambiguity(struct group_test_data *, struct group *);
|
||||||
struct group *);
|
|
||||||
static int group_fill_test_data(struct group_test_data *);
|
static int group_fill_test_data(struct group_test_data *);
|
||||||
static int group_test_correctness(struct group *, void *);
|
static int group_test_correctness(struct group *, void *);
|
||||||
static int group_test_getgrnam(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;
|
int written;
|
||||||
|
|
||||||
written = snprintf(buffer, buflen, "%s:%s:%d:",
|
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;
|
buffer += written;
|
||||||
if (written > (int)buflen)
|
if (written > (int)buflen)
|
||||||
return;
|
return;
|
||||||
@ -340,8 +339,8 @@ static int
|
|||||||
group_check_ambiguity(struct group_test_data *td, struct group *pwd)
|
group_check_ambiguity(struct group_test_data *td, struct group *pwd)
|
||||||
{
|
{
|
||||||
|
|
||||||
return (TEST_DATA_FIND(group, td, pwd, compare_group,
|
return (TEST_DATA_FIND(group, td, pwd, compare_group, NULL) !=
|
||||||
NULL) != NULL ? 0 : -1);
|
NULL ? 0 : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -377,18 +376,19 @@ group_test_getgrgid(struct group *grp_model, void *mdata)
|
|||||||
grp = getgrgid(grp_model->gr_gid);
|
grp = getgrgid(grp_model->gr_gid);
|
||||||
if (group_test_correctness(grp, NULL) != 0 ||
|
if (group_test_correctness(grp, NULL) != 0 ||
|
||||||
(compare_group(grp, grp_model, 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);
|
return (-1);
|
||||||
} else {
|
else
|
||||||
return (0);
|
return (0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
group_test_getgrent(struct group *grp, void *mdata __unused)
|
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));
|
return (group_test_correctness(grp, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,12 +451,12 @@ run_tests(const char *snapshot_file, enum test_methods method)
|
|||||||
compare_group, NULL);
|
compare_group, NULL);
|
||||||
break;
|
break;
|
||||||
case TEST_GETGRENT_2PASS:
|
case TEST_GETGRENT_2PASS:
|
||||||
TEST_DATA_INIT(group, &td_2pass, clone_group, free_group);
|
TEST_DATA_INIT(group, &td_2pass, clone_group, free_group);
|
||||||
rv = group_fill_test_data(&td_2pass);
|
rv = group_fill_test_data(&td_2pass);
|
||||||
if (rv != -1)
|
if (rv != -1)
|
||||||
rv = DO_2PASS_TEST(group, &td, &td_2pass,
|
rv = DO_2PASS_TEST(group, &td, &td_2pass,
|
||||||
compare_group, NULL);
|
compare_group, NULL);
|
||||||
TEST_DATA_DESTROY(group, &td_2pass);
|
TEST_DATA_DESTROY(group, &td_2pass);
|
||||||
break;
|
break;
|
||||||
case TEST_BUILD_SNAPSHOT:
|
case TEST_BUILD_SNAPSHOT:
|
||||||
if (snapshot_file != NULL)
|
if (snapshot_file != NULL)
|
||||||
|
@ -302,8 +302,8 @@ static int
|
|||||||
passwd_check_ambiguity(struct passwd_test_data *td, struct passwd *pwd)
|
passwd_check_ambiguity(struct passwd_test_data *td, struct passwd *pwd)
|
||||||
{
|
{
|
||||||
|
|
||||||
return (TEST_DATA_FIND(passwd, td, pwd, compare_passwd,
|
return (TEST_DATA_FIND(passwd, td, pwd, compare_passwd, NULL) !=
|
||||||
NULL) != NULL ? 0 : -1);
|
NULL ? 0 : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -320,10 +320,9 @@ passwd_test_getpwnam(struct passwd *pwd_model, void *mdata)
|
|||||||
if (passwd_test_correctness(pwd, NULL) != 0)
|
if (passwd_test_correctness(pwd, NULL) != 0)
|
||||||
goto errfin;
|
goto errfin;
|
||||||
|
|
||||||
if ((compare_passwd(pwd, pwd_model, NULL) != 0) &&
|
if (compare_passwd(pwd, pwd_model, NULL) != 0 &&
|
||||||
(passwd_check_ambiguity((struct passwd_test_data *)mdata, pwd)
|
passwd_check_ambiguity((struct passwd_test_data *)mdata, pwd) != 0)
|
||||||
!=0))
|
goto errfin;
|
||||||
goto errfin;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("ok\n");
|
printf("ok\n");
|
||||||
@ -348,10 +347,10 @@ passwd_test_getpwuid(struct passwd *pwd_model, void *mdata)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
pwd = getpwuid(pwd_model->pw_uid);
|
pwd = getpwuid(pwd_model->pw_uid);
|
||||||
if ((passwd_test_correctness(pwd, NULL) != 0) ||
|
if (passwd_test_correctness(pwd, NULL) != 0 ||
|
||||||
((compare_passwd(pwd, pwd_model, NULL) != 0) &&
|
(compare_passwd(pwd, pwd_model, NULL) != 0 &&
|
||||||
(passwd_check_ambiguity((struct passwd_test_data *)mdata, pwd)
|
passwd_check_ambiguity((struct passwd_test_data *)mdata,
|
||||||
!= 0))) {
|
pwd) != 0)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("not ok\n");
|
printf("not ok\n");
|
||||||
#endif
|
#endif
|
||||||
@ -367,8 +366,10 @@ passwd_test_getpwuid(struct passwd *pwd_model, void *mdata)
|
|||||||
static int
|
static int
|
||||||
passwd_test_getpwent(struct passwd *pwd, void *mdata __unused)
|
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));
|
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,
|
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:
|
case TEST_GETPWNAM:
|
||||||
if (snapshot_file == NULL)
|
if (snapshot_file == NULL)
|
||||||
rv = DO_1PASS_TEST(passwd, &td,
|
rv = DO_1PASS_TEST(passwd, &td,
|
||||||
passwd_test_getpwnam, (void *)&td);
|
passwd_test_getpwnam, (void *)&td);
|
||||||
else
|
else
|
||||||
rv = DO_1PASS_TEST(passwd, &td_snap,
|
rv = DO_1PASS_TEST(passwd, &td_snap,
|
||||||
passwd_test_getpwnam, (void *)&td_snap);
|
passwd_test_getpwnam, (void *)&td_snap);
|
||||||
break;
|
break;
|
||||||
case TEST_GETPWUID:
|
case TEST_GETPWUID:
|
||||||
if (snapshot_file == NULL)
|
if (snapshot_file == NULL)
|
||||||
rv = DO_1PASS_TEST(passwd, &td,
|
rv = DO_1PASS_TEST(passwd, &td,
|
||||||
passwd_test_getpwuid, (void *)&td);
|
passwd_test_getpwuid, (void *)&td);
|
||||||
else
|
else
|
||||||
rv = DO_1PASS_TEST(passwd, &td_snap,
|
rv = DO_1PASS_TEST(passwd, &td_snap,
|
||||||
passwd_test_getpwuid, (void *)&td_snap);
|
passwd_test_getpwuid, (void *)&td_snap);
|
||||||
break;
|
break;
|
||||||
case TEST_GETPWENT:
|
case TEST_GETPWENT:
|
||||||
if (snapshot_file == NULL)
|
if (snapshot_file == NULL)
|
||||||
rv = DO_1PASS_TEST(passwd, &td, passwd_test_getpwent,
|
rv = DO_1PASS_TEST(passwd, &td, passwd_test_getpwent,
|
||||||
(void *)&td);
|
(void *)&td);
|
||||||
else
|
else
|
||||||
rv = DO_2PASS_TEST(passwd, &td, &td_snap,
|
rv = DO_2PASS_TEST(passwd, &td, &td_snap,
|
||||||
compare_passwd, NULL);
|
compare_passwd, NULL);
|
||||||
break;
|
break;
|
||||||
case TEST_GETPWENT_2PASS:
|
case TEST_GETPWENT_2PASS:
|
||||||
TEST_DATA_INIT(passwd, &td_2pass, clone_passwd, free_passwd);
|
TEST_DATA_INIT(passwd, &td_2pass, clone_passwd, free_passwd);
|
||||||
|
@ -325,6 +325,6 @@ __##ent##_2pass_test(struct ent##_test_data *td1, \
|
|||||||
{ \
|
{ \
|
||||||
int rv; \
|
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); \
|
return (rv); \
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user