From f017f871078fd2219766ea061468268acb92140c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 5 Nov 2007 21:57:33 +0100 Subject: r25842: Start working on test for loading dso's in ldb. (This used to be commit d41ed7ca8d3954bf586126edd7aba17acc6af8a1) --- source4/lib/ldb/Makefile.in | 12 ++++++++- source4/lib/ldb/tests/sample_module.c | 43 +++++++++++++++++++++++++++++++++ source4/lib/ldb/tests/test-soloading.sh | 32 ++++++++++++++++++++++++ source4/lib/ldb/tools/cmdline.c | 7 ++++++ source4/lib/ldb/tools/cmdline.h | 1 + 5 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 source4/lib/ldb/tests/sample_module.c create mode 100755 source4/lib/ldb/tests/test-soloading.sh (limited to 'source4') diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in index 75f1767550..dc18a7b575 100644 --- a/source4/lib/ldb/Makefile.in +++ b/source4/lib/ldb/Makefile.in @@ -32,9 +32,11 @@ POPT_OBJ = @POPT_OBJ@ LDAP_LIBS = @LDAP_LIBS@ +SHLIBEXT = @SHLIBEXT@ + CFLAGS=-g -I$(srcdir)/include -Iinclude -I$(srcdir) -I$(srcdir)/.. \ $(POPT_CFLAGS) $(TALLOC_CFLAGS) $(TDB_CFLAGS) \ - -DLIBDIR=\"$(libdir)\" -DSHLIBEXT=\"@SHLIBEXT@\" -DUSE_MMAP=1 @CFLAGS@ + -DLIBDIR=\"$(libdir)\" -DSHLIBEXT=\"$(SHLIBEXT)\" -DUSE_MMAP=1 @CFLAGS@ LIB_FLAGS=@LDFLAGS@ -Llib -lldb @LIBS@ $(POPT_LIBS) $(TALLOC_LIBS) $(TDB_LIBS) \ $(LDAP_LIBS) @@ -104,6 +106,9 @@ lib/libldb.a: $(OBJS) lib/libnss_ldb.so.2: $(NSS_OBJ) $(LIBS) bin/libldb.a $(CC) -shared -Wl,-soname,libnss_ldb.so.2 -o lib/libnss_ldb.so.2 $(NSS_OBJ) $(OBJS) $(LIB_FLAGS) +sample_module.$(SHLIBEXT): tests/sample_module.o + $(CC) -shared -o $@ tests/sample_module.o $(LIB_FLAGS) + bin/ldbadd: tools/ldbadd.o tools/cmdline.o $(LIBS) $(CC) -o bin/ldbadd tools/ldbadd.o tools/cmdline.o $(LIB_FLAGS) @@ -160,6 +165,11 @@ distclean: clean realdistclean: distclean rm -f configure.in include/config.h.in +check:: test + +check-soloading: sample_module.$(SHLIBEXT) + LDB_MODULES_PATH=$(builddir) $(srcdir)/tests/test-soloading.sh + test: all for t in $(TESTS); do echo STARTING $${t}; $(srcdir)/tests/$${t} || exit 1; done diff --git a/source4/lib/ldb/tests/sample_module.c b/source4/lib/ldb/tests/sample_module.c new file mode 100644 index 0000000000..8ab1d33146 --- /dev/null +++ b/source4/lib/ldb/tests/sample_module.c @@ -0,0 +1,43 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Jelmer Vernooij 2007 + + ** NOTE! The following LGPL license applies to the ldb + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + 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 3 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, see . +*/ + +#include "ldb_includes.h" +#include "ldb.h" +#include "ldb_errors.h" + +int sample_add(struct ldb_module *mod, struct ldb_request *req) +{ + ldb_msg_add_fmt(req->op.add.message, "touchedBy", "sample"); + + return ldb_next_request(mod, req); +} + +static const struct ldb_module_ops sample_ops = { + .name = "sample_module", + .add = sample_add, +}; + +int init_module(void) +{ + return ldb_register_module(&sample_ops); +} diff --git a/source4/lib/ldb/tests/test-soloading.sh b/source4/lib/ldb/tests/test-soloading.sh new file mode 100755 index 0000000000..c42c9b22ba --- /dev/null +++ b/source4/lib/ldb/tests/test-soloading.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +if [ -n "$TEST_DATA_PREFIX" ]; then + LDB_URL="$TEST_DATA_PREFIX/tdbtest.ldb" +else + LDB_URL="tdbtest.ldb" +fi +export LDB_URL + +PATH=bin:$PATH +export PATH + +rm -f $LDB_URL* + +if [ -z "$LDBDIR" ]; then + LDBDIR=`dirname $0`/.. + export LDBDIR +fi + +cat <url, flags, ret->options) != 0) { fprintf(stderr, "Failed to connect to %s - %s\n", diff --git a/source4/lib/ldb/tools/cmdline.h b/source4/lib/ldb/tools/cmdline.h index ae295d68a4..3473d62a16 100644 --- a/source4/lib/ldb/tools/cmdline.h +++ b/source4/lib/ldb/tools/cmdline.h @@ -27,6 +27,7 @@ struct ldb_cmdline { const char *url; enum ldb_scope scope; const char *basedn; + const char *modules_path; int interactive; int sorted; const char *editor; -- cgit