summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2004-08-27 15:52:54 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:24 -0500
commit826a515ec063cf7b986ddfcfd47f2f7f09a12be5 (patch)
tree058c7fec0890237e558936ddc96f252193fc3306 /source4/lib
parent3cd74a363402a88a78cc900fda1c03134a8e9945 (diff)
downloadsamba-826a515ec063cf7b986ddfcfd47f2f7f09a12be5.tar.gz
samba-826a515ec063cf7b986ddfcfd47f2f7f09a12be5.tar.bz2
samba-826a515ec063cf7b986ddfcfd47f2f7f09a12be5.zip
r2088: add tdbtorture tdbdump and tdbtest to the build
NOTE: tdbbackup and tdbtool seems to be broken... NOTE: I also added SMB_EXT_LIB(GDBM,...) because that is needed by tdbtest metze (This used to be commit e66630662d4203ccecbb20962e83dbf50a2c056f)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/tdb/config.m425
-rw-r--r--source4/lib/tdb/config.mk51
-rw-r--r--source4/lib/tdb/tools/tdbdump.c9
-rw-r--r--source4/lib/tdb/tools/tdbtest.c35
-rw-r--r--source4/lib/tdb/tools/tdbtorture.c16
5 files changed, 119 insertions, 17 deletions
diff --git a/source4/lib/tdb/config.m4 b/source4/lib/tdb/config.m4
index 12d88ed6a8..d9b44b75a5 100644
--- a/source4/lib/tdb/config.m4
+++ b/source4/lib/tdb/config.m4
@@ -7,3 +7,28 @@ fi
SMB_LIBRARY_MK(libtdb,lib/tdb/config.mk)
+###############################
+# start SMB_EXT_LIB_GDBM
+# check for gdbm.h and -lgdbm
+AC_CHECK_HEADERS(gdbm.h)
+AC_CHECK_LIB_EXT(gdbm, GDBM_LIBS, gdbm_open)
+if test x"$ac_cv_header_gdbm_h" = x"yes" -a x"$ac_cv_lib_ext_gdbm_gdbm_open" = x"yes";then
+ SMB_EXT_LIB_ENABLE(GDBM,YES)
+fi
+SMB_EXT_LIB(GDBM, $GDBM_LIBS)
+# end SMB_EXT_LIB_GDBM
+###############################
+
+SMB_BINARY_ENABLE(tdbtest, NO)
+if test x"$SMB_EXT_LIB_ENABLE_GDBM" = x"YES"; then
+ SMB_BINARY_ENABLE(tdbtest, YES)
+fi
+SMB_BINARY_MK(tdbtest,lib/tdb/config.mk)
+
+SMB_BINARY_MK(tdbtorture,lib/tdb/config.mk)
+
+SMB_BINARY_MK(tdbdump,lib/tdb/config.mk)
+
+# these are broken
+#SMB_BINARY_MK(tdbtool,lib/tdb/config.mk)
+#SMB_BINARY_MK(tdbbackup,lib/tdb/config.mk)
diff --git a/source4/lib/tdb/config.mk b/source4/lib/tdb/config.mk
index 96641f8da7..fdde6e7b4f 100644
--- a/source4/lib/tdb/config.mk
+++ b/source4/lib/tdb/config.mk
@@ -21,3 +21,54 @@ REQUIRED_SUBSYSTEMS = \
#
# End LIBRARY LIBLDB
################################################
+
+################################################
+# Start BINARY tdbtest
+[BINARY::tdbtest]
+OBJ_FILES= \
+ lib/tdb/tools/tdbtest.o
+REQUIRED_SUBSYSTEMS = \
+ LIBBASIC CONFIG LIBCMDLINE LIBTDB
+REQUIRED_LIBRARIES = GDBM
+# End BINARY tdbtest
+################################################
+
+################################################
+# Start BINARY tdbtool
+[BINARY::tdbtool]
+OBJ_FILES= \
+ lib/tdb/tools/tdbtool.o
+REQUIRED_SUBSYSTEMS = \
+ LIBBASIC CONFIG LIBCMDLINE LIBTDB
+# End BINARY tdbtool
+################################################
+
+################################################
+# Start BINARY tdbtorture
+[BINARY::tdbtorture]
+OBJ_FILES= \
+ lib/tdb/tools/tdbtorture.o
+REQUIRED_SUBSYSTEMS = \
+ LIBBASIC CONFIG LIBCMDLINE LIBTDB
+# End BINARY tdbtorture
+################################################
+
+################################################
+# Start BINARY tdbdump
+[BINARY::tdbdump]
+OBJ_FILES= \
+ lib/tdb/tools/tdbdump.o
+REQUIRED_SUBSYSTEMS = \
+ LIBBASIC CONFIG LIBCMDLINE LIBTDB
+# End BINARY tdbdump
+################################################
+
+################################################
+# Start BINARY tdbbackup
+[BINARY::tdbbackup]
+OBJ_FILES= \
+ lib/tdb/tools/tdbbackup.o
+REQUIRED_SUBSYSTEMS = \
+ LIBBASIC CONFIG LIBCMDLINE LIBTDB
+# End BINARY tdbbackup
+################################################
diff --git a/source4/lib/tdb/tools/tdbdump.c b/source4/lib/tdb/tools/tdbdump.c
index 1a7128c473..0e179f8c3e 100644
--- a/source4/lib/tdb/tools/tdbdump.c
+++ b/source4/lib/tdb/tools/tdbdump.c
@@ -18,6 +18,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#ifdef STANDALONE
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
@@ -33,9 +34,15 @@
#include <signal.h>
#include "tdb.h"
+#else
+
+#include "includes.h"
+
+#endif
+
static void print_data(TDB_DATA d)
{
- uint8_t *p = d.dptr;
+ unsigned char *p = d.dptr;
int len = d.dsize;
while (len--) {
if (isprint(*p) && !strchr("\"\\", *p)) {
diff --git a/source4/lib/tdb/tools/tdbtest.c b/source4/lib/tdb/tools/tdbtest.c
index 89295a3291..9a210f8a61 100644
--- a/source4/lib/tdb/tools/tdbtest.c
+++ b/source4/lib/tdb/tools/tdbtest.c
@@ -1,3 +1,6 @@
+/* a test program for tdb - the trivial database */
+
+#ifdef STANDALONE
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
@@ -10,10 +13,13 @@
#include <sys/time.h>
#include <signal.h>
#include "tdb.h"
-#include <gdbm.h>
+#else
-/* a test program for tdb - the trivial database */
+#include "includes.h"
+#endif
+
+#include <gdbm.h>
#define DELETE_PROB 7
@@ -24,24 +30,27 @@ static GDBM_FILE gdbm;
struct timeval tp1,tp2;
-static void start_timer(void)
+static void _start_timer(void)
{
gettimeofday(&tp1,NULL);
}
-static double end_timer(void)
+static double _end_timer(void)
{
gettimeofday(&tp2,NULL);
return((tp2.tv_sec - tp1.tv_sec) +
(tp2.tv_usec - tp1.tv_usec)*1.0e-6);
}
-static void fatal(char *why)
+static void fatal(const char *why)
{
perror(why);
exit(1);
}
+#ifdef PRINTF_ATTRIBUTE
+static void tdb_log(TDB_CONTEXT *tdb, int level, const char *format, ...) PRINTF_ATTRIBUTE(3,4);
+#endif
static void tdb_log(TDB_CONTEXT *tdb, int level, const char *format, ...)
{
va_list ap;
@@ -192,14 +201,15 @@ static void merge_test(void)
{
int i;
char keys[5][2];
+ char tdata[] = "test";
TDB_DATA key, data;
for (i = 0; i < 5; i++) {
- sprintf(keys[i], "%d", i);
+ snprintf(keys[i],2, "%d", i);
key.dptr = keys[i];
key.dsize = 2;
- data.dptr = "test";
+ data.dptr = tdata;
data.dsize = 4;
if (tdb_store(db, key, data, TDB_REPLACE) != 0) {
@@ -223,12 +233,13 @@ int main(int argc, char *argv[])
{
int i, seed=0;
int loops = 10000;
+ char test_gdbm[] = "test.gdbm";
unlink("test.gdbm");
db = tdb_open("test.tdb", 0, TDB_CLEAR_IF_FIRST,
O_RDWR | O_CREAT | O_TRUNC, 0600);
- gdbm = gdbm_open("test.gdbm", 512, GDBM_WRITER|GDBM_NEWDB|GDBM_FAST,
+ gdbm = gdbm_open(test_gdbm, 512, GDBM_WRITER|GDBM_NEWDB|GDBM_FAST,
0600, NULL);
if (!db || !gdbm) {
@@ -239,17 +250,17 @@ int main(int argc, char *argv[])
#if 1
srand(seed);
- start_timer();
+ _start_timer();
for (i=0;i<loops;i++) addrec_gdbm();
- printf("gdbm got %.2f ops/sec\n", i/end_timer());
+ printf("gdbm got %.2f ops/sec\n", i/_end_timer());
#endif
merge_test();
srand(seed);
- start_timer();
+ _start_timer();
for (i=0;i<loops;i++) addrec_db();
- printf("tdb got %.2f ops/sec\n", i/end_timer());
+ printf("tdb got %.2f ops/sec\n", i/_end_timer());
compare_db();
diff --git a/source4/lib/tdb/tools/tdbtorture.c b/source4/lib/tdb/tools/tdbtorture.c
index 3f704e537e..d7c0812800 100644
--- a/source4/lib/tdb/tools/tdbtorture.c
+++ b/source4/lib/tdb/tools/tdbtorture.c
@@ -1,3 +1,8 @@
+/* this tests tdb by doing lots of ops from several simultaneous
+ writers - that stresses the locking code. Build with TDB_DEBUG=1
+ for best effect */
+
+#ifdef STANDALONE
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
@@ -13,11 +18,11 @@
#include <sys/wait.h>
#include "tdb.h"
-/* this tests tdb by doing lots of ops from several simultaneous
- writers - that stresses the locking code. Build with TDB_DEBUG=1
- for best effect */
+#else
+#include "includes.h"
+#endif
#define REOPEN_PROB 30
#define DELETE_PROB 8
@@ -32,6 +37,9 @@
static TDB_CONTEXT *db;
+#ifdef PRINTF_ATTRIBUTE
+static void tdb_log(TDB_CONTEXT *tdb, int level, const char *format, ...) PRINTF_ATTRIBUTE(3,4);
+#endif
static void tdb_log(TDB_CONTEXT *tdb, int level, const char *format, ...)
{
va_list ap;
@@ -50,7 +58,7 @@ static void tdb_log(TDB_CONTEXT *tdb, int level, const char *format, ...)
#endif
}
-static void fatal(char *why)
+static void fatal(const char *why)
{
perror(why);
exit(1);