Tests - add a version of the ctdb tool that compiles against libctdb stubs
authorMartin Schwenke <martin@meltin.net>
Thu, 15 Dec 2011 00:26:57 +0000 (11:26 +1100)
committerMartin Schwenke <martin@meltin.net>
Mon, 6 Feb 2012 05:00:24 +0000 (16:00 +1100)
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit 6c79b951c3ae68238f8dbd836ceca6c1187eaabe)

ctdb/Makefile.in
ctdb/tests/src/ctdb_tool_stubby.c [new file with mode: 0644]

index 6fdd3f6c3deeb4c6bc1f3ec01563ddf8a4232c69..15da88398d28050a0ae9d9708eb4dddf7c627d0b 100755 (executable)
@@ -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 (file)
index 0000000..c388c63
--- /dev/null
@@ -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;
+}