summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/.cvsignore1
-rw-r--r--tests/Makefile.am6
-rw-r--r--tests/tst-pam_mkargv.c52
3 files changed, 56 insertions, 3 deletions
diff --git a/tests/.cvsignore b/tests/.cvsignore
index 8907f478..d8828fe6 100644
--- a/tests/.cvsignore
+++ b/tests/.cvsignore
@@ -18,3 +18,4 @@ tst-pam_set_data
tst-pam_set_item
tst-pam_setcred
tst-pam_start
+tst-pam_mkargv
diff --git a/tests/Makefile.am b/tests/Makefile.am
index de1594bd..dfe745da 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2006 Thorsten Kukuk <kukuk@suse.de>
+# Copyright (c) 2006, 2009 Thorsten Kukuk <kukuk@suse.de>
#
AM_CFLAGS = -DLIBPAM_COMPILE -I$(top_srcdir)/libpam/include \
@@ -11,9 +11,9 @@ CLEANFILES = *~
TESTS = tst-pam_start tst-pam_end tst-pam_fail_delay tst-pam_open_session \
tst-pam_close_session tst-pam_acct_mgmt tst-pam_authenticate \
tst-pam_chauthtok tst-pam_setcred tst-pam_get_item tst-pam_set_item \
- tst-pam_getenvlist tst-pam_get_user tst-pam_set_data
+ tst-pam_getenvlist tst-pam_get_user tst-pam_set_data \
+ tst-pam_mkargv
check_PROGRAMS = ${TESTS} tst-dlopen
tst_dlopen_LDADD = -ldl
-
diff --git a/tests/tst-pam_mkargv.c b/tests/tst-pam_mkargv.c
new file mode 100644
index 00000000..462875b8
--- /dev/null
+++ b/tests/tst-pam_mkargv.c
@@ -0,0 +1,52 @@
+/*
+ Copyright (C) Thorsten Kukuk <kukuk@suse.de> 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation in version 2 of the License.
+*/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+
+#include "pam_misc.c"
+
+/* Simple program to see if _pam_mkargv() would succeed. */
+int main(void)
+{
+ char *argvstring = "user = XENDT\\userĪ± user=XENDT\\user1";
+ const char *argvresult[] = {"user", "=", "XENDT\\userĪ±",
+ "user=XENDT\\user1"};
+ int myargc;
+ char **myargv;
+ int argvlen;
+ int i;
+
+ argvlen = _pam_mkargv(argvstring, &myargv, &myargc);
+
+#if 0
+ printf ("argvlen=%i, argc=%i", argvlen, myargc);
+ for (i = 0; i < myargc; i++) {
+ printf(", argv[%d]=%s", i, myargv[i]);
+ }
+ printf ("\n");
+#endif
+
+ if (argvlen != 333)
+ return 1;
+
+ if (myargc != 4)
+ return 1;
+
+ for (i = 0; i < 4; i++)
+ {
+ if (strcmp (myargv[i], argvresult[i]) != 0)
+ return 1;
+ }
+
+ return 0;
+}