summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2011-12-15 11:26:57 +1100
committerMartin Schwenke <martin@meltin.net>2012-02-06 16:00:24 +1100
commit31487f31df154e29bdc8060cc8dfce4b436c6bf0 (patch)
treed2a200cc23db0ef766013a9ef71258548fb2a0e2
parente2ceae48e382e47ca175231cda8581020dd8a000 (diff)
downloadsamba-31487f31df154e29bdc8060cc8dfce4b436c6bf0.tar.gz
samba-31487f31df154e29bdc8060cc8dfce4b436c6bf0.tar.xz
samba-31487f31df154e29bdc8060cc8dfce4b436c6bf0.zip
Tests - add a version of the ctdb tool that compiles against libctdb stubs
Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 6c79b951c3ae68238f8dbd836ceca6c1187eaabe)
-rwxr-xr-xctdb/Makefile.in8
-rw-r--r--ctdb/tests/src/ctdb_tool_stubby.c49
2 files changed, 56 insertions, 1 deletions
diff --git a/ctdb/Makefile.in b/ctdb/Makefile.in
index 6fdd3f6c3d..15da88398d 100755
--- a/ctdb/Makefile.in
+++ b/ctdb/Makefile.in
@@ -84,7 +84,7 @@ TEST_BINS=tests/bin/ctdb_bench tests/bin/ctdb_fetch tests/bin/ctdb_fetch_one \
tests/bin/ctdb_randrec tests/bin/ctdb_persistent \
tests/bin/ctdb_traverse tests/bin/rb_test tests/bin/ctdb_transaction \
tests/bin/ctdb_takeover_tests tests/bin/ctdb_update_record \
- tests/bin/ctdb_tool_libctdb \
+ tests/bin/ctdb_tool_libctdb tests/bin/ctdb_tool_stubby \
@INFINIBAND_BINS@
BINS = bin/ctdb @CTDB_SCSI_IO@ bin/smnotify bin/ping_pong bin/ltdbtool @CTDB_PMDA@
@@ -254,6 +254,12 @@ tests/bin/ctdb_tool_libctdb: $(CTDB_TEST_OBJ) tests/src/ctdb_tool_libctdb.o
@echo Linking $@
@$(CC) $(CFLAGS) -o $@ tests/src/ctdb_tool_libctdb.o $(CTDB_TEST_OBJ) @POPT_OBJ@ $(LIB_FLAGS)
+tests/src/ctdb_tool_stubby.o: tests/src/ctdb_tool_stubby.c tests/src/libctdb_test.c $(CTDB_TEST_C)
+
+tests/bin/ctdb_tool_stubby: $(CTDB_TEST_OBJ) tests/src/ctdb_tool_stubby.o
+ @echo Linking $@
+ @$(CC) $(CFLAGS) -o $@ tests/src/ctdb_tool_stubby.o $(CTDB_TEST_OBJ) @POPT_OBJ@ $(LIB_FLAGS)
+
tests/bin/ibwrapper_test: $(CTDB_CLIENT_OBJ) ib/ibwrapper_test.o
@echo Linking $@
@$(CC) $(CFLAGS) -o $@ ib/ibwrapper_test.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
diff --git a/ctdb/tests/src/ctdb_tool_stubby.c b/ctdb/tests/src/ctdb_tool_stubby.c
new file mode 100644
index 0000000000..c388c63070
--- /dev/null
+++ b/ctdb/tests/src/ctdb_tool_stubby.c
@@ -0,0 +1,49 @@
+/*
+ Tests wrapper for tools/ctdb.c that uses stubs
+
+ Copyright (C) Martin Schwenke 2011
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#define CTDB_TEST_USE_MAIN
+#include "ctdb_test.c"
+
+#include "libctdb_test.c"
+
+void tevent_loop_allow_nesting_foobar(struct tevent_context *ev)
+{
+ return;
+}
+
+struct ctdb_context *ctdb_cmdline_client_foobar(struct tevent_context *ev,
+ struct timeval req_timeout)
+{
+ struct ctdb_context *ret;
+
+ ret = talloc(NULL, struct ctdb_context);
+
+ return ret;
+}
+
+struct tevent_context *tevent_context_init_foobar(TALLOC_CTX *mem_ctx)
+{
+ /* This should obviously never be used... */
+ return (struct tevent_context *) 1;
+}
+
+const char *ctdb_get_socketname_foobar(struct ctdb_context *ctdb)
+{
+ return LIBCTDB_TEST_FAKESTATE;
+}