Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am52
-rw-r--r--tests/test_cfg.c1
-rw-r--r--tests/test_common.c20
-rw-r--r--tests/test_myldap.c12
4 files changed, 36 insertions, 49 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f132208..2d6c3a4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -18,11 +18,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
-TESTS = test_dict test_set test_tio test_cfg test_myldap.sh test_nsscmds.sh \
- test_pamcmds.sh test_getpeercred test_common test_expr
+TESTS = test_dict test_set test_tio test_expr test_getpeercred test_cfg \
+ test_myldap.sh test_common test_nsscmds.sh test_pamcmds.sh
-check_PROGRAMS = test_dict test_set test_tio test_cfg test_myldap \
- test_getpeercred test_common test_expr
+check_PROGRAMS = test_dict test_set test_tio test_expr test_getpeercred \
+ test_cfg test_myldap test_common
EXTRA_DIST = nslcd-test.conf test_myldap.sh test_nsscmds.sh test_pamcmds.sh \
in_testenv.sh test_pamcmds.expect usernames.txt
@@ -47,36 +47,28 @@ test_set_LDADD = ../common/libdict.a
test_tio_SOURCES = test_tio.c ../common/tio.h ../common/tio.c
test_tio_LDFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)
-test_cfg_SOURCES = test_cfg.c
-test_cfg_LDADD = ../nslcd/log.o ../nslcd/attmap.o \
- ../nslcd/common.o ../nslcd/myldap.o \
- ../nslcd/alias.o ../nslcd/ether.o ../nslcd/group.o \
- ../nslcd/host.o ../nslcd/netgroup.o ../nslcd/network.o \
- ../nslcd/passwd.o ../nslcd/protocol.o ../nslcd/rpc.o \
- ../nslcd/service.o ../nslcd/shadow.o \
- @nslcd_LIBS@ ../common/libtio.a ../common/libdict.a \
- ../common/libexpr.a ../compat/libcompat.a
-
test_expr_SOURCES = test_expr.c
test_expr_LDADD = ../common/set.o ../common/dict.o
-test_myldap_SOURCES = test_myldap.c
-test_myldap_LDADD = ../nslcd/log.o ../nslcd/common.o ../nslcd/cfg.o \
- ../nslcd/alias.o ../nslcd/ether.o ../nslcd/group.o \
- ../nslcd/host.o ../nslcd/netgroup.o ../nslcd/network.o \
- ../nslcd/passwd.o ../nslcd/protocol.o ../nslcd/rpc.o \
- ../nslcd/service.o ../nslcd/shadow.o \
- ../nslcd/myldap.o @nslcd_LIBS@ ../common/libtio.a \
- ../common/libdict.a ../compat/libcompat.a
-
test_getpeercred_SOURCES = test_getpeercred.c
test_getpeercred_LDADD = ../compat/libcompat.a
+# common objects that are included for the tests of nslcd functionality
+common_nslcd_LDADD = ../nslcd/log.o ../nslcd/common.o \
+ ../nslcd/myldap.o ../nslcd/attmap.o \
+ ../nslcd/alias.o ../nslcd/ether.o ../nslcd/group.o \
+ ../nslcd/host.o ../nslcd/netgroup.o ../nslcd/network.o \
+ ../nslcd/passwd.o ../nslcd/protocol.o ../nslcd/rpc.o \
+ ../nslcd/service.o ../nslcd/shadow.o ../nslcd/pam.o \
+ @nslcd_LIBS@ @PTHREAD_LIBS@ ../common/libtio.a \
+ ../common/libdict.a ../common/libexpr.a \
+ ../compat/libcompat.a
+
+test_cfg_SOURCES = test_cfg.c
+test_cfg_LDADD = $(common_nslcd_LDADD)
+
+test_myldap_SOURCES = test_myldap.c
+test_myldap_LDADD = ../nslcd/cfg.o $(common_nslcd_LDADD)
+
test_common_SOURCES = test_common.c
-test_common_LDADD = ../nslcd/log.o ../nslcd/common.o \
- ../nslcd/alias.o ../nslcd/ether.o ../nslcd/group.o \
- ../nslcd/host.o ../nslcd/netgroup.o ../nslcd/network.o \
- ../nslcd/passwd.o ../nslcd/protocol.o ../nslcd/rpc.o \
- ../nslcd/service.o ../nslcd/shadow.o ../nslcd/attmap.o \
- ../nslcd/myldap.o @nslcd_LIBS@ ../common/libtio.a \
- ../common/libdict.a ../common/libexpr.a ../compat/libcompat.a
+test_common_LDADD = ../nslcd/cfg.o $(common_nslcd_LDADD)
diff --git a/tests/test_cfg.c b/tests/test_cfg.c
index 810d024..ed6e8f1 100644
--- a/tests/test_cfg.c
+++ b/tests/test_cfg.c
@@ -83,7 +83,6 @@ static void test_parse_boolean(void)
assert(parse_boolean(__FILE__,__LINE__,"Foo")==0); */
}
-
static void test_parse_scope(void)
{
assert(parse_scope(__FILE__,__LINE__,"sUb")==LDAP_SCOPE_SUBTREE);
diff --git a/tests/test_common.c b/tests/test_common.c
index ee96733..6911108 100644
--- a/tests/test_common.c
+++ b/tests/test_common.c
@@ -27,10 +27,7 @@
#include "nslcd/common.h"
#include "nslcd/cfg.h"
-
-/* we include nslcd/cfg.c here to use cfg_defaults() to set the default
- regular expression used in test_isvalidname() */
-#include "nslcd/cfg.c"
+#include "nslcd/log.h"
static void test_isvalidname(void)
{
@@ -46,8 +43,19 @@ static void test_isvalidname(void)
/* the main program... */
int main(int UNUSED(argc),char UNUSED(*argv[]))
{
- nslcd_cfg=(struct ldap_config *)malloc(sizeof(struct ldap_config));
- cfg_defaults(nslcd_cfg);
+ char *srcdir;
+ char fname[100];
+ /* build the name of the file */
+ srcdir=getenv("srcdir");
+ if (srcdir==NULL)
+ srcdir=".";
+ snprintf(fname,sizeof(fname),"%s/nslcd-test.conf",srcdir);
+ fname[sizeof(fname)-1]='\0';
+ /* initialize configuration */
+ cfg_init(fname);
+ /* partially initialize logging */
+ log_setdefaultloglevel(LOG_DEBUG);
+ /* run the tests */
test_isvalidname();
return 0;
}
diff --git a/tests/test_myldap.c b/tests/test_myldap.c
index 6295118..6465538 100644
--- a/tests/test_myldap.c
+++ b/tests/test_myldap.c
@@ -39,18 +39,6 @@ struct worker_args {
int id;
};
-static const char *foo="";
-
-/* this is a simple way to get this into an executable,
- we should probably read a valid config instead */
-const char **base_get_var(int UNUSED(map)) {return NULL;}
-int *scope_get_var(int UNUSED(map)) {return NULL;}
-const char **filter_get_var(int UNUSED(map)) {return &foo;}
-const char **attmap_get_var(int UNUSED(map),const char UNUSED(*name)) {return &foo;}
-const char *attmap_get_value(MYLDAP_ENTRY UNUSED(*entry),const char UNUSED(*attr),char UNUSED(*buffer),size_t UNUSED(buflen)) {return "";}
-void *attmap_add_attributes(void UNUSED(*set),const char UNUSED(*attr)) {return NULL;}
-const char *attmap_set_mapping(const char UNUSED(**var),const char UNUSED(*value)) {return NULL;}
-
/* the maxium number of results to print (all results are retrieved) */
#define MAXRESULTS 10