From 9d453f1e8b28983b363b44c49b7cd701a994fd97 Mon Sep 17 00:00:00 2001 From: Nikolai Kondrashov Date: Mon, 24 Nov 2014 19:13:16 +0200 Subject: Add integration tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add "intgcheck" make target. Update CI to use it. The "intgcheck" target configures and builds sssd in a sub-directory, installs it into a prefix in another sub-directory, and then makes the "intgcheck-installed" target from within src/tests/intg in that separate build. The "intgcheck-installed" target in src/tests/intg runs py.test for all tests it can find in that directory, under fakeroot and nss_wrapper/uid_wrapper environments emulating running under root. It also adds the value of INTGCHECK_PYTEST_ARGS environment/make variable to the py.test command line. You can use it to pass additional py.test options, such as specifying a subset of tests to run. See "py.test --help" output. There are only two test suites in src/tests/intg at the moment: ent_test.py and ldap_test.py. The ent_test.py runs tests on ent.py - a module of assertion functions for checking entries in NSS database (passwd and group), for use in actual tests. The ent_test.py suite can be used as ent.py usage reference. The ldap_test.py suite sets up and starts a slapd instance, adds a few user and group entries, configures and starts sssd and verifies that those users and groups are retrieved correctly using various NSS functions. The tests are very basic at the moment. Reviewed-by: Lukáš Slebodník Reviewed-by: Michal Židek --- src/external/cwrap.m4 | 7 +++---- src/external/intgcheck.m4 | 32 ++++++++++++++++++++++++++++++++ src/external/ldap.m4 | 4 ++++ 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 src/external/intgcheck.m4 (limited to 'src/external') diff --git a/src/external/cwrap.m4 b/src/external/cwrap.m4 index 0bd0bc9c9..b03d1ef00 100644 --- a/src/external/cwrap.m4 +++ b/src/external/cwrap.m4 @@ -4,20 +4,19 @@ dnl AM_CHECK_WRAPPER(name, conditional) dnl If the cwrap library is found, sets the HAVE_$name conditional AC_DEFUN([AM_CHECK_WRAPPER], [ - FOUND_WRAPPER=0 - AC_MSG_CHECKING([for $1]) PKG_CHECK_EXISTS([$1], [ AC_MSG_RESULT([yes]) - FOUND_WRAPPER=1 + AC_SUBST([$2], [yes]) ], [ AC_MSG_RESULT([no]) + AC_SUBST([$2], [no]) AC_MSG_WARN([cwrap library $1 not found, some tests will not run]) ]) - AM_CONDITIONAL($2, [ test x$FOUND_WRAPPER = x1]) + AM_CONDITIONAL($2, [ test x$2 = xyes]) ]) AC_DEFUN([AM_CHECK_UID_WRAPPER], diff --git a/src/external/intgcheck.m4 b/src/external/intgcheck.m4 new file mode 100644 index 000000000..80d41b599 --- /dev/null +++ b/src/external/intgcheck.m4 @@ -0,0 +1,32 @@ +AC_CHECK_PROG([HAVE_FAKEROOT], [fakeroot], [yes], [no]) + +AC_PATH_PROG([PYTEST], [py.test]) +AS_IF([test -n "$PYTEST"], [HAVE_PYTEST=yes], [HAVE_PYTEST=no]) + +dnl Check for variable and fail unless value is "yes" +dnl The second argument will be printed in error message in case of error +dnl Usage: +dnl SSS_INTGCHECK_REQ(variable, message) + +AC_DEFUN([SSS_INTGCHECK_REQ], [ + AS_IF([test x$$1 = xyes], , [ + AC_MSG_ERROR([cannot enable integration tests: $2 not found])]) +]) + +AC_DEFUN([SSS_ENABLE_INTGCHECK_REQS], [ + AC_ARG_ENABLE(intgcheck-reqs, + [AS_HELP_STRING([--enable-intgcheck-reqs], + [enable checking for integration test requirements [default=no]])], + [enable_intgcheck_reqs="$enableval"], + [enable_intgcheck_reqs="no"]) + if test x"$enable_intgcheck_reqs" = xyes; then + SSS_INTGCHECK_REQ([HAVE_UID_WRAPPER], [uid_wrapper]) + SSS_INTGCHECK_REQ([HAVE_NSS_WRAPPER], [nss_wrapper]) + SSS_INTGCHECK_REQ([HAVE_SLAPD], [slapd]) + SSS_INTGCHECK_REQ([HAVE_LDAPMODIFY], [ldapmodify]) + SSS_INTGCHECK_REQ([HAVE_FAKEROOT], [fakeroot]) + SSS_INTGCHECK_REQ([HAVE_PYTHON2], [python2]) + SSS_INTGCHECK_REQ([HAVE_PYTEST], [pytest]) + SSS_INTGCHECK_REQ([HAVE_PY2MOD_LDAP], [python-ldap]) + fi +]) diff --git a/src/external/ldap.m4 b/src/external/ldap.m4 index 3a99ddfcc..43a01efae 100644 --- a/src/external/ldap.m4 +++ b/src/external/ldap.m4 @@ -90,3 +90,7 @@ AC_CHECK_TYPE([LDAPDerefRes], CFLAGS=$SAVE_CFLAGS LIBS=$SAVE_LIBS +AC_PATH_PROG([SLAPD], [slapd], , + [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR]) +AS_IF([test -n "$SLAPD"], [HAVE_SLAPD=yes], [HAVE_SLAPD=no]) +AC_CHECK_PROG([HAVE_LDAPMODIFY], [ldapmodify], [yes], [no]) -- cgit