nss-pam-ldapd commit: r1397 - in nss-pam-ldapd: . tests
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
nss-pam-ldapd commit: r1397 - in nss-pam-ldapd: . tests
- From: Commits of the nss-pam-ldapd project <nss-pam-ldapd-commits [at] lists.arthurdejong.org>
- To: nss-pam-ldapd-commits [at] lists.arthurdejong.org
- Reply-to: nss-pam-ldapd-users [at] lists.arthurdejong.org
- Subject: nss-pam-ldapd commit: r1397 - in nss-pam-ldapd: . tests
- Date: Thu, 17 Mar 2011 22:02:48 +0100 (CET)
Author: arthur
Date: Thu Mar 17 22:02:45 2011
New Revision: 1397
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?view=rev&revision=1397
Log:
put all assertion functions and compatibility code into one header file
Added:
nss-pam-ldapd/tests/common.h
Modified:
nss-pam-ldapd/configure.ac
nss-pam-ldapd/tests/Makefile.am
nss-pam-ldapd/tests/test_cfg.c
nss-pam-ldapd/tests/test_common.c
nss-pam-ldapd/tests/test_expr.c
nss-pam-ldapd/tests/test_getpeercred.c
nss-pam-ldapd/tests/test_myldap.c
nss-pam-ldapd/tests/test_tio.c
Modified: nss-pam-ldapd/configure.ac
==============================================================================
--- nss-pam-ldapd/configure.ac Thu Mar 17 22:01:14 2011 (r1396)
+++ nss-pam-ldapd/configure.ac Thu Mar 17 22:02:45 2011 (r1397)
@@ -292,6 +292,7 @@
AC_CHECK_FUNCS([strcasecmp strncasecmp strchr strcspn strspn strtol])
AC_CHECK_FUNCS([malloc realloc])
AC_FUNC_FORK
+AC_CHECK_FUNCS(__assert_fail)
# checks for types
AC_TYPE_MODE_T
Modified: nss-pam-ldapd/tests/Makefile.am
==============================================================================
--- nss-pam-ldapd/tests/Makefile.am Thu Mar 17 22:01:14 2011 (r1396)
+++ nss-pam-ldapd/tests/Makefile.am Thu Mar 17 22:02:45 2011 (r1397)
@@ -76,6 +76,6 @@
../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/service.o ../nslcd/shadow.o ../nslcd/attmap.o \
../nslcd/myldap.o @nslcd_LIBS@ ../common/libtio.a \
- ../common/libdict.a ../compat/libcompat.a
+ ../common/libdict.a ../common/libexpr.a
../compat/libcompat.a
Added: nss-pam-ldapd/tests/common.h
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ nss-pam-ldapd/tests/common.h Thu Mar 17 22:02:45 2011 (r1397)
@@ -0,0 +1,69 @@
+/*
+ common.h - common test routines
+ This file is part of the nss-pam-ldapd library.
+
+ Copyright (C) 2011 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
+*/
+
+#ifndef TEST__COMMON_H
+#define TEST__COMMON_H 1
+
+#include <errno.h>
+
+#ifndef __ASSERT_FUNCTION
+#define __ASSERT_FUNCTION ""
+#endif /* not __ASSERT_FUNCTION */
+
+/* try to find the actual assert function */
+#ifndef HAVE___ASSERT_FAIL
+/* for Solaris: */
+#define __assert_fail(assertion,file,line,function)
__assert(assertion,file,line)
+#endif /* not HAVE___ASSERT_FAIL */
+
+/* extra assertion function that epxects both strings to be the same
+ (special macro because strcmp() can be a macro that turns ugly in assert) */
+#define assertstreq(str1,str2) \
+ (assertstreq_impl(str1,str2,"strcmp(" __STRING(str1) "," __STRING(str2)
")==0", \
+ __FILE__, __LINE__, __ASSERT_FUNCTION))
+
+static inline void assertstreq_impl(const char *str1,const char *str2,
+ const char *assertion,const char *file,
+ int line,const char *function)
+{
+ if (strcmp(str1,str2)!=0)
+ __assert_fail(assertion,file,line,function);
+}
+
+/* extra assertion function that expects expr to be valid and prints an
+ error message that include errno otherwise */
+#define assertok(expr) \
+ ((expr) \
+ ? (void) (0) \
+ : __assertok_fail(__STRING(expr),__FILE__,__LINE__,__ASSERT_FUNCTION))
+
+
+static inline void __assertok_fail(const char *expr,const char *file,
+ int line,const char *function)
+{
+ char msg[120];
+ snprintf(msg,sizeof(msg),"%s (errno=\"%s\")",expr,strerror(errno));
+ __assert_fail(msg,file,line,function);
+}
+
+
+#endif /* not TEST__COMMON_H */
Modified: nss-pam-ldapd/tests/test_cfg.c
==============================================================================
--- nss-pam-ldapd/tests/test_cfg.c Thu Mar 17 22:01:14 2011 (r1396)
+++ nss-pam-ldapd/tests/test_cfg.c Thu Mar 17 22:02:45 2011 (r1397)
@@ -2,7 +2,7 @@
test_cfg.c - simple test for the cfg module
This file is part of the nss-pam-ldapd library.
- Copyright (C) 2007, 2009 Arthur de Jong
+ Copyright (C) 2007, 2009, 2011 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
@@ -26,29 +26,11 @@
#include <string.h>
#include <assert.h>
+#include "common.h"
+
/* we include cfg.c because we want to test the static methods */
#include "nslcd/cfg.c"
-#ifndef __ASSERT_FUNCTION
-#define __ASSERT_FUNCTION ""
-#endif /* not __ASSERT_FUNCTION */
-
-#define assertstreq(str1,str2) \
- (assertstreq_impl(str1,str2,"strcmp(" __STRING(str1) "," __STRING(str2)
")==0", \
- __FILE__, __LINE__, __ASSERT_FUNCTION))
-
-/* for Solaris: */
-#define __assert_fail(assertion,file,line,function)
__assert(assertion,file,line)
-
-/* method for determening string equalness */
-static void assertstreq_impl(const char *str1,const char *str2,
- const char *assertion,const char *file,
- int line,const char *function)
-{
- if (strcmp(str1,str2)!=0)
- __assert_fail(assertion,file,line,function);
-}
-
static void test_xstrdup(void)
{
static const char *foo="testString123";
Modified: nss-pam-ldapd/tests/test_common.c
==============================================================================
--- nss-pam-ldapd/tests/test_common.c Thu Mar 17 22:01:14 2011 (r1396)
+++ nss-pam-ldapd/tests/test_common.c Thu Mar 17 22:02:45 2011 (r1397)
@@ -2,7 +2,7 @@
test_common.c - simple test for the common module
This file is part of the nss-pam-ldapd library.
- Copyright (C) 2008, 2009 Arthur de Jong
+ Copyright (C) 2008, 2009, 2011 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
@@ -27,15 +27,6 @@
#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;}
-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;}
-
static void test_isvalidname(void)
{
assert(isvalidname("arthur"));
Modified: nss-pam-ldapd/tests/test_expr.c
==============================================================================
--- nss-pam-ldapd/tests/test_expr.c Thu Mar 17 22:01:14 2011 (r1396)
+++ nss-pam-ldapd/tests/test_expr.c Thu Mar 17 22:02:45 2011 (r1397)
@@ -2,7 +2,7 @@
test_expr.c - simple tests for the expr module
This file is part of the nss-pam-ldapd library.
- Copyright (C) 2009 Arthur de Jong
+ Copyright (C) 2009, 2011 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
@@ -26,29 +26,11 @@
#include <string.h>
#include <assert.h>
+#include "common.h"
+
/* we include expr.c because we want to test the static methods */
#include "common/expr.c"
-#ifndef __ASSERT_FUNCTION
-#define __ASSERT_FUNCTION ""
-#endif /* not __ASSERT_FUNCTION */
-
-#define assertstreq(str1,str2) \
- (assertstreq_impl(str1,str2,"strcmp(" __STRING(str1) "," __STRING(str2)
")==0", \
- __FILE__, __LINE__, __ASSERT_FUNCTION))
-
-/* for Solaris: */
-#define __assert_fail(assertion,file,line,function)
__assert(assertion,file,line)
-
-/* method for determening string equalness */
-static void assertstreq_impl(const char *str1,const char *str2,
- const char *assertion,const char *file,
- int line,const char *function)
-{
- if (strcmp(str1,str2)!=0)
- __assert_fail(assertion,file,line,function);
-}
-
static void test_parse_name(void)
{
char buffer[20];
Modified: nss-pam-ldapd/tests/test_getpeercred.c
==============================================================================
--- nss-pam-ldapd/tests/test_getpeercred.c Thu Mar 17 22:01:14 2011
(r1396)
+++ nss-pam-ldapd/tests/test_getpeercred.c Thu Mar 17 22:02:45 2011
(r1397)
@@ -2,7 +2,7 @@
test_getpeercred.c - simple test for the peercred module
This file is part of the nss-pam-ldapd library.
- Copyright (C) 2008 Arthur de Jong
+ Copyright (C) 2008, 2011 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
@@ -35,26 +35,11 @@
#endif /* HAVE_GRP_H */
#include <errno.h>
+#include "common.h"
+
#include "compat/attrs.h"
#include "compat/getpeercred.h"
-#ifndef __ASSERT_FUNCTION
-#define __ASSERT_FUNCTION ""
-#endif /* not __ASSERT_FUNCTION */
-
-#define assertok(expr) \
- ((expr) \
- ? (void) (0) \
- : __assertok_fail(__STRING(expr),__FILE__,__LINE__,__ASSERT_FUNCTION))
-
-static void __assertok_fail(const char *expr,const char *file,
- int line,const char *function)
-{
- char msg[120];
- snprintf(msg,sizeof(msg),"%s (errno=\"%s\")",expr,strerror(errno));
- __assert_fail(msg,file,line,function);
-}
-
/* create a named socket */
static int create_socket(const char *name)
{
Modified: nss-pam-ldapd/tests/test_myldap.c
==============================================================================
--- nss-pam-ldapd/tests/test_myldap.c Thu Mar 17 22:01:14 2011 (r1396)
+++ nss-pam-ldapd/tests/test_myldap.c Thu Mar 17 22:02:45 2011 (r1397)
@@ -2,7 +2,7 @@
test_myldap.c - simple test for the myldap module
This file is part of the nss-pam-ldapd library.
- Copyright (C) 2007, 2008, 2009 Arthur de Jong
+ Copyright (C) 2007, 2008, 2009, 2011 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
@@ -29,30 +29,12 @@
#include <assert.h>
#include <signal.h>
+#include "common.h"
+
#include "nslcd/log.h"
#include "nslcd/cfg.h"
#include "nslcd/myldap.h"
-#ifndef __ASSERT_FUNCTION
-#define __ASSERT_FUNCTION ""
-#endif /* not __ASSERT_FUNCTION */
-
-#define assertstreq(str1,str2) \
- (assertstreq_impl(str1,str2,"strcmp(" __STRING(str1) "," __STRING(str2)
")==0", \
- __FILE__, __LINE__, __ASSERT_FUNCTION))
-
-/* for Solaris: */
-#define __assert_fail(assertion,file,line,function)
__assert(assertion,file,line)
-
-/* method for determening string equalness */
-static void assertstreq_impl(const char *str1,const char *str2,
- const char *assertion,const char *file,
- int line,const char *function)
-{
- if (strcmp(str1,str2)!=0)
- __assert_fail(assertion,file,line,function);
-}
-
struct worker_args {
int id;
};
Modified: nss-pam-ldapd/tests/test_tio.c
==============================================================================
--- nss-pam-ldapd/tests/test_tio.c Thu Mar 17 22:01:14 2011 (r1396)
+++ nss-pam-ldapd/tests/test_tio.c Thu Mar 17 22:02:45 2011 (r1397)
@@ -2,7 +2,7 @@
test_tio.c - simple test for the tio module
This file is part of the nss-pam-ldapd library.
- Copyright (C) 2007, 2008 Arthur de Jong
+ Copyright (C) 2007, 2008, 2011 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
@@ -33,25 +33,12 @@
#endif /* HAVE_STDINT_H */
#include <stdlib.h>
#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
-#include "common/tio.h"
+#include "common.h"
-#ifndef __ASSERT_FUNCTION
-#define __ASSERT_FUNCTION ""
-#endif /* not __ASSERT_FUNCTION */
-
-#define assertok(expr) \
- ((expr) \
- ? (void) (0) \
- : __assertok_fail(__STRING(expr),__FILE__,__LINE__,__ASSERT_FUNCTION))
-
-static void __assertok_fail(const char *expr,const char *file,
- int line,const char *function)
-{
- char msg[120];
- snprintf(msg,sizeof(msg),"%s (errno=\"%s\")",expr,strerror(errno));
- __assert_fail(msg,file,line,function);
-}
+#include "common/tio.h"
/* structure for passing arguments to helper (is a thread) */
struct helper_args {
--
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits
- nss-pam-ldapd commit: r1397 - in nss-pam-ldapd: . tests,
Commits of the nss-pam-ldapd project