aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@strace.io>2024-04-03 08:00:00 +0000
committerDmitry V. Levin <ldv@strace.io>2024-04-03 08:00:00 +0000
commit8c3b9402fede30f919a2270f6e72c0773300c314 (patch)
treed9cf95900d087bdc4a809280780449bf836a2c1b /tests
parentf6fe98be3da0d136d6ad255f97d953d22067f48c (diff)
downloadpam-8c3b9402fede30f919a2270f6e72c0773300c314.tar.gz
pam-8c3b9402fede30f919a2270f6e72c0773300c314.tar.bz2
pam-8c3b9402fede30f919a2270f6e72c0773300c314.zip
tests: check pam_get_data PAM_NO_MODULE_DATA return value semantics
* tests/tst-pam_get_data.c (main): Check that PAM_NO_MODULE_DATA is returned by pam_get_data iff the corresponding data is not present.
Diffstat (limited to 'tests')
-rw-r--r--tests/tst-pam_get_data.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/tst-pam_get_data.c b/tests/tst-pam_get_data.c
index 1dd7e408..d2fab9cf 100644
--- a/tests/tst-pam_get_data.c
+++ b/tests/tst-pam_get_data.c
@@ -44,9 +44,10 @@
static void
tst_str_data_cleanup(pam_handle_t *pamh UNUSED, void *data, int error_status)
{
+ const char *q = data ? "\"" : "";
fprintf(stderr,
- "tst_cleanup was called: data=\"%s\", error_status=%d\n",
- (char *)data, error_status);
+ "tst_cleanup was called: data=%s%s%s, error_status=%d\n",
+ q, data ? (char *) data : "NULL", q, error_status);
free(data);
}
@@ -92,6 +93,16 @@ main(void)
ASSERT_EQ(dataptr, constdataptr);
ASSERT_EQ(0, strcmp((const char *) constdataptr, "test3b"));
+ ASSERT_EQ(PAM_SUCCESS,
+ pam_set_data(pamh, "tst-pam_get_data-3", NULL,
+ tst_str_data_cleanup));
+ ASSERT_EQ(PAM_SUCCESS,
+ pam_get_data(pamh, "tst-pam_get_data-3", &constdataptr));
+ ASSERT_EQ(NULL, constdataptr);
+
+ ASSERT_EQ(PAM_NO_MODULE_DATA,
+ pam_get_data(pamh, "tst-pam_get_data-4", &constdataptr));
+
__PAM_TO_APP(pamh);
ASSERT_EQ(PAM_SUCCESS, pam_end(pamh, 987));