Author: jelmer Date: 2007-11-05 21:57:33 +0000 (Mon, 05 Nov 2007) New Revision: 25842
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25842 Log: Start working on test for loading dso's in ldb. Added: branches/SAMBA_4_0/source/lib/ldb/tests/sample_module.c branches/SAMBA_4_0/source/lib/ldb/tests/test-soloading.sh Modified: branches/SAMBA_4_0/ branches/SAMBA_4_0/.bzrignore branches/SAMBA_4_0/source/lib/ldb/Makefile.in branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.c branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.h Changeset: Property changes on: branches/SAMBA_4_0 ___________________________________________________________________ Name: bzr:revision-info ...skipped... Name: bzr:file-ids ...skipped... Name: bzr:revision-id:v3-trunk0 ...skipped... Modified: branches/SAMBA_4_0/.bzrignore =================================================================== --- branches/SAMBA_4_0/.bzrignore 2007-11-05 16:16:41 UTC (rev 25841) +++ branches/SAMBA_4_0/.bzrignore 2007-11-05 21:57:33 UTC (rev 25842) @@ -202,3 +202,5 @@ torture/winbind/proto.h source/rpc_server/lsa/proto.h source/torture/winbind/proto.h +source/lib/ldb/tdbtest.ldb +source/lib/ldb/tdbtest.ldb Modified: branches/SAMBA_4_0/source/lib/ldb/Makefile.in =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/Makefile.in 2007-11-05 16:16:41 UTC (rev 25841) +++ branches/SAMBA_4_0/source/lib/ldb/Makefile.in 2007-11-05 21:57:33 UTC (rev 25842) @@ -32,9 +32,11 @@ 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=\"@[EMAIL PROTECTED]" -DUSE_MMAP=1 @CFLAGS@ + -DLIBDIR=\"$(libdir)\" -DSHLIBEXT=\"$(SHLIBEXT)\" -DUSE_MMAP=1 @CFLAGS@ [EMAIL PROTECTED]@ -Llib -lldb @LIBS@ $(POPT_LIBS) $(TALLOC_LIBS) $(TDB_LIBS) \ $(LDAP_LIBS) @@ -104,6 +106,9 @@ 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 @@ 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 Added: branches/SAMBA_4_0/source/lib/ldb/tests/sample_module.c =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/tests/sample_module.c 2007-11-05 16:16:41 UTC (rev 25841) +++ branches/SAMBA_4_0/source/lib/ldb/tests/sample_module.c 2007-11-05 21:57:33 UTC (rev 25842) @@ -0,0 +1,43 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Jelmer Vernooij <[EMAIL PROTECTED]> 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 <http://www.gnu.org/licenses/>. +*/ + +#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); +} Added: branches/SAMBA_4_0/source/lib/ldb/tests/test-soloading.sh =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/tests/test-soloading.sh 2007-11-05 16:16:41 UTC (rev 25841) +++ branches/SAMBA_4_0/source/lib/ldb/tests/test-soloading.sh 2007-11-05 21:57:33 UTC (rev 25842) @@ -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 <<EOF | $VALGRIND ldbadd || exit 1 +dn: @MODULES [EMAIL PROTECTED]: sample_module +EOF + +cat <<EOF | $VALGRIND ldbadd || exit 1 +dn: dc=bar +dc: bar +someThing: someThingElse +EOF + +$VALGRIND ldbsearch "(touchedBy=sample)" | grep "touchedBy: sample" || exit 1 + Property changes on: branches/SAMBA_4_0/source/lib/ldb/tests/test-soloading.sh ___________________________________________________________________ Name: svn:executable + * Modified: branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.c =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.c 2007-11-05 16:16:41 UTC (rev 25841) +++ branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.c 2007-11-05 21:57:33 UTC (rev 25842) @@ -60,6 +60,7 @@ { "verbose", 'v', POPT_ARG_NONE, NULL, 'v', "increase verbosity", NULL }, { "interactive", 'i', POPT_ARG_NONE, &options.interactive, 0, "input from stdin", NULL }, { "recursive", 'r', POPT_ARG_NONE, &options.recursive, 0, "recursive delete", NULL }, + { "modules-path", 0, POPT_ARG_STRING, &options.modules_path, 0, "modules path", "PATH" }, { "num-searches", 0, POPT_ARG_INT, &options.num_searches, 0, "number of test searches", NULL }, { "num-records", 0, POPT_ARG_INT, &options.num_records, 0, "number of test records", NULL }, { "all", 'a', POPT_ARG_NONE, &options.all_records, 0, "(|(objectClass=*)(distinguishedName=*))", NULL }, @@ -218,6 +219,12 @@ ldb_set_utf8_fns(ldb, NULL, wrap_casefold); #endif + if (options.modules_path != NULL) { + ldb_set_modules_dir(ldb, options.modules_path); + } else if (getenv("LDB_MODULES_PATH") != NULL) { + ldb_set_modules_dir(ldb, getenv("LDB_MODULES_PATH")); + } + /* now connect to the ldb */ if (ldb_connect(ldb, ret->url, flags, ret->options) != 0) { fprintf(stderr, "Failed to connect to %s - %s\n", Modified: branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.h =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.h 2007-11-05 16:16:41 UTC (rev 25841) +++ branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.h 2007-11-05 21:57:33 UTC (rev 25842) @@ -27,6 +27,7 @@ const char *url; enum ldb_scope scope; const char *basedn; + const char *modules_path; int interactive; int sorted; const char *editor;