Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2008-06-13 23:04:45 +0200
committerArthur de Jong <arthur@arthurdejong.org>2008-06-13 23:04:45 +0200
commitcc1d7f7ff293b73ca521da0f566e65bca5a9fc41 (patch)
treeecfeba107ab75d91894d4ee03efb414f4d6cb9ef /tests
parent8fc785087daefbff19f35cd4e89e30a6d90f3374 (diff)
add some very basic tests for the isvalidname() function
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@760 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am9
-rw-r--r--tests/test_common.c49
2 files changed, 56 insertions, 2 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ef555ad..fb50281 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,10 +19,10 @@
# 02110-1301 USA
TESTS = test_dict test_set test_tio test_cfg test_myldap.sh test_nsscmds.sh \
- test_getpeercred
+ test_getpeercred test_common
check_PROGRAMS = test_dict test_set test_tio test_cfg test_myldap \
- test_getpeercred
+ test_getpeercred test_common
EXTRA_PROGRAMS = test_aliases test_ethers test_group test_hosts \
test_netgroup test_networks test_passwd test_protocols \
@@ -69,6 +69,11 @@ test_myldap_LDADD = ../nslcd/log.o ../nslcd/common.o ../nslcd/cfg.o \
test_getpeercred_SOURCES = test_getpeercred.c
test_getpeercred_LDADD = ../compat/libcompat.a
+test_common_SOURCES = test_common.c
+test_common_LDADD = ../nslcd/log.o ../nslcd/common.o ../nslcd/cfg.o \
+ ../nslcd/myldap.o @nslcd_LIBS@ ../common/libtio.a \
+ ../common/libdict.a ../compat/libcompat.a
+
common_SOURCES = ../nss/common.c ../nslcd.h ../nss/prototypes.h \
../common/tio.c ../common/tio.h
diff --git a/tests/test_common.c b/tests/test_common.c
new file mode 100644
index 0000000..fa70b6d
--- /dev/null
+++ b/tests/test_common.c
@@ -0,0 +1,49 @@
+/*
+ test_common.c - simple test for the common module
+ This file is part of the nss-ldapd library.
+
+ Copyright (C) 2008 Arthur de Jong
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA
+*/
+
+#include "config.h"
+
+#include <stdio.h>
+#include <assert.h>
+
+#include "nslcd/common.h"
+
+/* this is a simple way to get this into an executable */
+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 NULL;}
+const char **attmap_get_var(int UNUSED(map),const char UNUSED(*name)) {return NULL;}
+
+static void test_isvalidname(void)
+{
+ assert(isvalidname("arthur"));
+ assert(!isvalidname("-arthur"));
+ assert(isvalidname("arthur-is-nice"));
+ assert(isvalidname("sambamachine$"));
+}
+
+/* the main program... */
+int main(int UNUSED(argc),char UNUSED(*argv[]))
+{
+ test_isvalidname();
+ return 0;
+}