Switch to using the cryb.to project's test framework.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@922 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
parent
890bea99e0
commit
a823b423ca
12
configure.ac
12
configure.ac
|
@ -121,6 +121,18 @@ SYSTEM_LIBPAM="${LIBS}"
|
||||||
LIBS="${saved_LIBS}"
|
LIBS="${saved_LIBS}"
|
||||||
AC_SUBST(SYSTEM_LIBPAM)
|
AC_SUBST(SYSTEM_LIBPAM)
|
||||||
|
|
||||||
|
save_LIBS="${LIBS}"
|
||||||
|
LIBS=""
|
||||||
|
AC_SEARCH_LIBS([cryb_test_version], [cryb-test], [
|
||||||
|
CRYB_TEST_LIBS="${LIBS}"
|
||||||
|
], [
|
||||||
|
CRYB_TEST_LIBS=""
|
||||||
|
AC_MSG_WARN([cryb-test library not available, unit tests disabled])
|
||||||
|
])
|
||||||
|
LIBS="${save_LIBS}"
|
||||||
|
AC_SUBST(CRYB_TEST_LIBS)
|
||||||
|
AM_CONDITIONAL([WITH_TEST], [ test x"$CRYB_TEST_LIBS" != x"" ])
|
||||||
|
|
||||||
AC_ARG_ENABLE([developer-warnings],
|
AC_ARG_ENABLE([developer-warnings],
|
||||||
AS_HELP_STRING([--enable-developer-warnings], [enable strict warnings (default is NO)]),
|
AS_HELP_STRING([--enable-developer-warnings], [enable strict warnings (default is NO)]),
|
||||||
[CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual"])
|
[CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual"])
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
|
if WITH_TEST
|
||||||
|
|
||||||
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/lib/libpam
|
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/lib/libpam
|
||||||
|
|
||||||
AM_TESTS_ENVIRONMENT = \
|
AM_TESTS_ENVIRONMENT = \
|
||||||
PAM_RETURN_SO=$(abs_top_builddir)/modules/pam_return/.libs/pam_return.so
|
PAM_RETURN_SO=$(abs_top_builddir)/modules/pam_return/.libs/pam_return.so
|
||||||
|
|
||||||
noinst_HEADERS = t.h t_pam_conv.h
|
noinst_HEADERS = t_pam_conv.h
|
||||||
|
|
||||||
# tests
|
# tests
|
||||||
TESTS =
|
TESTS =
|
||||||
|
@ -17,12 +19,14 @@ check_PROGRAMS = $(TESTS)
|
||||||
|
|
||||||
# libt - common support code
|
# libt - common support code
|
||||||
check_LIBRARIES = libt.a
|
check_LIBRARIES = libt.a
|
||||||
libt_a_SOURCES = t_main.c t_file.c t_pam_conv.c
|
libt_a_SOURCES = t_pam_conv.c
|
||||||
|
|
||||||
# link with libpam and libt
|
# link with libpam and test framework
|
||||||
LDADD = libt.a
|
LDADD = $(CRYB_TEST_LIBS) libt.a
|
||||||
if WITH_SYSTEM_LIBPAM
|
if WITH_SYSTEM_LIBPAM
|
||||||
LDADD += $(SYSTEM_LIBPAM)
|
LDADD += $(SYSTEM_LIBPAM)
|
||||||
else
|
else
|
||||||
LDADD += $(top_builddir)/lib/libpam/libpam.la
|
LDADD += $(top_builddir)/lib/libpam/libpam.la
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
87
t/t.h
87
t/t.h
|
@ -1,87 +0,0 @@
|
||||||
/*-
|
|
||||||
* Copyright (c) 2012-2016 Dag-Erling Smørgrav
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef T_H_INCLUDED
|
|
||||||
#define T_H_INCLUDED
|
|
||||||
|
|
||||||
#if _BullseyeCoverage
|
|
||||||
_Pragma("BullseyeCoverage save off")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <security/openpam_attr.h>
|
|
||||||
|
|
||||||
struct t_test {
|
|
||||||
int (*func)(void *);
|
|
||||||
const char *desc;
|
|
||||||
void *arg;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define T_FUNC(n, d) \
|
|
||||||
static int t_ ## n ## _func(void *); \
|
|
||||||
static struct t_test t_ ## n = \
|
|
||||||
{ t_ ## n ## _func, d, NULL }; \
|
|
||||||
static int t_ ## n ## _func(OPENPAM_UNUSED(void *arg))
|
|
||||||
|
|
||||||
#define T_FUNC_ARG(n, d, a) \
|
|
||||||
static int t_ ## n ## _func(void *); \
|
|
||||||
static struct t_test t_ ## n = \
|
|
||||||
{ t_ ## n ## _func, d, a }; \
|
|
||||||
static int t_ ## n ## _func(void *arg)
|
|
||||||
|
|
||||||
#define T(n) \
|
|
||||||
&t_ ## n
|
|
||||||
|
|
||||||
extern const char *t_progname;
|
|
||||||
|
|
||||||
struct t_test **t_prepare(int, char **);
|
|
||||||
void t_cleanup(void);
|
|
||||||
|
|
||||||
void t_verbose(const char *, ...)
|
|
||||||
OPENPAM_FORMAT((__printf__, 1, 2));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Convenience functions for temp files
|
|
||||||
*/
|
|
||||||
struct t_file {
|
|
||||||
char *name;
|
|
||||||
FILE *file;
|
|
||||||
struct t_file *prev, *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct t_file *t_fopen(const char *);
|
|
||||||
int t_fprintf(struct t_file *, const char *, ...);
|
|
||||||
int t_ferror(struct t_file *);
|
|
||||||
int t_feof(struct t_file *);
|
|
||||||
void t_frewind(struct t_file *);
|
|
||||||
void t_fclose(struct t_file *);
|
|
||||||
void t_fcloseall(void);
|
|
||||||
|
|
||||||
#endif
|
|
162
t/t_file.c
162
t/t_file.c
|
@ -1,162 +0,0 @@
|
||||||
/*-
|
|
||||||
* Copyright (c) 2012-2016 Dag-Erling Smørgrav
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <err.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "openpam_asprintf.h"
|
|
||||||
|
|
||||||
#include "t.h"
|
|
||||||
|
|
||||||
static struct t_file *tflist;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open a temp file.
|
|
||||||
*/
|
|
||||||
struct t_file *
|
|
||||||
t_fopen(const char *filename)
|
|
||||||
{
|
|
||||||
struct t_file *tf;
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
if ((tf = calloc(sizeof *tf, 1)) == NULL)
|
|
||||||
err(1, "%s(): calloc()", __func__);
|
|
||||||
if (filename) {
|
|
||||||
if ((tf->name = strdup(filename)) == NULL)
|
|
||||||
err(1, "%s(): strdup()", __func__);
|
|
||||||
} else {
|
|
||||||
asprintf(&tf->name, "%s.%lu.%p.tmp",
|
|
||||||
t_progname, (unsigned long)getpid(), (void *)tf);
|
|
||||||
if (tf->name == NULL)
|
|
||||||
err(1, "%s(): asprintf()", __func__);
|
|
||||||
}
|
|
||||||
if ((fd = open(tf->name, O_RDWR|O_CREAT|O_TRUNC, 0600)) < 0)
|
|
||||||
err(1, "%s(): %s", __func__, tf->name);
|
|
||||||
if ((tf->file = fdopen(fd, "r+")) == NULL)
|
|
||||||
err(1, "%s(): fdopen()", __func__);
|
|
||||||
if ((tf->next = tflist) != NULL)
|
|
||||||
tf->next->prev = tf;
|
|
||||||
tflist = tf;
|
|
||||||
return (tf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write text to the temp file.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
t_fprintf(struct t_file *tf, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
len = vfprintf(tf->file, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
if (ferror(tf->file))
|
|
||||||
err(1, "%s(): vfprintf()", __func__);
|
|
||||||
if (fflush(tf->file) != 0)
|
|
||||||
err(1, "%s(): fflush()", __func__);
|
|
||||||
return (len);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Rewind the temp file.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
t_frewind(struct t_file *tf)
|
|
||||||
{
|
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
rewind(tf->file);
|
|
||||||
if (errno != 0)
|
|
||||||
err(1, "%s(): rewind()", __func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return non-zero if an error occurred.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
t_ferror(struct t_file *tf)
|
|
||||||
{
|
|
||||||
|
|
||||||
return (ferror(tf->file));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return non-zero if the end of the file was reached.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
t_feof(struct t_file *tf)
|
|
||||||
{
|
|
||||||
|
|
||||||
return (feof(tf->file));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Close a temp file.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
t_fclose(struct t_file *tf)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (tf == tflist)
|
|
||||||
tflist = tf->next;
|
|
||||||
if (tf->prev)
|
|
||||||
tf->prev->next = tf->next;
|
|
||||||
if (tf->next)
|
|
||||||
tf->next->prev = tf->prev;
|
|
||||||
fclose(tf->file);
|
|
||||||
if (unlink(tf->name) < 0)
|
|
||||||
warn("%s(): unlink()", __func__);
|
|
||||||
free(tf->name);
|
|
||||||
free(tf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* atexit() function to close all remaining files.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
t_fcloseall(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
while (tflist)
|
|
||||||
t_fclose(tflist);
|
|
||||||
}
|
|
130
t/t_main.c
130
t/t_main.c
|
@ -1,130 +0,0 @@
|
||||||
/*-
|
|
||||||
* Copyright (c) 2012-2015 Dag-Erling Smørgrav
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote
|
|
||||||
* products derived from this software without specific prior written
|
|
||||||
* permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <err.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <syslog.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "t.h"
|
|
||||||
|
|
||||||
const char *t_progname;
|
|
||||||
|
|
||||||
static int verbose;
|
|
||||||
|
|
||||||
void
|
|
||||||
t_verbose(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
if (verbose) {
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vfprintf(stderr, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
usage(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
fprintf(stderr, "usage: %s [-v]\n", t_progname);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
struct t_test **t_plan;
|
|
||||||
const char *desc;
|
|
||||||
int n, pass, fail;
|
|
||||||
int opt;
|
|
||||||
|
|
||||||
#ifdef HAVE_SETLOGMASK
|
|
||||||
/* suppress openpam_log() */
|
|
||||||
setlogmask(LOG_UPTO(0));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* make stdout line-buffered to preserve ordering */
|
|
||||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
|
||||||
|
|
||||||
/* clean up temp files in case of premature exit */
|
|
||||||
atexit(t_fcloseall);
|
|
||||||
|
|
||||||
if ((t_progname = strrchr(argv[0], '/')) != NULL)
|
|
||||||
t_progname++; /* one past the slash */
|
|
||||||
else
|
|
||||||
t_progname = argv[0];
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "v")) != -1)
|
|
||||||
switch (opt) {
|
|
||||||
case 'v':
|
|
||||||
verbose = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
/* prepare the test plan */
|
|
||||||
if ((t_plan = t_prepare(argc, argv)) == NULL)
|
|
||||||
errx(1, "no plan\n");
|
|
||||||
|
|
||||||
/* count the tests */
|
|
||||||
for (n = 0; t_plan[n] != NULL; ++n)
|
|
||||||
/* nothing */;
|
|
||||||
printf("1..%d\n", n);
|
|
||||||
|
|
||||||
/* run the tests */
|
|
||||||
for (n = pass = fail = 0; t_plan[n] != NULL; ++n) {
|
|
||||||
desc = t_plan[n]->desc ? t_plan[n]->desc : "no description";
|
|
||||||
if ((*t_plan[n]->func)(t_plan[n]->arg)) {
|
|
||||||
printf("ok %d - %s\n", n + 1, desc);
|
|
||||||
++pass;
|
|
||||||
} else {
|
|
||||||
printf("not ok %d - %s\n", n + 1, desc);
|
|
||||||
++fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* clean up and exit */
|
|
||||||
t_cleanup();
|
|
||||||
exit(fail > 0 ? 1 : 0);
|
|
||||||
}
|
|
|
@ -33,12 +33,13 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "openpam_ctype.h"
|
#include <cryb/test.h>
|
||||||
|
|
||||||
#include "t.h"
|
#include "openpam_ctype.h"
|
||||||
|
|
||||||
#define OC_DIGIT "0123456789"
|
#define OC_DIGIT "0123456789"
|
||||||
#define OC_XDIGIT OC_DIGIT "ABCDEFabcdef"
|
#define OC_XDIGIT OC_DIGIT "ABCDEFabcdef"
|
||||||
|
@ -61,11 +62,14 @@ static const char oc_p[] = OC_P;
|
||||||
static const char oc_pfcs[] = OC_PFCS;
|
static const char oc_pfcs[] = OC_PFCS;
|
||||||
|
|
||||||
#define T_OC(set) \
|
#define T_OC(set) \
|
||||||
T_FUNC(t_oc_##set, "is_" #set) \
|
static int \
|
||||||
|
t_oc_##set(char **desc, void *arg) \
|
||||||
{ \
|
{ \
|
||||||
char crib[256]; \
|
char crib[256]; \
|
||||||
unsigned int i, ret; \
|
unsigned int i, ret; \
|
||||||
\
|
\
|
||||||
|
(void)desc; \
|
||||||
|
(void)arg; \
|
||||||
memset(crib, 0, sizeof crib); \
|
memset(crib, 0, sizeof crib); \
|
||||||
for (i = 0; oc_##set[i]; ++i) \
|
for (i = 0; oc_##set[i]; ++i) \
|
||||||
crib[(int)oc_##set[i]] = 1; \
|
crib[(int)oc_##set[i]] = 1; \
|
||||||
|
@ -78,6 +82,7 @@ static const char oc_pfcs[] = OC_PFCS;
|
||||||
} \
|
} \
|
||||||
return (ret == 0); \
|
return (ret == 0); \
|
||||||
}
|
}
|
||||||
|
#define T_OC_ADD(set) t_add_test(&t_oc_##set, NULL, "is_"#set)
|
||||||
|
|
||||||
T_OC(digit)
|
T_OC(digit)
|
||||||
T_OC(xdigit)
|
T_OC(xdigit)
|
||||||
|
@ -94,29 +99,27 @@ T_OC(pfcs)
|
||||||
* Boilerplate
|
* Boilerplate
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static struct t_test *t_plan[] = {
|
static int
|
||||||
T(t_oc_digit),
|
|
||||||
T(t_oc_xdigit),
|
|
||||||
T(t_oc_upper),
|
|
||||||
T(t_oc_lower),
|
|
||||||
T(t_oc_letter),
|
|
||||||
T(t_oc_lws),
|
|
||||||
T(t_oc_ws),
|
|
||||||
T(t_oc_p),
|
|
||||||
T(t_oc_pfcs),
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
struct t_test **
|
|
||||||
t_prepare(int argc, char *argv[])
|
t_prepare(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
return (t_plan);
|
T_OC_ADD(digit);
|
||||||
|
T_OC_ADD(xdigit);
|
||||||
|
T_OC_ADD(upper);
|
||||||
|
T_OC_ADD(lower);
|
||||||
|
T_OC_ADD(letter);
|
||||||
|
T_OC_ADD(lws);
|
||||||
|
T_OC_ADD(ws);
|
||||||
|
T_OC_ADD(p);
|
||||||
|
T_OC_ADD(pfcs);
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
t_cleanup(void)
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
|
t_main(t_prepare, NULL, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,17 +34,28 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <cryb/test.h>
|
||||||
|
|
||||||
#include <security/pam_appl.h>
|
#include <security/pam_appl.h>
|
||||||
#include <security/openpam.h>
|
#include <security/openpam.h>
|
||||||
|
|
||||||
#include "openpam_impl.h"
|
#include "openpam_impl.h"
|
||||||
#include "t.h"
|
|
||||||
#include "t_pam_conv.h"
|
#include "t_pam_conv.h"
|
||||||
|
|
||||||
|
#define T_FUNC(n, d) \
|
||||||
|
static const char *t_ ## n ## _desc = d; \
|
||||||
|
static int t_ ## n ## _func(OPENPAM_UNUSED(char **desc), \
|
||||||
|
OPENPAM_UNUSED(void *arg))
|
||||||
|
|
||||||
|
#define T(n) \
|
||||||
|
t_add_test(&t_ ## n ## _func, NULL, t_ ## n ## _desc)
|
||||||
|
|
||||||
const char *pam_return_so;
|
const char *pam_return_so;
|
||||||
|
|
||||||
T_FUNC(empty_policy, "empty policy")
|
T_FUNC(empty_policy, "empty policy")
|
||||||
|
@ -72,24 +83,23 @@ T_FUNC(empty_policy, "empty policy")
|
||||||
*/
|
*/
|
||||||
pam_err = pam_authenticate(pamh, 0);
|
pam_err = pam_authenticate(pamh, 0);
|
||||||
t_verbose("pam_authenticate() returned %d\n", pam_err);
|
t_verbose("pam_authenticate() returned %d\n", pam_err);
|
||||||
ret = (pam_err != PAM_SUCCESS);
|
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_verbose("pam_setcred() returned %d\n", pam_err);
|
||||||
ret |= (pam_err != PAM_SUCCESS);
|
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_verbose("pam_acct_mgmt() returned %d\n", pam_err);
|
||||||
ret |= (pam_err != PAM_SUCCESS);
|
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_verbose("pam_chauthtok() returned %d\n", pam_err);
|
||||||
ret |= (pam_err != PAM_SUCCESS);
|
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_verbose("pam_open_session() returned %d\n", pam_err);
|
||||||
ret |= (pam_err != PAM_SUCCESS);
|
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_verbose("pam_close_session() returned %d\n", pam_err);
|
||||||
ret |= (pam_err != PAM_SUCCESS);
|
ret &= (pam_err == PAM_SYSTEM_ERR);
|
||||||
pam_err = pam_end(pamh, pam_err);
|
pam_end(pamh, pam_err);
|
||||||
ret |= (pam_err == PAM_SUCCESS);
|
|
||||||
t_fclose(tf);
|
t_fclose(tf);
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
@ -166,6 +176,8 @@ T_FUNC(mod_return, "module return value")
|
||||||
}
|
}
|
||||||
t_verbose("%s returned %d\n",
|
t_verbose("%s returned %d\n",
|
||||||
pam_func_name[tc->primitive], pam_err);
|
pam_func_name[tc->primitive], pam_err);
|
||||||
|
pam_end(pamh, pam_err);
|
||||||
|
t_verbose("here\n");
|
||||||
t_fclose(tf);
|
t_fclose(tf);
|
||||||
}
|
}
|
||||||
return (1);
|
return (1);
|
||||||
|
@ -176,19 +188,17 @@ T_FUNC(mod_return, "module return value")
|
||||||
* Boilerplate
|
* Boilerplate
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static struct t_test *t_plan[] = {
|
static int
|
||||||
T(empty_policy),
|
|
||||||
T(mod_return),
|
|
||||||
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
struct t_test **
|
|
||||||
t_prepare(int argc, char *argv[])
|
t_prepare(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((pam_return_so = getenv("PAM_RETURN_SO")) == NULL)
|
(void)argc;
|
||||||
return (NULL);
|
(void)argv;
|
||||||
|
|
||||||
|
if ((pam_return_so = getenv("PAM_RETURN_SO")) == NULL) {
|
||||||
|
t_verbose("define PAM_RETURN_SO before running these tests\n");
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
openpam_set_feature(OPENPAM_RESTRICT_MODULE_NAME, 0);
|
openpam_set_feature(OPENPAM_RESTRICT_MODULE_NAME, 0);
|
||||||
openpam_set_feature(OPENPAM_VERIFY_MODULE_FILE, 0);
|
openpam_set_feature(OPENPAM_VERIFY_MODULE_FILE, 0);
|
||||||
|
@ -196,12 +206,15 @@ t_prepare(int argc, char *argv[])
|
||||||
openpam_set_feature(OPENPAM_VERIFY_POLICY_FILE, 0);
|
openpam_set_feature(OPENPAM_VERIFY_POLICY_FILE, 0);
|
||||||
openpam_set_feature(OPENPAM_FALLBACK_TO_OTHER, 0);
|
openpam_set_feature(OPENPAM_FALLBACK_TO_OTHER, 0);
|
||||||
|
|
||||||
(void)argc;
|
T(empty_policy);
|
||||||
(void)argv;
|
T(mod_return);
|
||||||
return (t_plan);
|
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
t_cleanup(void)
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
|
t_main(t_prepare, NULL, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,15 +34,25 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <cryb/test.h>
|
||||||
|
|
||||||
#include <security/pam_appl.h>
|
#include <security/pam_appl.h>
|
||||||
#include <security/openpam.h>
|
#include <security/openpam.h>
|
||||||
|
|
||||||
#include "openpam_impl.h"
|
#include "openpam_impl.h"
|
||||||
#include "t.h"
|
|
||||||
|
#define T_FUNC(n, d) \
|
||||||
|
static const char *t_ ## n ## _desc = d; \
|
||||||
|
static int t_ ## n ## _func(OPENPAM_UNUSED(char **desc), \
|
||||||
|
OPENPAM_UNUSED(void *arg))
|
||||||
|
|
||||||
|
#define T(n) \
|
||||||
|
t_add_test(&t_ ## n ## _func, NULL, 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
|
||||||
|
@ -55,7 +65,9 @@ orlv_expect(struct t_file *tf, const char **expectedv, int lines, int eof)
|
||||||
{
|
{
|
||||||
int expectedc, gotc, i, lineno = 0;
|
int expectedc, gotc, i, lineno = 0;
|
||||||
char **gotv;
|
char **gotv;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = 1;
|
||||||
expectedc = 0;
|
expectedc = 0;
|
||||||
if (expectedv != NULL)
|
if (expectedv != NULL)
|
||||||
while (expectedv[expectedc] != NULL)
|
while (expectedv[expectedc] != NULL)
|
||||||
|
@ -65,44 +77,38 @@ orlv_expect(struct t_file *tf, const char **expectedv, int lines, int eof)
|
||||||
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_verbose("expected %d words, got nothing\n", expectedc);
|
||||||
return (0);
|
ret = 0;
|
||||||
}
|
} else if (expectedv == NULL && gotv != NULL) {
|
||||||
if (expectedv == NULL && gotv != NULL) {
|
|
||||||
t_verbose("expected nothing, got %d words\n", gotc);
|
t_verbose("expected nothing, got %d words\n", gotc);
|
||||||
FREEV(gotc, gotv);
|
ret = 0;
|
||||||
return (0);
|
} else if (expectedv != NULL && gotv != NULL) {
|
||||||
}
|
|
||||||
if (expectedv != NULL && gotv != NULL) {
|
|
||||||
if (expectedc != gotc) {
|
if (expectedc != gotc) {
|
||||||
t_verbose("expected %d words, got %d\n",
|
t_verbose("expected %d words, got %d\n",
|
||||||
expectedc, gotc);
|
expectedc, gotc);
|
||||||
FREEV(gotc, gotv);
|
ret = 0;
|
||||||
return (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_verbose("word %d: expected <<%s>>, "
|
||||||
"got <<%s>>\n", i, expectedv[i], gotv[i]);
|
"got <<%s>>\n", i, expectedv[i], gotv[i]);
|
||||||
FREEV(gotc, gotv);
|
ret = 0;
|
||||||
return (0);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FREEV(gotc, gotv);
|
FREEV(gotc, gotv);
|
||||||
}
|
|
||||||
if (lineno != lines) {
|
if (lineno != lines) {
|
||||||
t_verbose("expected to advance %d lines, advanced %d lines\n",
|
t_verbose("expected to advance %d lines, advanced %d lines\n",
|
||||||
lines, lineno);
|
lines, lineno);
|
||||||
return (0);
|
ret = 0;
|
||||||
}
|
}
|
||||||
if (eof && !t_feof(tf)) {
|
if (eof && !t_feof(tf)) {
|
||||||
t_verbose("expected EOF, but didn't get it\n");
|
t_verbose("expected EOF, but didn't get it\n");
|
||||||
return (0);
|
ret = 0;
|
||||||
}
|
} else if (!eof && t_feof(tf)) {
|
||||||
if (!eof && t_feof(tf)) {
|
|
||||||
t_verbose("didn't expect EOF, but got it anyway\n");
|
t_verbose("didn't expect EOF, but got it anyway\n");
|
||||||
return (0);
|
ret = 0;
|
||||||
}
|
}
|
||||||
return (1);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -302,33 +308,32 @@ T_FUNC(unterminated_line, "unterminated line")
|
||||||
* Boilerplate
|
* Boilerplate
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static struct t_test *t_plan[] = {
|
static int
|
||||||
T(empty_input),
|
|
||||||
T(empty_line),
|
|
||||||
T(unterminated_empty_line),
|
|
||||||
T(whitespace),
|
|
||||||
T(comment),
|
|
||||||
T(whitespace_before_comment),
|
|
||||||
T(line_continuation_within_whitespace),
|
|
||||||
|
|
||||||
T(one_word),
|
|
||||||
T(two_words),
|
|
||||||
T(many_words),
|
|
||||||
T(unterminated_line),
|
|
||||||
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
struct t_test **
|
|
||||||
t_prepare(int argc, char *argv[])
|
t_prepare(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
return (t_plan);
|
|
||||||
|
T(empty_input);
|
||||||
|
T(empty_line);
|
||||||
|
T(unterminated_empty_line);
|
||||||
|
T(whitespace);
|
||||||
|
T(comment);
|
||||||
|
T(whitespace_before_comment);
|
||||||
|
T(line_continuation_within_whitespace);
|
||||||
|
|
||||||
|
T(one_word);
|
||||||
|
T(two_words);
|
||||||
|
T(many_words);
|
||||||
|
T(unterminated_line);
|
||||||
|
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
t_cleanup(void)
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
|
t_main(t_prepare, NULL, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,10 +39,18 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <cryb/test.h>
|
||||||
|
|
||||||
#include <security/pam_appl.h>
|
#include <security/pam_appl.h>
|
||||||
#include <security/openpam.h>
|
#include <security/openpam.h>
|
||||||
|
|
||||||
#include "t.h"
|
#define T_FUNC(n, d) \
|
||||||
|
static const char *t_ ## n ## _desc = d; \
|
||||||
|
static int t_ ## n ## _func(OPENPAM_UNUSED(char **desc), \
|
||||||
|
OPENPAM_UNUSED(void *arg))
|
||||||
|
|
||||||
|
#define T(n) \
|
||||||
|
t_add_test(&t_ ## n ## _func, NULL, 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
|
||||||
|
@ -56,49 +64,49 @@ orw_expect(struct t_file *tf, const char *expected, int lines, int eof, int eol)
|
||||||
int ch, lineno = 0;
|
int ch, lineno = 0;
|
||||||
char *got;
|
char *got;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
int ret;
|
||||||
|
|
||||||
got = openpam_readword(tf->file, &lineno, &len);
|
got = openpam_readword(tf->file, &lineno, &len);
|
||||||
|
ret = 1;
|
||||||
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_verbose("expected <<%s>>, got nothing\n", expected);
|
||||||
return (0);
|
ret = 0;
|
||||||
}
|
} else if (expected == NULL && got != NULL) {
|
||||||
if (expected == NULL && got != NULL) {
|
|
||||||
t_verbose("expected nothing, got <<%s>>\n", got);
|
t_verbose("expected nothing, got <<%s>>\n", got);
|
||||||
return (0);
|
ret = 0;
|
||||||
}
|
} else if (expected != NULL && got != NULL && strcmp(expected, got) != 0) {
|
||||||
if (expected != NULL && got != NULL && strcmp(expected, got) != 0) {
|
|
||||||
t_verbose("expected <<%s>>, got <<%s>>\n", expected, got);
|
t_verbose("expected <<%s>>, got <<%s>>\n", expected, got);
|
||||||
return (0);
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
free(got);
|
||||||
if (lineno != lines) {
|
if (lineno != lines) {
|
||||||
t_verbose("expected to advance %d lines, advanced %d lines\n",
|
t_verbose("expected to advance %d lines, advanced %d lines\n",
|
||||||
lines, lineno);
|
lines, lineno);
|
||||||
return (0);
|
ret = 0;
|
||||||
}
|
}
|
||||||
if (eof && !t_feof(tf)) {
|
if (eof && !t_feof(tf)) {
|
||||||
t_verbose("expected EOF, but didn't get it\n");
|
t_verbose("expected EOF, but didn't get it\n");
|
||||||
return (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_verbose("didn't expect EOF, but got it anyway\n");
|
||||||
return (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_verbose("expected EOL, but didn't get it\n");
|
||||||
return (0);
|
ret = 0;
|
||||||
}
|
} else if (!eol && ch == '\n') {
|
||||||
if (!eol && ch == '\n') {
|
|
||||||
t_verbose("didn't expect EOL, but got it anyway\n");
|
t_verbose("didn't expect EOL, but got it anyway\n");
|
||||||
return (0);
|
ret = 0;
|
||||||
}
|
}
|
||||||
if (ch != EOF)
|
if (ch != EOF)
|
||||||
ungetc(ch, tf->file);
|
ungetc(ch, tf->file);
|
||||||
return (1);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -949,86 +957,85 @@ T_FUNC(line_continuation_within_word, "line continuation within word")
|
||||||
* Boilerplate
|
* Boilerplate
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static struct t_test *t_plan[] = {
|
static int
|
||||||
T(empty_input),
|
|
||||||
T(empty_line),
|
|
||||||
T(unterminated_line),
|
|
||||||
T(single_whitespace),
|
|
||||||
T(multiple_whitespace),
|
|
||||||
T(comment),
|
|
||||||
T(whitespace_before_comment),
|
|
||||||
T(single_quoted_comment),
|
|
||||||
T(double_quoted_comment),
|
|
||||||
T(comment_at_eof),
|
|
||||||
|
|
||||||
T(single_word),
|
|
||||||
T(single_whitespace_before_word),
|
|
||||||
T(double_whitespace_before_word),
|
|
||||||
T(single_whitespace_after_word),
|
|
||||||
T(double_whitespace_after_word),
|
|
||||||
T(comment_after_word),
|
|
||||||
T(word_containing_hash),
|
|
||||||
T(two_words),
|
|
||||||
|
|
||||||
T(naked_escape),
|
|
||||||
T(escaped_escape),
|
|
||||||
T(escaped_whitespace),
|
|
||||||
T(escaped_newline_before_word),
|
|
||||||
T(escaped_newline_within_word),
|
|
||||||
T(escaped_newline_after_word),
|
|
||||||
T(escaped_letter),
|
|
||||||
T(escaped_comment),
|
|
||||||
T(escape_at_eof),
|
|
||||||
|
|
||||||
T(naked_single_quote),
|
|
||||||
T(naked_double_quote),
|
|
||||||
T(empty_single_quotes),
|
|
||||||
T(empty_double_quotes),
|
|
||||||
T(single_quotes_within_double_quotes),
|
|
||||||
T(double_quotes_within_single_quotes),
|
|
||||||
T(single_quoted_whitespace),
|
|
||||||
T(double_quoted_whitespace),
|
|
||||||
T(single_quoted_words),
|
|
||||||
T(double_quoted_words),
|
|
||||||
|
|
||||||
T(single_quote_before_word),
|
|
||||||
T(double_quote_before_word),
|
|
||||||
T(single_quote_within_word),
|
|
||||||
T(double_quote_within_word),
|
|
||||||
T(single_quote_after_word),
|
|
||||||
T(double_quote_after_word),
|
|
||||||
|
|
||||||
T(escaped_single_quote),
|
|
||||||
T(escaped_double_quote),
|
|
||||||
T(escaped_whitespace_within_single_quotes),
|
|
||||||
T(escaped_whitespace_within_double_quotes),
|
|
||||||
T(escaped_letter_within_single_quotes),
|
|
||||||
T(escaped_letter_within_double_quotes),
|
|
||||||
T(escaped_escape_within_single_quotes),
|
|
||||||
T(escaped_escape_within_double_quotes),
|
|
||||||
T(escaped_single_quote_within_single_quotes),
|
|
||||||
T(escaped_double_quote_within_single_quotes),
|
|
||||||
T(escaped_single_quote_within_double_quotes),
|
|
||||||
T(escaped_double_quote_within_double_quotes),
|
|
||||||
|
|
||||||
T(line_continuation_within_whitespace),
|
|
||||||
T(line_continuation_before_whitespace),
|
|
||||||
T(line_continuation_after_whitespace),
|
|
||||||
T(line_continuation_within_word),
|
|
||||||
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
struct t_test **
|
|
||||||
t_prepare(int argc, char *argv[])
|
t_prepare(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
return (t_plan);
|
|
||||||
|
T(empty_input);
|
||||||
|
T(empty_line);
|
||||||
|
T(unterminated_line);
|
||||||
|
T(single_whitespace);
|
||||||
|
T(multiple_whitespace);
|
||||||
|
T(comment);
|
||||||
|
T(whitespace_before_comment);
|
||||||
|
T(single_quoted_comment);
|
||||||
|
T(double_quoted_comment);
|
||||||
|
T(comment_at_eof);
|
||||||
|
|
||||||
|
T(single_word);
|
||||||
|
T(single_whitespace_before_word);
|
||||||
|
T(double_whitespace_before_word);
|
||||||
|
T(single_whitespace_after_word);
|
||||||
|
T(double_whitespace_after_word);
|
||||||
|
T(comment_after_word);
|
||||||
|
T(word_containing_hash);
|
||||||
|
T(two_words);
|
||||||
|
|
||||||
|
T(naked_escape);
|
||||||
|
T(escaped_escape);
|
||||||
|
T(escaped_whitespace);
|
||||||
|
T(escaped_newline_before_word);
|
||||||
|
T(escaped_newline_within_word);
|
||||||
|
T(escaped_newline_after_word);
|
||||||
|
T(escaped_letter);
|
||||||
|
T(escaped_comment);
|
||||||
|
T(escape_at_eof);
|
||||||
|
|
||||||
|
T(naked_single_quote);
|
||||||
|
T(naked_double_quote);
|
||||||
|
T(empty_single_quotes);
|
||||||
|
T(empty_double_quotes);
|
||||||
|
T(single_quotes_within_double_quotes);
|
||||||
|
T(double_quotes_within_single_quotes);
|
||||||
|
T(single_quoted_whitespace);
|
||||||
|
T(double_quoted_whitespace);
|
||||||
|
T(single_quoted_words);
|
||||||
|
T(double_quoted_words);
|
||||||
|
|
||||||
|
T(single_quote_before_word);
|
||||||
|
T(double_quote_before_word);
|
||||||
|
T(single_quote_within_word);
|
||||||
|
T(double_quote_within_word);
|
||||||
|
T(single_quote_after_word);
|
||||||
|
T(double_quote_after_word);
|
||||||
|
|
||||||
|
T(escaped_single_quote);
|
||||||
|
T(escaped_double_quote);
|
||||||
|
T(escaped_whitespace_within_single_quotes);
|
||||||
|
T(escaped_whitespace_within_double_quotes);
|
||||||
|
T(escaped_letter_within_single_quotes);
|
||||||
|
T(escaped_letter_within_double_quotes);
|
||||||
|
T(escaped_escape_within_single_quotes);
|
||||||
|
T(escaped_escape_within_double_quotes);
|
||||||
|
T(escaped_single_quote_within_single_quotes);
|
||||||
|
T(escaped_double_quote_within_single_quotes);
|
||||||
|
T(escaped_single_quote_within_double_quotes);
|
||||||
|
T(escaped_double_quote_within_double_quotes);
|
||||||
|
|
||||||
|
T(line_continuation_within_whitespace);
|
||||||
|
T(line_continuation_before_whitespace);
|
||||||
|
T(line_continuation_after_whitespace);
|
||||||
|
T(line_continuation_within_word);
|
||||||
|
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
t_cleanup(void)
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
|
t_main(t_prepare, NULL, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,16 +35,18 @@
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <cryb/test.h>
|
||||||
|
|
||||||
#include <security/pam_appl.h>
|
#include <security/pam_appl.h>
|
||||||
#include <security/openpam.h>
|
#include <security/openpam.h>
|
||||||
|
|
||||||
#include "openpam_impl.h"
|
#include "openpam_impl.h"
|
||||||
#include "openpam_asprintf.h"
|
#include "openpam_asprintf.h"
|
||||||
#include "t.h"
|
|
||||||
|
|
||||||
#include "t_pam_conv.h"
|
#include "t_pam_conv.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue