[SCM] CTDB repository - branch master updated - ctdb-1.12-178-g6127515

Ronnie Sahlberg sahlberg at samba.org
Sun Feb 5 22:18:06 MST 2012


The branch, master has been updated
       via  6127515ea62173ff1574d1217129ec05a8fbeb3f (commit)
       via  47e86c33d768816d03817124481bb6aa967bf2a6 (commit)
       via  fa00bbf7d7378eecb5ba77684d01db90c9370bca (commit)
       via  47e9975fa75a7bb2628a751dc19d35e2c5c57ce3 (commit)
       via  ca1d2bb62e61b7d723a648b3a9b146e258efcabb (commit)
       via  f96954b42b03f810f7b1732b5fe00c5dab2d8cb8 (commit)
       via  6c79b951c3ae68238f8dbd836ceca6c1187eaabe (commit)
       via  7339e87019c0ab44522bf160234307472c05dc14 (commit)
       via  6f29c39d666485fddef60e9d87bf94082d179ebb (commit)
       via  25a0136bd773e7ed8dfda635471f0498d4a7afe9 (commit)
       via  9bfc3b04ffeca056d8507d1cc8bc20f56c8e1572 (commit)
       via  abe9985e503d998cf597933a594b445de8d3cec6 (commit)
       via  f6039eaece4224b866a98dd49010f278a7b3f015 (commit)
       via  d597020af01dfcdf0d39e1cf579bf33f43f87dda (commit)
       via  bc4d5d5f0048487776f9f5d9f04a0af2e5d45aac (commit)
      from  4f4fbd4080a3a7226d3b82637f803c4b71217d39 (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 6127515ea62173ff1574d1217129ec05a8fbeb3f
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Feb 6 15:59:08 2012 +1100

    Tests - ctdb tool - add verbose option and output filtering
    
    Need to filter dates before comparing...
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 47e86c33d768816d03817124481bb6aa967bf2a6
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Feb 6 15:58:15 2012 +1100

    Tests - ctdb tool - fix "ctdb status" test
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit fa00bbf7d7378eecb5ba77684d01db90c9370bca
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Feb 6 15:57:13 2012 +1100

    Tests - let run_tests.sh take a list of tests to run
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 47e9975fa75a7bb2628a751dc19d35e2c5c57ce3
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Jan 15 14:55:52 2012 +1100

    Tests: initial ctdb tool testcases
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit ca1d2bb62e61b7d723a648b3a9b146e258efcabb
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Jan 15 14:55:15 2012 +1100

    Tests: fix usage message in ctdb_tool_libctdb
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit f96954b42b03f810f7b1732b5fe00c5dab2d8cb8
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Jan 15 14:54:14 2012 +1100

    Tests: libctdb stubs should fail when current node disconnected
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 6c79b951c3ae68238f8dbd836ceca6c1187eaabe
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Dec 15 11:26:57 2011 +1100

    Tests - add a version of the ctdb tool that compiles against libctdb stubs
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 7339e87019c0ab44522bf160234307472c05dc14
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Dec 15 11:26:09 2011 +1100

    ctdb tool - free some memory used by popt
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 6f29c39d666485fddef60e9d87bf94082d179ebb
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Dec 15 11:21:34 2011 +1100

    Tests - allow tools/ctdb.c:main() to be used
    
    We'll need stubs somewhere else...
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 25a0136bd773e7ed8dfda635471f0498d4a7afe9
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Dec 13 16:48:10 2011 +1100

    Tests - more libctdb stub test infrastructure
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 9bfc3b04ffeca056d8507d1cc8bc20f56c8e1572
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Dec 13 15:44:22 2011 +1100

    Tests - more libctdb stubs and supporting state faking functions
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit abe9985e503d998cf597933a594b445de8d3cec6
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Dec 12 17:19:00 2011 +1100

    ctdb tool - convert control_status() over to use just libctdb()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit f6039eaece4224b866a98dd49010f278a7b3f015
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Dec 12 16:48:10 2011 +1100

    libctdb - add ctdb_getvnnmap()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit d597020af01dfcdf0d39e1cf579bf33f43f87dda
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Dec 7 14:04:54 2011 +1100

    Tests - update test code for ctdb tool code and libctdb stubs
    
    Rename ctdb_parse_nodestring.c to ctdb_tool_libctdb.c.  It can contain
    many tests.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit bc4d5d5f0048487776f9f5d9f04a0af2e5d45aac
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Dec 6 19:50:40 2011 +1100

    ctdb tool - Fix parse_nodestring() related issues
    
    An old, buggy version of this code was merged.  This fixes it.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

-----------------------------------------------------------------------

Summary of changes:
 Makefile.in                                        |   14 +-
 include/ctdb.h                                     |   59 +++++
 include/ctdb_private.h                             |   20 --
 include/ctdb_protocol.h                            |   18 ++
 libctdb/control.c                                  |   76 ++++++
 libctdb/sync.c                                     |   19 ++
 tests/run_tests.sh                                 |    2 +-
 tests/src/ctdb_test.c                              |   30 +++
 ...ctdb_parse_nodestring.c => ctdb_tool_libctdb.c} |   70 +++++-
 tests/src/ctdb_tool_stubby.c                       |   49 ++++
 tests/src/libctdb_test.c                           |  268 +++++++++++++++++++-
 tests/{takeover => tool}/common.sh                 |   43 ++--
 tests/{takeover => tool}/run_tests.sh              |    8 +-
 tests/tool/testcases/func.parse_nodestring.001.sh  |   16 ++
 tests/tool/testcases/func.parse_nodestring.002.sh  |   16 ++
 tests/tool/testcases/func.parse_nodestring.003.sh  |   15 +
 tests/tool/testcases/stubby.nodestatus.001.sh      |   30 +++
 tests/tool/testcases/stubby.nodestatus.002.sh      |   30 +++
 tests/tool/testcases/stubby.nodestatus.003.sh      |   30 +++
 tests/tool/testcases/stubby.nodestatus.004.sh      |   28 ++
 tests/tool/testcases/stubby.status.001.sh          |   37 +++
 tests/tool/testcases/stubby.status.002.sh          |   37 +++
 tools/ctdb.c                                       |   36 ++--
 23 files changed, 882 insertions(+), 69 deletions(-)
 rename tests/src/{ctdb_parse_nodestring.c => ctdb_tool_libctdb.c} (65%)
 create mode 100644 tests/src/ctdb_tool_stubby.c
 copy tests/{takeover => tool}/common.sh (52%)
 copy tests/{takeover => tool}/run_tests.sh (75%)
 create mode 100755 tests/tool/testcases/func.parse_nodestring.001.sh
 create mode 100755 tests/tool/testcases/func.parse_nodestring.002.sh
 create mode 100755 tests/tool/testcases/func.parse_nodestring.003.sh
 create mode 100755 tests/tool/testcases/stubby.nodestatus.001.sh
 create mode 100755 tests/tool/testcases/stubby.nodestatus.002.sh
 create mode 100755 tests/tool/testcases/stubby.nodestatus.003.sh
 create mode 100755 tests/tool/testcases/stubby.nodestatus.004.sh
 create mode 100755 tests/tool/testcases/stubby.status.001.sh
 create mode 100755 tests/tool/testcases/stubby.status.002.sh


Changeset truncated at 500 lines:

diff --git a/Makefile.in b/Makefile.in
index 2dd2bb7..15da883 100755
--- a/Makefile.in
+++ b/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_parse_nodestring \
+	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@
@@ -248,11 +248,17 @@ tests/bin/ctdb_takeover_tests: $(CTDB_TEST_OBJ) tests/src/ctdb_takeover_tests.o
 	@echo Linking $@
 	@$(CC) $(CFLAGS) -o $@ tests/src/ctdb_takeover_tests.o $(CTDB_TEST_OBJ) $(LIB_FLAGS)
 
-tests/src/ctdb_parse_nodestring.o: tests/src/ctdb_parse_nodestring.c tests/src/libctdb_test.c $(CTDB_TEST_C)
+tests/src/ctdb_tool_libctdb.o: tests/src/ctdb_tool_libctdb.c tests/src/libctdb_test.c $(CTDB_TEST_C)
 
-tests/bin/ctdb_parse_nodestring: $(CTDB_TEST_OBJ) tests/src/ctdb_parse_nodestring.o
+tests/bin/ctdb_tool_libctdb: $(CTDB_TEST_OBJ) tests/src/ctdb_tool_libctdb.o
 	@echo Linking $@
-	@$(CC) $(CFLAGS) -o $@ tests/src/ctdb_parse_nodestring.o $(CTDB_TEST_OBJ) @POPT_OBJ@ $(LIB_FLAGS)
+	@$(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 $@
diff --git a/include/ctdb.h b/include/ctdb.h
index 795ff5c..8dbdd47 100644
--- a/include/ctdb.h
+++ b/include/ctdb.h
@@ -744,6 +744,38 @@ bool ctdb_getrecmode_recv(struct ctdb_connection *ctdb,
 			  uint32_t *recmode);
 
 /**
+ * ctdb_getvnnmap_send - read the vnn map from a node.
+ * @ctdb: the ctdb_connection from ctdb_connect.
+ * @destnode: the destination node (see below)
+ * @callback: the callback when ctdb replies to our message (typesafe)
+ * @cbdata: the argument to callback()
+ *
+ * There are several special values for destnode, detailed in
+ * ctdb_protocol.h, particularly CTDB_CURRENT_NODE which means the
+ * local ctdbd.
+ */
+struct ctdb_request *
+ctdb_getvnnmap_send(struct ctdb_connection *ctdb,
+		    uint32_t destnode,
+		    ctdb_callback_t callback,
+		    void *cbdata);
+/**
+ * ctdb_getvnnmap_recv - read an ctdb_getvnnmap reply from ctdbd
+ * @ctdb: the ctdb_connection from ctdb_connect.
+ * @req: the completed request.
+ * @vnnmap: the list of interfaces 
+ *
+ * This returns false if something went wrong.
+ * If the command failed, it guarantees to set vnnmap to NULL.
+ * A non-NULL value for vnnmap means the command was successful.
+ *
+ * A non-NULL value of the vnnmap must be released/freed
+ * by ctdb_free_vnnmap().
+ */
+bool ctdb_getvnnmap_recv(struct ctdb_connection *ctdb,
+			 struct ctdb_request *req, struct ctdb_vnn_map **vnnmap);
+
+/**
  * ctdb_cancel - cancel an uncompleted request
  * @ctdb: the ctdb_connection from ctdb_connect.
  * @req: the uncompleted request.
@@ -989,6 +1021,29 @@ bool ctdb_getpublicips(struct ctdb_connection *ctdb,
 void ctdb_free_publicips(struct ctdb_all_public_ips *ips);
 
 
+/**
+ * ctdb_getvnnmap - read the vnn map from a node (synchronous)
+ * @ctdb: the ctdb_connection from ctdb_connect.
+ * @destnode: the destination node (see below)
+ * @vnnmap: a pointer to the vnnmap to fill in
+ *
+ * There are several special values for destnode, detailed in
+ * ctdb_protocol.h, particularly CTDB_CURRENT_NODE which means the
+ * local ctdbd.
+ *
+ * Returns true and fills in *vnnmap on success.
+ * A non-NULL value of the vnnmap must be  released/freed
+ * by ctdb_free_vnnmap().
+ */
+bool ctdb_getvnnmap(struct ctdb_connection *ctdb,
+		    uint32_t destnode, struct ctdb_vnn_map **vnnmap);
+
+/*
+ * This function is used to release/free the vnnmap structure returned
+ * by ctdb_getvnnmap() and ctdb_getvnnmap_recv()
+ */
+void ctdb_free_vnnmap(struct ctdb_vnn_map *vnnmap);
+
 /* These ugly macro wrappers make the callbacks typesafe. */
 #include <ctdb_typesafe_cb.h>
 #define ctdb_sendcb(cb, cbdata)						\
@@ -1067,4 +1122,8 @@ void ctdb_free_publicips(struct ctdb_all_public_ips *ips);
 	ctdb_getifaces_send((ctdb), (destnode),				\
 			 ctdb_sendcb((cb), (cbdata)), (cbdata))
 
+#define ctdb_getvnnmap_send(ctdb, destnode, cb, cbdata)			\
+	ctdb_getvnnmap_send((ctdb), (destnode),				\
+			 ctdb_sendcb((cb), (cbdata)), (cbdata))
+
 #endif
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 92d498a..f58356f 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -363,26 +363,6 @@ struct ctdb_daemon_data {
 
 
 
-
-
-#define INVALID_GENERATION 1
-/* table that contains the mapping between a hash value and lmaster
- */
-struct ctdb_vnn_map {
-	uint32_t generation;
-	uint32_t size;
-	uint32_t *map;
-};
-
-/* 
-   a wire representation of the vnn map
- */
-struct ctdb_vnn_map_wire {
-	uint32_t generation;
-	uint32_t size;
-	uint32_t map[1];
-};
-
 /* a structure that contains the elements required for the write record
    control
 */
diff --git a/include/ctdb_protocol.h b/include/ctdb_protocol.h
index 70197d9..0b3245d 100644
--- a/include/ctdb_protocol.h
+++ b/include/ctdb_protocol.h
@@ -676,4 +676,22 @@ struct ctdb_ifaces_list {
 	struct ctdb_iface_info ifaces[1];
 };
 
+#define INVALID_GENERATION 1
+/* table that contains the mapping between a hash value and lmaster
+ */
+struct ctdb_vnn_map {
+	uint32_t generation;
+	uint32_t size;
+	uint32_t *map;
+};
+
+/* 
+   a wire representation of the vnn map
+ */
+struct ctdb_vnn_map_wire {
+	uint32_t generation;
+	uint32_t size;
+	uint32_t map[1];
+};
+
 #endif
diff --git a/libctdb/control.c b/libctdb/control.c
index 9beb49f..ba22444 100644
--- a/libctdb/control.c
+++ b/libctdb/control.c
@@ -30,6 +30,7 @@
 #undef ctdb_getpublicips_send
 #undef ctdb_getdbseqnum_send
 #undef ctdb_getifaces_send
+#undef ctdb_getvnnmap_send
 
 bool ctdb_getrecmaster_recv(struct ctdb_connection *ctdb,
 			   struct ctdb_request *req, uint32_t *recmaster)
@@ -355,3 +356,78 @@ struct ctdb_request *ctdb_getifaces_send(struct ctdb_connection *ctdb,
 					NULL, 0, callback, private_data);
 }
 
+bool ctdb_getvnnmap_recv(struct ctdb_connection *ctdb,
+			 struct ctdb_request *req,
+			 struct ctdb_vnn_map **vnnmap)
+{
+	struct ctdb_reply_control *reply;
+	struct ctdb_vnn_map_wire *map;
+	struct ctdb_vnn_map *tmap;
+	int len;
+
+	*vnnmap = NULL;
+	reply = unpack_reply_control(req, CTDB_CONTROL_GETVNNMAP);
+	if (!reply) {
+		return false;
+	}
+	if (reply->status == -1) {
+		DEBUG(ctdb, LOG_ERR, "ctdb_getvnnmap_recv: status -1");
+		return false;
+	}
+	if (reply->datalen == 0) {
+		DEBUG(ctdb, LOG_ERR, "ctdb_getvnnmap_recv: returned data is 0 bytes");
+		return false;
+	}
+
+	len = offsetof(struct ctdb_vnn_map_wire, map);
+	if (len > reply->datalen) {
+		DEBUG(ctdb, LOG_ERR, "ctdb_getvnnmap_recv: returned data is %d bytes but %d is minimum", reply->datalen,  (int)offsetof(struct ctdb_vnn_map_wire, map));
+		return false;
+	}
+
+	map = (struct ctdb_vnn_map_wire *)(reply->data);
+	len += map->size * sizeof(uint32_t);
+
+	if (len != reply->datalen) {
+		DEBUG(ctdb, LOG_ERR, "ctdb_getvnnmap_recv: returned data is %d bytes but should be %d", reply->datalen,  len);
+		return false;
+	}
+
+	tmap = malloc(sizeof(struct ctdb_vnn_map));
+	if (tmap == NULL) {
+		DEBUG(ctdb, LOG_ERR, "ctdb_getvnnmap_recv: failed to malloc buffer");
+		return false;
+	}
+
+	tmap->generation = map->generation;
+	tmap->size       = map->size;
+	tmap->map        = malloc(sizeof(uint32_t) * map->size);
+	if (tmap->map == NULL) {
+		DEBUG(ctdb, LOG_ERR, "ctdb_getvnnmap_recv: failed to malloc buffer");
+		free(tmap);
+		return false;
+	}
+
+	memcpy(tmap->map, map->map, sizeof(uint32_t)*map->size);
+
+	*vnnmap = tmap;
+
+	return true;
+}
+
+void ctdb_free_vnnmap(struct ctdb_vnn_map *vnnmap)
+{
+	free(vnnmap->map);
+	free(vnnmap);
+}
+
+struct ctdb_request *ctdb_getvnnmap_send(struct ctdb_connection *ctdb,
+					 uint32_t destnode,
+					 ctdb_callback_t callback,
+					 void *private_data)
+{
+	return new_ctdb_control_request(ctdb, CTDB_CONTROL_GETVNNMAP,
+					destnode,
+					NULL, 0, callback, private_data);
+}
+
diff --git a/libctdb/sync.c b/libctdb/sync.c
index 9567d96..f2b6957 100644
--- a/libctdb/sync.c
+++ b/libctdb/sync.c
@@ -300,3 +300,22 @@ bool ctdb_getifaces(struct ctdb_connection *ctdb,
 	return ret;
 }
 
+bool ctdb_getvnnmap(struct ctdb_connection *ctdb,
+		    uint32_t destnode, struct ctdb_vnn_map **vnnmap)
+{
+	struct ctdb_request *req;
+	bool done = false;
+	bool ret = false;
+
+	*vnnmap = NULL;
+
+	req = synchronous(ctdb,
+			  ctdb_getvnnmap_send(ctdb, destnode, set, &done),
+			  &done);
+	if (req != NULL) {
+		ret = ctdb_getvnnmap_recv(ctdb, req, vnnmap);
+		ctdb_request_free(req);
+	}
+	return ret;
+}
+
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 210074c..6a46248 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-tests/scripts/run_tests -s tests/simple/*.sh || exit 1
+tests/scripts/run_tests -s ${*:-tests/simple/*.sh} || exit 1
 
 echo "All OK"
 exit 0
diff --git a/tests/src/ctdb_test.c b/tests/src/ctdb_test.c
index 533f3f4..83322d0 100644
--- a/tests/src/ctdb_test.c
+++ b/tests/src/ctdb_test.c
@@ -20,11 +20,41 @@
 #ifndef _CTDBD_TEST_C
 #define _CTDBD_TEST_C
 
+#ifdef CTDB_TEST_USE_MAIN
+
+/* Use main, stubify some stuff */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <sys/socket.h>
+#include "lib/tevent/tevent.h"
+
+#define tevent_context_init(x) tevent_context_init_foobar(x)
+struct tevent_context *tevent_context_init_foobar(TALLOC_CTX *mem_ctx);
+#define tevent_loop_allow_nesting(x) tevent_loop_allow_nesting_foobar(x)
+void tevent_loop_allow_nesting_foobar(struct tevent_context *ev);
+#define ctdb_cmdline_client(x, y) ctdb_cmdline_client_foobar(x, y)
+#define ctdb_get_socketname(x) ctdb_get_socketname_foobar(x)
+
+#else
+
+/* Define our own main() and usage() functions */
 #define main(argc, argv) main_foobar(argc, argv)
 #define usage usage_foobar
+
+#endif /* CTDB_TEST_USE_MAIN */
+
 #include "tools/ctdb.c"
+
+#ifdef CTDB_TEST_USE_MAIN
+#undef tevent_context_init
+#undef tevent_loop_allow_nesting
+#undef ctdb_cmdline_client
+#undef ctdb_get_socketname
+#else
 #undef main
 #undef usage
+#endif /* CTDB_TEST_USE_MAIN */
+ 
 
 #undef TIMELIMIT
 #include "tools/ctdb_vacuum.c"
diff --git a/tests/src/ctdb_parse_nodestring.c b/tests/src/ctdb_tool_libctdb.c
similarity index 65%
rename from tests/src/ctdb_parse_nodestring.c
rename to tests/src/ctdb_tool_libctdb.c
index e467c36..9b86bda 100644
--- a/tests/src/ctdb_parse_nodestring.c
+++ b/tests/src/ctdb_tool_libctdb.c
@@ -1,5 +1,5 @@
 /* 
-   Tests for tools/ctdb.c:parse_nodestring()
+   Tests for tools/ctdb.c and libctdb stubs
 
    Copyright (C) Martin Schwenke 2011
 
@@ -30,6 +30,63 @@ static void test_read_nodemap(void)
 	ctdb_disconnect(ctdb);
 }
 
+static void test_read_ifaces(void)
+{
+	struct ctdb_connection *ctdb = ctdb_connect("foo", NULL, NULL);
+
+	libctdb_test_read_ifaces(ctdb);
+	libctdb_test_print_ifaces(ctdb);
+
+	ctdb_disconnect(ctdb);
+}
+
+static void test_read_vnnmap(void)
+{
+	struct ctdb_connection *ctdb = ctdb_connect("foo", NULL, NULL);
+
+	libctdb_test_read_vnnmap(ctdb);
+	libctdb_test_print_vnnmap(ctdb);
+
+	ctdb_disconnect(ctdb);
+}
+
+static void test_fake_setup(void)
+{
+	bool first = true;
+	struct ctdb_connection *ctdb = ctdb_connect("foo", NULL, NULL);
+
+	libctdb_test_fake_setup(ctdb);
+
+	if (ctdb->nodemap != NULL) {
+		if (!first) {
+			printf("\n");
+		}
+		printf("NODEMAP\n");
+		libctdb_test_print_nodemap(ctdb);
+		first = false;
+	}
+
+	if (ctdb->ifaces != NULL) {
+		if (!first) {
+			printf("\n");
+		}
+		printf("IFACES\n");
+		libctdb_test_print_ifaces(ctdb);
+		first = false;
+	}
+
+	if (ctdb->vnnmap != NULL) {
+		if (!first) {
+			printf("\n");
+		}
+		printf("VNNMAP\n");
+		libctdb_test_print_vnnmap(ctdb);
+		first = false;
+	}
+
+	ctdb_disconnect(ctdb);
+}
+
 static const char * decode_pnn_mode(uint32_t pnn_mode)
 {
 	int i;
@@ -90,7 +147,8 @@ static void test_parse_nodestring(const char *nodestring_s,
 
 	libctdb_test_read_nodemap(ctdb);
 
-	if (parse_nodestring(NULL, nodestring, dd_ok, &nodes, &pnn_mode)) {
+	if (parse_nodestring(NULL, nodestring, CTDB_CURRENT_NODE, dd_ok,
+			     &nodes, &pnn_mode)) {
 		print_nodes(nodes, pnn_mode);
 	}
 
@@ -99,7 +157,7 @@ static void test_parse_nodestring(const char *nodestring_s,
 
 static void usage(void)
 {
-	fprintf(stderr, "usage: ctdb_parse_nodelist <op>\n");
+	fprintf(stderr, "usage: ctdb_tool_libctdb <op>\n");
 	exit(1);
 }
 
@@ -116,6 +174,12 @@ int main(int argc, const char *argv[])
 
 	if (argc == 2 && strcmp(argv[1], "read_nodemap") == 0) {
 		test_read_nodemap();
+	} else if (argc == 2 && strcmp(argv[1], "read_ifaces") == 0) {
+		test_read_ifaces();
+	} else if (argc == 2 && strcmp(argv[1], "read_vnnmap") == 0) {
+		test_read_vnnmap();
+	} else if (argc == 2 && strcmp(argv[1], "fake_setup") == 0) {
+		test_fake_setup();
 	} else if (argc == 4 && strcmp(argv[1], "parse_nodestring") == 0) {
 		test_parse_nodestring(argv[2], argv[3]);
 	} else {
diff --git a/tests/src/ctdb_tool_stubby.c b/tests/src/ctdb_tool_stubby.c
new file mode 100644
index 0000000..c388c63
--- /dev/null
+++ b/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;
+


-- 
CTDB repository


More information about the samba-cvs mailing list