Adapt to newer versions of the Cryb test framework.

git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@926 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
Dag-Erling Smørgrav 2017-03-23 13:42:56 +00:00
parent 812256e9d1
commit e7f32a97b0
5 changed files with 34 additions and 34 deletions

View File

@ -75,7 +75,7 @@ static const char oc_pfcs[] = OC_PFCS;
crib[(int)oc_##set[i]] = 1; \ crib[(int)oc_##set[i]] = 1; \
for (i = ret = 0; i < sizeof crib; ++i) { \ for (i = ret = 0; i < sizeof crib; ++i) { \
if (is_##set(i) != crib[i]) { \ if (is_##set(i) != crib[i]) { \
t_verbose("is_%s() incorrect " \ t_printv("is_%s() incorrect " \
"for %#02x\n", #set, i); \ "for %#02x\n", #set, i); \
++ret; \ ++ret; \
} \ } \

View File

@ -54,7 +54,7 @@
OPENPAM_UNUSED(void *arg)) OPENPAM_UNUSED(void *arg))
#define T(n) \ #define T(n) \
t_add_test(&t_ ## n ## _func, NULL, t_ ## n ## _desc) t_add_test(&t_ ## n ## _func, NULL, "%s", t_ ## n ## _desc)
const char *pam_return_so; const char *pam_return_so;
@ -73,7 +73,7 @@ T_FUNC(empty_policy, "empty policy")
t_fprintf(tf, "# empty policy\n"); t_fprintf(tf, "# empty policy\n");
pam_err = pam_start(tf->name, "test", &pamc, &pamh); pam_err = pam_start(tf->name, "test", &pamc, &pamh);
if (pam_err != PAM_SUCCESS) { if (pam_err != PAM_SUCCESS) {
t_verbose("pam_start() returned %d\n", pam_err); t_printv("pam_start() returned %d\n", pam_err);
return (0); return (0);
} }
/* /*
@ -82,22 +82,22 @@ T_FUNC(empty_policy, "empty policy")
* instead. * instead.
*/ */
pam_err = pam_authenticate(pamh, 0); pam_err = pam_authenticate(pamh, 0);
t_verbose("pam_authenticate() returned %d\n", pam_err); t_printv("pam_authenticate() returned %d\n", pam_err);
ret = (pam_err == PAM_SYSTEM_ERR); ret = (pam_err == PAM_SYSTEM_ERR);
pam_err = pam_setcred(pamh, 0); pam_err = pam_setcred(pamh, 0);
t_verbose("pam_setcred() returned %d\n", pam_err); t_printv("pam_setcred() returned %d\n", pam_err);
ret &= (pam_err == PAM_SYSTEM_ERR); ret &= (pam_err == PAM_SYSTEM_ERR);
pam_err = pam_acct_mgmt(pamh, 0); pam_err = pam_acct_mgmt(pamh, 0);
t_verbose("pam_acct_mgmt() returned %d\n", pam_err); t_printv("pam_acct_mgmt() returned %d\n", pam_err);
ret &= (pam_err == PAM_SYSTEM_ERR); ret &= (pam_err == PAM_SYSTEM_ERR);
pam_err = pam_chauthtok(pamh, 0); pam_err = pam_chauthtok(pamh, 0);
t_verbose("pam_chauthtok() returned %d\n", pam_err); t_printv("pam_chauthtok() returned %d\n", pam_err);
ret &= (pam_err == PAM_SYSTEM_ERR); ret &= (pam_err == PAM_SYSTEM_ERR);
pam_err = pam_open_session(pamh, 0); pam_err = pam_open_session(pamh, 0);
t_verbose("pam_open_session() returned %d\n", pam_err); t_printv("pam_open_session() returned %d\n", pam_err);
ret &= (pam_err == PAM_SYSTEM_ERR); ret &= (pam_err == PAM_SYSTEM_ERR);
pam_err = pam_close_session(pamh, 0); pam_err = pam_close_session(pamh, 0);
t_verbose("pam_close_session() returned %d\n", pam_err); t_printv("pam_close_session() returned %d\n", pam_err);
ret &= (pam_err == PAM_SYSTEM_ERR); ret &= (pam_err == PAM_SYSTEM_ERR);
pam_end(pamh, pam_err); pam_end(pamh, pam_err);
t_fclose(tf); t_fclose(tf);
@ -150,7 +150,7 @@ T_FUNC(mod_return, "module return value")
} }
pam_err = pam_start(tf->name, "test", &pamc, &pamh); pam_err = pam_start(tf->name, "test", &pamc, &pamh);
if (pam_err != PAM_SUCCESS) { if (pam_err != PAM_SUCCESS) {
t_verbose("pam_start() returned %d\n", pam_err); t_printv("pam_start() returned %d\n", pam_err);
t_fclose(tf); t_fclose(tf);
continue; continue;
} }
@ -174,10 +174,10 @@ T_FUNC(mod_return, "module return value")
pam_err = pam_chauthtok(pamh, tc->flags); pam_err = pam_chauthtok(pamh, tc->flags);
break; break;
} }
t_verbose("%s returned %d\n", t_printv("%s returned %d\n",
pam_func_name[tc->primitive], pam_err); pam_func_name[tc->primitive], pam_err);
pam_end(pamh, pam_err); pam_end(pamh, pam_err);
t_verbose("here\n"); t_printv("here\n");
t_fclose(tf); t_fclose(tf);
} }
return (1); return (1);
@ -196,7 +196,7 @@ t_prepare(int argc, char *argv[])
(void)argv; (void)argv;
if ((pam_return_so = getenv("PAM_RETURN_SO")) == NULL) { if ((pam_return_so = getenv("PAM_RETURN_SO")) == NULL) {
t_verbose("define PAM_RETURN_SO before running these tests\n"); t_printv("define PAM_RETURN_SO before running these tests\n");
return (0); return (0);
} }

View File

@ -52,7 +52,7 @@
OPENPAM_UNUSED(void *arg)) OPENPAM_UNUSED(void *arg))
#define T(n) \ #define T(n) \
t_add_test(&t_ ## n ## _func, NULL, t_ ## n ## _desc) t_add_test(&t_ ## n ## _func, NULL, "%s", t_ ## n ## _desc)
/* /*
* Read a line from the temp file and verify that the result matches our * Read a line from the temp file and verify that the result matches our
@ -76,20 +76,20 @@ orlv_expect(struct t_file *tf, const char **expectedv, int lines, int eof)
if (t_ferror(tf)) if (t_ferror(tf))
err(1, "%s(): %s", __func__, tf->name); err(1, "%s(): %s", __func__, tf->name);
if (expectedv != NULL && gotv == NULL) { if (expectedv != NULL && gotv == NULL) {
t_verbose("expected %d words, got nothing\n", expectedc); t_printv("expected %d words, got nothing\n", expectedc);
ret = 0; ret = 0;
} else if (expectedv == NULL && gotv != NULL) { } else if (expectedv == NULL && gotv != NULL) {
t_verbose("expected nothing, got %d words\n", gotc); t_printv("expected nothing, got %d words\n", gotc);
ret = 0; ret = 0;
} else if (expectedv != NULL && gotv != NULL) { } else if (expectedv != NULL && gotv != NULL) {
if (expectedc != gotc) { if (expectedc != gotc) {
t_verbose("expected %d words, got %d\n", t_printv("expected %d words, got %d\n",
expectedc, gotc); expectedc, gotc);
ret = 0; ret = 0;
} }
for (i = 0; i < gotc; ++i) { for (i = 0; i < gotc; ++i) {
if (strcmp(expectedv[i], gotv[i]) != 0) { if (strcmp(expectedv[i], gotv[i]) != 0) {
t_verbose("word %d: expected <<%s>>, " t_printv("word %d: expected <<%s>>, "
"got <<%s>>\n", i, expectedv[i], gotv[i]); "got <<%s>>\n", i, expectedv[i], gotv[i]);
ret = 0; ret = 0;
} }
@ -97,15 +97,15 @@ orlv_expect(struct t_file *tf, const char **expectedv, int lines, int eof)
} }
FREEV(gotc, gotv); FREEV(gotc, gotv);
if (lineno != lines) { if (lineno != lines) {
t_verbose("expected to advance %d lines, advanced %d lines\n", t_printv("expected to advance %d lines, advanced %d lines\n",
lines, lineno); lines, lineno);
ret = 0; ret = 0;
} }
if (eof && !t_feof(tf)) { if (eof && !t_feof(tf)) {
t_verbose("expected EOF, but didn't get it\n"); t_printv("expected EOF, but didn't get it\n");
ret = 0; ret = 0;
} else if (!eof && t_feof(tf)) { } else if (!eof && t_feof(tf)) {
t_verbose("didn't expect EOF, but got it anyway\n"); t_printv("didn't expect EOF, but got it anyway\n");
ret = 0; ret = 0;
} }
return (ret); return (ret);

View File

@ -51,7 +51,7 @@
OPENPAM_UNUSED(void *arg)) OPENPAM_UNUSED(void *arg))
#define T(n) \ #define T(n) \
t_add_test(&t_ ## n ## _func, NULL, t_ ## n ## _desc) t_add_test(&t_ ## n ## _func, NULL, "%s", t_ ## n ## _desc)
/* /*
* Read a word from the temp file and verify that the result matches our * Read a word from the temp file and verify that the result matches our
@ -72,37 +72,37 @@ orw_expect(struct t_file *tf, const char *expected, int lines, int eof, int eol)
if (t_ferror(tf)) if (t_ferror(tf))
err(1, "%s(): %s", __func__, tf->name); err(1, "%s(): %s", __func__, tf->name);
if (expected != NULL && got == NULL) { if (expected != NULL && got == NULL) {
t_verbose("expected <<%s>>, got nothing\n", expected); t_printv("expected <<%s>>, got nothing\n", expected);
ret = 0; ret = 0;
} else if (expected == NULL && got != NULL) { } else if (expected == NULL && got != NULL) {
t_verbose("expected nothing, got <<%s>>\n", got); t_printv("expected nothing, got <<%s>>\n", got);
ret = 0; ret = 0;
} else if (expected != NULL && got != NULL && strcmp(expected, got) != 0) { } else if (expected != NULL && got != NULL && strcmp(expected, got) != 0) {
t_verbose("expected <<%s>>, got <<%s>>\n", expected, got); t_printv("expected <<%s>>, got <<%s>>\n", expected, got);
ret = 0; ret = 0;
} }
free(got); free(got);
if (lineno != lines) { if (lineno != lines) {
t_verbose("expected to advance %d lines, advanced %d lines\n", t_printv("expected to advance %d lines, advanced %d lines\n",
lines, lineno); lines, lineno);
ret = 0; ret = 0;
} }
if (eof && !t_feof(tf)) { if (eof && !t_feof(tf)) {
t_verbose("expected EOF, but didn't get it\n"); t_printv("expected EOF, but didn't get it\n");
ret = 0; ret = 0;
} }
if (!eof && t_feof(tf)) { if (!eof && t_feof(tf)) {
t_verbose("didn't expect EOF, but got it anyway\n"); t_printv("didn't expect EOF, but got it anyway\n");
ret = 0; ret = 0;
} }
ch = fgetc(tf->file); ch = fgetc(tf->file);
if (t_ferror(tf)) if (t_ferror(tf))
err(1, "%s(): %s", __func__, tf->name); err(1, "%s(): %s", __func__, tf->name);
if (eol && ch != '\n') { if (eol && ch != '\n') {
t_verbose("expected EOL, but didn't get it\n"); t_printv("expected EOL, but didn't get it\n");
ret = 0; ret = 0;
} else if (!eol && ch == '\n') { } else if (!eol && ch == '\n') {
t_verbose("didn't expect EOL, but got it anyway\n"); t_printv("didn't expect EOL, but got it anyway\n");
ret = 0; ret = 0;
} }
if (ch != EOF) if (ch != EOF)

View File

@ -99,16 +99,16 @@ t_pam_conv(int nm, const struct pam_message **msgs,
} }
switch (msgs[i]->msg_style) { switch (msgs[i]->msg_style) {
case PAM_PROMPT_ECHO_OFF: case PAM_PROMPT_ECHO_OFF:
t_verbose("[PAM_PROMPT_ECHO_OFF] %s\n", msgs[i]->msg); t_printv("[PAM_PROMPT_ECHO_OFF] %s\n", msgs[i]->msg);
break; break;
case PAM_PROMPT_ECHO_ON: case PAM_PROMPT_ECHO_ON:
t_verbose("[PAM_PROMPT_ECHO_ON] %s\n", msgs[i]->msg); t_printv("[PAM_PROMPT_ECHO_ON] %s\n", msgs[i]->msg);
break; break;
case PAM_ERROR_MSG: case PAM_ERROR_MSG:
t_verbose("[PAM_ERROR_MSG] %s\n", msgs[i]->msg); t_printv("[PAM_ERROR_MSG] %s\n", msgs[i]->msg);
break; break;
case PAM_TEXT_INFO: case PAM_TEXT_INFO:
t_verbose("[PAM_TEXT_INFO] %s\n", msgs[i]->msg); t_printv("[PAM_TEXT_INFO] %s\n", msgs[i]->msg);
break; break;
default: default:
asprintf(&s->comment, "invalid message style %d", asprintf(&s->comment, "invalid message style %d",