The branch, master has been updated via e3fdb0a ctdb-tests: rename tests from stubby.* to ctdb.* via 92c8bd7 ctdb-tests: Fix output for ctdb reloadnodes tests via 92d3704 ctdb-tests: Fix output for ctdb lvs test via 047886e ctdb-tests: Fix output for ctdb getcapabilities test via 90f04c7 ctdb-tests: Remove ctdb tool stub code via 1394856 ctdb-tests: Use fake_ctdbd for ctdb tool tests instead of ctdb stub via 0711904 ctdb-tests: Add fake ctdb daemon implementation for testing via 627e9a9 ctdb-tool: All errors should be logged via stderr via bbadce4 ctdb-tool: Add test-hooks to enable testing of the tool via c8ed16b ctdb-tests: Remove ctdb reloadips tests via e36a201 ctdb-tool: Remove xpnn command and related tests via e35ffb0 ctdb-protocol: Add function to compare ctdb_sock_addr via ad0286c ctdb-natgw: Allow override of CTDB for testing via 60d0725 ctdb-lvs: Allow override of CTDB for testing via 63f7466 ctdb-tests: Get rid of ctdb func tests from 91f6439 tests/dcerpc: add tests for string allocation and deletion
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit e3fdb0a9b6a19a48c6ccd72b37485ae4a8217464 Author: Amitay Isaacs <ami...@gmail.com> Date: Tue May 10 18:28:40 2016 +1000 ctdb-tests: rename tests from stubby.* to ctdb.* These tests do not use ctdb tool stub anymore. Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> Autobuild-User(master): Amitay Isaacs <ami...@samba.org> Autobuild-Date(master): Wed May 11 02:19:20 CEST 2016 on sn-devel-144 commit 92c8bd73e9b0aa53ac6f5eedd97ff4adcefe254a Author: Amitay Isaacs <ami...@gmail.com> Date: Thu Apr 28 15:12:40 2016 +1000 ctdb-tests: Fix output for ctdb reloadnodes tests Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 92d37043756f667b6b8f09cf8a9d48081579c08c Author: Amitay Isaacs <ami...@gmail.com> Date: Thu Apr 28 18:43:56 2016 +1000 ctdb-tests: Fix output for ctdb lvs test Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 047886e414e49287f44617136946815bb48f64f7 Author: Amitay Isaacs <ami...@gmail.com> Date: Thu Apr 28 18:43:32 2016 +1000 ctdb-tests: Fix output for ctdb getcapabilities test Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 90f04c7fc384016a0fdf6f1c51c1b53c9361825d Author: Amitay Isaacs <ami...@gmail.com> Date: Tue May 10 18:38:56 2016 +1000 ctdb-tests: Remove ctdb tool stub code Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 13948562c461a206e9a1613e802eeb0a87de329d Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Apr 27 01:42:33 2016 +1000 ctdb-tests: Use fake_ctdbd for ctdb tool tests instead of ctdb stub Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 07119045f0669cb4398d8cf138ac0c7980b98d42 Author: Amitay Isaacs <ami...@gmail.com> Date: Fri Apr 22 17:30:52 2016 +1000 ctdb-tests: Add fake ctdb daemon implementation for testing Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 627e9a99f458bb01232794fcb23865a7d20b48ce Author: Amitay Isaacs <ami...@gmail.com> Date: Fri May 6 14:06:43 2016 +1000 ctdb-tool: All errors should be logged via stderr Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit bbadce47b912c2b1530f7b7249592b813fe0e9ac Author: Amitay Isaacs <ami...@gmail.com> Date: Thu Apr 28 13:03:35 2016 +1000 ctdb-tool: Add test-hooks to enable testing of the tool Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit c8ed16bdc9acfd3441d742a10eb98a768ffcb881 Author: Amitay Isaacs <ami...@gmail.com> Date: Thu Apr 28 15:40:22 2016 +1000 ctdb-tests: Remove ctdb reloadips tests Since there are no public IPs setup, these tests do not really test the functionality. Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit e36a20145dab1b65825827b983fb73bd9b8cd235 Author: Amitay Isaacs <ami...@gmail.com> Date: Thu Apr 28 13:32:31 2016 +1000 ctdb-tool: Remove xpnn command and related tests It's unreliable and should not be used. Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit e35ffb06bcc9a92cbed921a44e73ea022ce472bd Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Apr 27 18:30:12 2016 +1000 ctdb-protocol: Add function to compare ctdb_sock_addr Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit ad0286c744b2089540c883b77b8545ad3bc00b82 Author: Amitay Isaacs <ami...@gmail.com> Date: Thu Apr 28 13:11:29 2016 +1000 ctdb-natgw: Allow override of CTDB for testing Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 60d0725f1f3305f3caa4f1ae4b749ac361d4a1f5 Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Apr 27 01:43:39 2016 +1000 ctdb-lvs: Allow override of CTDB for testing Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 63f7466490d22a8cf3946f8330b87d077e463e34 Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Apr 27 12:21:18 2016 +1000 ctdb-tests: Get rid of ctdb func tests This tested parse_nodestring function from tools/ctdb.c. However, ctdb.c is soon going to be replaced with the code using new client API. Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> ----------------------------------------------------------------------- Summary of changes: ctdb/protocol/protocol_api.h | 1 + ctdb/protocol/protocol_util.c | 33 + ctdb/tests/src/ctdb_functest.c | 189 -- ctdb/tests/src/ctdb_test.c | 182 -- ctdb/tests/src/ctdb_test_stubs.c | 861 -------- ctdb/tests/src/fake_ctdbd.c | 2303 ++++++++++++++++++++ ...bilities.001.sh => ctdb.getcapabilities.001.sh} | 0 ...bilities.002.sh => ctdb.getcapabilities.002.sh} | 0 ctdb/tests/tool/ctdb.getcapabilities.003.sh | 37 + ...bilities.004.sh => ctdb.getcapabilities.004.sh} | 0 ...ubby.listnodes.001.sh => ctdb.listnodes.001.sh} | 0 ...ubby.listnodes.002.sh => ctdb.listnodes.002.sh} | 0 .../tool/{stubby.lvs.001.sh => ctdb.lvs.001.sh} | 0 .../tool/{stubby.lvs.002.sh => ctdb.lvs.002.sh} | 0 .../tool/{stubby.lvs.003.sh => ctdb.lvs.003.sh} | 0 .../tool/{stubby.lvs.004.sh => ctdb.lvs.004.sh} | 0 .../tool/{stubby.lvs.005.sh => ctdb.lvs.005.sh} | 0 .../tool/{stubby.lvs.006.sh => ctdb.lvs.006.sh} | 0 .../tool/{stubby.lvs.007.sh => ctdb.lvs.007.sh} | 0 ctdb/tests/tool/ctdb.lvs.008.sh | 88 + .../{stubby.natgw.001.sh => ctdb.natgw.001.sh} | 0 .../{stubby.natgw.002.sh => ctdb.natgw.002.sh} | 0 .../{stubby.natgw.003.sh => ctdb.natgw.003.sh} | 0 .../{stubby.natgw.004.sh => ctdb.natgw.004.sh} | 0 .../{stubby.natgw.005.sh => ctdb.natgw.005.sh} | 0 .../{stubby.natgw.006.sh => ctdb.natgw.006.sh} | 0 .../{stubby.natgw.007.sh => ctdb.natgw.007.sh} | 0 .../{stubby.natgw.008.sh => ctdb.natgw.008.sh} | 0 ...by.nodestatus.001.sh => ctdb.nodestatus.001.sh} | 0 ...by.nodestatus.002.sh => ctdb.nodestatus.002.sh} | 0 .../{stubby.recover.001.sh => ctdb.recover.001.sh} | 0 ....reloadnodes.001.sh => ctdb.reloadnodes.001.sh} | 0 ....reloadnodes.002.sh => ctdb.reloadnodes.002.sh} | 0 ....reloadnodes.003.sh => ctdb.reloadnodes.003.sh} | 3 +- ....reloadnodes.011.sh => ctdb.reloadnodes.011.sh} | 3 - ....reloadnodes.012.sh => ctdb.reloadnodes.012.sh} | 2 - ....reloadnodes.013.sh => ctdb.reloadnodes.013.sh} | 0 ....reloadnodes.014.sh => ctdb.reloadnodes.014.sh} | 2 - ....reloadnodes.015.sh => ctdb.reloadnodes.015.sh} | 0 ....reloadnodes.016.sh => ctdb.reloadnodes.016.sh} | 2 - ....reloadnodes.017.sh => ctdb.reloadnodes.017.sh} | 0 ....reloadnodes.018.sh => ctdb.reloadnodes.018.sh} | 3 - ....reloadnodes.019.sh => ctdb.reloadnodes.019.sh} | 2 - ....reloadnodes.020.sh => ctdb.reloadnodes.020.sh} | 2 - ....reloadnodes.021.sh => ctdb.reloadnodes.021.sh} | 2 - ....reloadnodes.022.sh => ctdb.reloadnodes.022.sh} | 0 ....reloadnodes.023.sh => ctdb.reloadnodes.023.sh} | 2 - ....reloadnodes.024.sh => ctdb.reloadnodes.024.sh} | 0 .../{stubby.status.001.sh => ctdb.status.001.sh} | 0 .../{stubby.status.002.sh => ctdb.status.002.sh} | 0 ctdb/tests/tool/func.parse_nodestring.001.sh | 16 - ctdb/tests/tool/func.parse_nodestring.002.sh | 16 - ctdb/tests/tool/func.parse_nodestring.003.sh | 15 - ctdb/tests/tool/scripts/local.sh | 49 +- ctdb/tests/tool/stubby.getcapabilities.003.sh | 27 - ctdb/tests/tool/stubby.lvs.008.sh | 66 - ctdb/tests/tool/stubby.reloadips.001.sh | 17 - ctdb/tests/tool/stubby.reloadips.002.sh | 25 - ctdb/tests/tool/stubby.reloadips.003.sh | 19 - ctdb/tests/tool/stubby.xpnn.001.sh | 20 - ctdb/tests/tool/stubby.xpnn.002.sh | 20 - ctdb/tests/tool/stubby.xpnn.003.sh | 24 - ctdb/tests/tool/stubs/ctdb | 27 - ctdb/tools/ctdb.c | 42 +- ctdb/tools/ctdb_lvs | 10 +- ctdb/tools/ctdb_natgw | 8 +- ctdb/wscript | 16 +- 67 files changed, 2532 insertions(+), 1602 deletions(-) delete mode 100644 ctdb/tests/src/ctdb_functest.c delete mode 100644 ctdb/tests/src/ctdb_test.c delete mode 100644 ctdb/tests/src/ctdb_test_stubs.c create mode 100644 ctdb/tests/src/fake_ctdbd.c rename ctdb/tests/tool/{stubby.getcapabilities.001.sh => ctdb.getcapabilities.001.sh} (100%) rename ctdb/tests/tool/{stubby.getcapabilities.002.sh => ctdb.getcapabilities.002.sh} (100%) create mode 100755 ctdb/tests/tool/ctdb.getcapabilities.003.sh rename ctdb/tests/tool/{stubby.getcapabilities.004.sh => ctdb.getcapabilities.004.sh} (100%) rename ctdb/tests/tool/{stubby.listnodes.001.sh => ctdb.listnodes.001.sh} (100%) rename ctdb/tests/tool/{stubby.listnodes.002.sh => ctdb.listnodes.002.sh} (100%) rename ctdb/tests/tool/{stubby.lvs.001.sh => ctdb.lvs.001.sh} (100%) rename ctdb/tests/tool/{stubby.lvs.002.sh => ctdb.lvs.002.sh} (100%) rename ctdb/tests/tool/{stubby.lvs.003.sh => ctdb.lvs.003.sh} (100%) rename ctdb/tests/tool/{stubby.lvs.004.sh => ctdb.lvs.004.sh} (100%) rename ctdb/tests/tool/{stubby.lvs.005.sh => ctdb.lvs.005.sh} (100%) rename ctdb/tests/tool/{stubby.lvs.006.sh => ctdb.lvs.006.sh} (100%) rename ctdb/tests/tool/{stubby.lvs.007.sh => ctdb.lvs.007.sh} (100%) create mode 100755 ctdb/tests/tool/ctdb.lvs.008.sh rename ctdb/tests/tool/{stubby.natgw.001.sh => ctdb.natgw.001.sh} (100%) rename ctdb/tests/tool/{stubby.natgw.002.sh => ctdb.natgw.002.sh} (100%) rename ctdb/tests/tool/{stubby.natgw.003.sh => ctdb.natgw.003.sh} (100%) rename ctdb/tests/tool/{stubby.natgw.004.sh => ctdb.natgw.004.sh} (100%) rename ctdb/tests/tool/{stubby.natgw.005.sh => ctdb.natgw.005.sh} (100%) rename ctdb/tests/tool/{stubby.natgw.006.sh => ctdb.natgw.006.sh} (100%) rename ctdb/tests/tool/{stubby.natgw.007.sh => ctdb.natgw.007.sh} (100%) rename ctdb/tests/tool/{stubby.natgw.008.sh => ctdb.natgw.008.sh} (100%) rename ctdb/tests/tool/{stubby.nodestatus.001.sh => ctdb.nodestatus.001.sh} (100%) rename ctdb/tests/tool/{stubby.nodestatus.002.sh => ctdb.nodestatus.002.sh} (100%) rename ctdb/tests/tool/{stubby.recover.001.sh => ctdb.recover.001.sh} (100%) rename ctdb/tests/tool/{stubby.reloadnodes.001.sh => ctdb.reloadnodes.001.sh} (100%) rename ctdb/tests/tool/{stubby.reloadnodes.002.sh => ctdb.reloadnodes.002.sh} (100%) rename ctdb/tests/tool/{stubby.reloadnodes.003.sh => ctdb.reloadnodes.003.sh} (83%) rename ctdb/tests/tool/{stubby.reloadnodes.011.sh => ctdb.reloadnodes.011.sh} (82%) rename ctdb/tests/tool/{stubby.reloadnodes.012.sh => ctdb.reloadnodes.012.sh} (86%) rename ctdb/tests/tool/{stubby.reloadnodes.013.sh => ctdb.reloadnodes.013.sh} (100%) rename ctdb/tests/tool/{stubby.reloadnodes.014.sh => ctdb.reloadnodes.014.sh} (86%) rename ctdb/tests/tool/{stubby.reloadnodes.015.sh => ctdb.reloadnodes.015.sh} (100%) rename ctdb/tests/tool/{stubby.reloadnodes.016.sh => ctdb.reloadnodes.016.sh} (86%) rename ctdb/tests/tool/{stubby.reloadnodes.017.sh => ctdb.reloadnodes.017.sh} (100%) rename ctdb/tests/tool/{stubby.reloadnodes.018.sh => ctdb.reloadnodes.018.sh} (84%) rename ctdb/tests/tool/{stubby.reloadnodes.019.sh => ctdb.reloadnodes.019.sh} (87%) rename ctdb/tests/tool/{stubby.reloadnodes.020.sh => ctdb.reloadnodes.020.sh} (87%) rename ctdb/tests/tool/{stubby.reloadnodes.021.sh => ctdb.reloadnodes.021.sh} (88%) rename ctdb/tests/tool/{stubby.reloadnodes.022.sh => ctdb.reloadnodes.022.sh} (100%) rename ctdb/tests/tool/{stubby.reloadnodes.023.sh => ctdb.reloadnodes.023.sh} (85%) rename ctdb/tests/tool/{stubby.reloadnodes.024.sh => ctdb.reloadnodes.024.sh} (100%) rename ctdb/tests/tool/{stubby.status.001.sh => ctdb.status.001.sh} (100%) rename ctdb/tests/tool/{stubby.status.002.sh => ctdb.status.002.sh} (100%) delete mode 100755 ctdb/tests/tool/func.parse_nodestring.001.sh delete mode 100755 ctdb/tests/tool/func.parse_nodestring.002.sh delete mode 100755 ctdb/tests/tool/func.parse_nodestring.003.sh delete mode 100755 ctdb/tests/tool/stubby.getcapabilities.003.sh delete mode 100755 ctdb/tests/tool/stubby.lvs.008.sh delete mode 100755 ctdb/tests/tool/stubby.reloadips.001.sh delete mode 100755 ctdb/tests/tool/stubby.reloadips.002.sh delete mode 100755 ctdb/tests/tool/stubby.reloadips.003.sh delete mode 100755 ctdb/tests/tool/stubby.xpnn.001.sh delete mode 100755 ctdb/tests/tool/stubby.xpnn.002.sh delete mode 100755 ctdb/tests/tool/stubby.xpnn.003.sh delete mode 100755 ctdb/tests/tool/stubs/ctdb Changeset truncated at 500 lines: diff --git a/ctdb/protocol/protocol_api.h b/ctdb/protocol/protocol_api.h index 0f781cc..17ed8c3 100644 --- a/ctdb/protocol/protocol_api.h +++ b/ctdb/protocol/protocol_api.h @@ -687,5 +687,6 @@ const char *ctdb_event_to_string(enum ctdb_event event); enum ctdb_event ctdb_event_from_string(const char *event_str); const char *ctdb_sock_addr_to_string(TALLOC_CTX *mem_ctx, ctdb_sock_addr *addr); +bool ctdb_sock_addr_same(ctdb_sock_addr *addr1, ctdb_sock_addr *addr2); #endif /* __CTDB_PROTOCOL_API_H__ */ diff --git a/ctdb/protocol/protocol_util.c b/ctdb/protocol/protocol_util.c index 823849f..636e3a8 100644 --- a/ctdb/protocol/protocol_util.c +++ b/ctdb/protocol/protocol_util.c @@ -140,3 +140,36 @@ const char *ctdb_sock_addr_to_string(TALLOC_CTX *mem_ctx, ctdb_sock_addr *addr) return cip; } + +bool ctdb_sock_addr_same(ctdb_sock_addr *addr1, ctdb_sock_addr *addr2) +{ + if (addr1->sa.sa_family != addr2->sa.sa_family) { + return false; + } + + switch (addr1->sa.sa_family) { + case AF_INET: + if (addr1->ip.sin_addr.s_addr != addr2->ip.sin_addr.s_addr) { + return false; + } + if (addr1->ip.sin_port != addr2->ip.sin_port) { + return false; + } + break; + + case AF_INET6: + if (memcmp(addr1->ip6.sin6_addr.s6_addr, + addr2->ip6.sin6_addr.s6_addr, 16) != 0) { + return false; + } + if (addr1->ip6.sin6_port != addr2->ip6.sin6_port) { + return false; + } + break; + + default: + return false; + } + + return true; +} diff --git a/ctdb/tests/src/ctdb_functest.c b/ctdb/tests/src/ctdb_functest.c deleted file mode 100644 index 9eaae55..0000000 --- a/ctdb/tests/src/ctdb_functest.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - Tests for tools/ctdb.c and CTDB client 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_OVERRIDE_MAIN -#include "ctdb_test.c" - -static void test_read_nodemap(void) -{ - struct ctdb_context *ctdb = talloc_zero(NULL, struct ctdb_context); - - ctdb_test_stubs_read_nodemap(ctdb); - ctdb_test_stubs_print_nodemap(ctdb); - - talloc_free(ctdb); -} - -static void test_read_ifaces(void) -{ - struct ctdb_context *ctdb = talloc_zero(NULL, struct ctdb_context); - - ctdb_test_stubs_read_ifaces(ctdb); - ctdb_test_stubs_print_ifaces(ctdb); - - talloc_free(ctdb); -} - -static void test_read_vnnmap(void) -{ - struct ctdb_context *ctdb = talloc_zero(NULL, struct ctdb_context); - - ctdb_test_stubs_read_vnnmap(ctdb); - ctdb_test_stubs_print_vnnmap(ctdb); - - talloc_free(ctdb); -} - -static void test_fake_setup(void) -{ - bool first = true; - struct ctdb_context *ctdb = talloc_zero(NULL, struct ctdb_context); - - ctdb_test_stubs_fake_setup(ctdb); - - if (ctdb->nodes != NULL) { - if (!first) { - printf("\n"); - } - printf("NODEMAP\n"); - ctdb_test_stubs_print_nodemap(ctdb); - first = false; - } - - if (ctdb->ifaces != NULL) { - if (!first) { - printf("\n"); - } - printf("IFACES\n"); - ctdb_test_stubs_print_ifaces(ctdb); - first = false; - } - - if (ctdb->vnn_map != NULL) { - if (!first) { - printf("\n"); - } - printf("VNNMAP\n"); - ctdb_test_stubs_print_vnnmap(ctdb); - first = false; - } - - talloc_free(ctdb); -} - -static const char * decode_pnn_mode(uint32_t pnn_mode) -{ - int i; - static const struct { - uint32_t mode; - const char *name; - } pnn_modes[] = { - { CTDB_CURRENT_NODE, "CURRENT_NODE" }, - { CTDB_BROADCAST_ALL, "BROADCAST_ALL" }, - { CTDB_BROADCAST_VNNMAP, "BROADCAST_VNNMAP" }, - { CTDB_BROADCAST_CONNECTED, "BROADCAST_CONNECTED" }, - { CTDB_MULTICAST, "MULTICAST" }, - }; - - for (i = 0; i < ARRAY_SIZE(pnn_modes); i++) { - if (pnn_mode == pnn_modes[i].mode) { - return pnn_modes[i].name; - } - } - - return "PNN"; -} - -static void print_nodes(uint32_t *nodes, uint32_t pnn_mode) -{ - int i; - - printf("NODES:"); - for (i = 0; i < talloc_array_length(nodes); i++) { - printf(" %lu", (unsigned long) nodes[i]); - } - printf("\n"); - - printf("PNN MODE: %s (%lu)\n", - decode_pnn_mode(pnn_mode), (unsigned long) pnn_mode); -} - -static void test_parse_nodestring(const char *nodestring_s, - const char *dd_ok_s) -{ - const char *nodestring; - bool dd_ok; - struct ctdb_context *ctdb; - uint32_t *nodes; - uint32_t pnn_mode; - - nodestring = strcmp("", nodestring_s) == 0 ? NULL : nodestring_s; - - if (strcasecmp(dd_ok_s, "yes") == 0 || - strcmp(dd_ok_s, "true") == 0) { - dd_ok = true; - } else { - dd_ok = false; - } - - ctdb = talloc_zero(NULL, struct ctdb_context); - - ctdb_test_stubs_read_nodemap(ctdb); - - if (parse_nodestring(ctdb, NULL, nodestring, CTDB_CURRENT_NODE, dd_ok, - &nodes, &pnn_mode)) { - print_nodes(nodes, pnn_mode); - } - - talloc_free(ctdb); -} - -static void usage(void) -{ - fprintf(stderr, "usage: ctdb_tool_functest <op>\n"); - exit(1); -} - -int main(int argc, const char *argv[]) -{ - DEBUGLEVEL = DEBUG_DEBUG; - if (getenv("CTDB_TEST_LOGLEVEL")) { - DEBUGLEVEL = atoi(getenv("CTDB_TEST_LOGLEVEL")); - } - - if (argc < 2) { - usage(); - } - - 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 { - usage(); - } - - return 0; -} diff --git a/ctdb/tests/src/ctdb_test.c b/ctdb/tests/src/ctdb_test.c deleted file mode 100644 index a26d959..0000000 --- a/ctdb/tests/src/ctdb_test.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - ctdb test include file - - 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/>. -*/ - -#ifndef _CTDBD_TEST_C -#define _CTDBD_TEST_C - -#ifdef CTDB_TEST_OVERRIDE_MAIN - -/* Define our own main() and usage() functions */ -#define main(argc, argv) main_foobar(argc, argv) -int main_foobar(int argc, const char **argv); -#define usage usage_foobar - -#endif /* CTDB_TEST_USE_MAIN */ - -#define ctdb_cmdline_client(x, y) \ - ctdb_cmdline_client_stub(x, y) -#define tevent_context_init(x) \ - tevent_context_init_stub(x) -#define ctdb_ctrl_getnodemap(ctdb, timelimit, pnn, tmp_ctx, nodemap) \ - ctdb_ctrl_getnodemap_stub(ctdb, timelimit, pnn, tmp_ctx, nodemap) -#define ctdb_ctrl_getnodesfile(ctdb, timeout, destnode, mem_ctx, nodemap) \ - ctdb_ctrl_getnodesfile_stub(ctdb, timeout, destnode, mem_ctx, nodemap) -#define ctdb_ctrl_get_ifaces(ctdb, timelimit, pnn, tmp_ctx, ifaces) \ - ctdb_ctrl_get_ifaces_stub(ctdb, timelimit, pnn, tmp_ctx, ifaces) -#define ctdb_ctrl_getpnn(ctdb, timelimit, pnn) \ - ctdb_ctrl_getpnn_stub(ctdb, timelimit, pnn) -#define ctdb_ctrl_getrecmode(ctdb, tmp_ctx, timelimit, pnn, recmode) \ - ctdb_ctrl_getrecmode_stub(ctdb, tmp_ctx, timelimit, pnn, recmode) -#define ctdb_ctrl_setrecmode(ctdb, timeout, destnode, recmode) \ - ctdb_ctrl_setrecmode_stub(ctdb, timeout, destnode, recmode) -#define ctdb_ctrl_getrecmaster(ctdb, tmp_ctx, timelimit, pnn, recmaster) \ - ctdb_ctrl_getrecmaster_stub(ctdb, tmp_ctx, timelimit, pnn, recmaster) -#define ctdb_ctrl_getvnnmap(ctdb, timelimit, pnn, tmp_ctx, vnnmap) \ - ctdb_ctrl_getvnnmap_stub(ctdb, timelimit, pnn, tmp_ctx, vnnmap) -#define ctdb_ctrl_getdebseqnum(ctdb, timelimit, pnn, db_id, seqnum) \ - ctdb_ctrl_getvnnmap_stub(ctdb, timelimit, pnn, db_id, seqnum) -#define ctdb_client_set_message_handler(ctdb, srvid, handler, private_data) \ - ctdb_client_set_message_handler_stub(ctdb, srvid, handler, private_data) -#define ctdb_client_remove_message_handler(ctdb, srvid, private_data) \ - ctdb_client_remove_message_handler_stub(ctdb, srvid, private_data) -#define ctdb_client_send_message(ctdb, pnn, srvid, data) \ - ctdb_client_send_message_stub(ctdb, pnn, srvid, data) -#define ctdb_client_check_message_handlers(ctdb, ids, argc, result) \ - ctdb_client_check_message_handlers_stub(ctdb, ids, argc, result) -#define ctdb_ctrl_getcapabilities(ctdb, timeout, destnode, capabilities) \ - ctdb_ctrl_getcapabilities_stub(ctdb, timeout, destnode, capabilities) -#define ctdb_ctrl_reload_nodes_file(ctdb, timeout, destnode) \ - ctdb_ctrl_reload_nodes_file_stub(ctdb, timeout, destnode) -#define ctdb_sys_have_ip(addr) \ - ctdb_sys_have_ip_stub(addr) -#define ctdb_client_async_control(ctdb, opcode, nodes, srvid, timeout, dont_log_errors, data, client_callback, fail_callback, callback_data) \ - ctdb_client_async_control_stub(ctdb, opcode, nodes, srvid, timeout, dont_log_errors, data, client_callback, fail_callback, callback_data) -#define ctdb_get_capabilities(ctdb, mem_ctx, timeout, nodemap) \ - ctdb_get_capabilities_stub(ctdb, mem_ctx, timeout, nodemap) - -#include "tools/ctdb.c" - -#ifndef CTDB_TEST_USE_MAIN -#undef main -#undef usage -#endif /* CTDB_TEST_USE_MAIN */ - -#undef ctdb_cmdline_client -#undef tevent_context_init -/* This is called in client/ctdb_client.c so needs a declaration... */ -struct ctdb_context *ctdb_cmdline_client(struct tevent_context *ev, - struct timeval req_timeout); -struct tevent_context *tevent_context_init(TALLOC_CTX *mem_ctx); -#include "common/cmdline.c" - -#undef ctdb_ctrl_getnodemap -#undef ctdb_ctrl_getnodesfile -#undef ctdb_ctrl_get_ifaces -#undef ctdb_ctrl_getpnn -#undef ctdb_ctrl_getrecmode -#undef ctdb_ctrl_setrecmode -#undef ctdb_ctrl_getrecmaster -#undef ctdb_ctrl_getvnnmap -#undef ctdb_ctrl_getdebseqnum -#undef ctdb_client_set_message_handler -#undef ctdb_client_remove_message_handler -#undef ctdb_client_send_message -#undef ctdb_client_check_message_handlers -#undef ctdb_ctrl_getcapabilities -#undef ctdb_ctrl_reload_nodes_file -#undef ctdb_sys_have_ip -#undef ctdb_client_async_control -#undef ctdb_get_capabilities - -int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb, - struct timeval timeout, uint32_t destnode, - TALLOC_CTX *mem_ctx, struct ctdb_node_map_old **nodemap); -int ctdb_ctrl_getnodesfile(struct ctdb_context *ctdb, - struct timeval timeout, uint32_t destnode, - TALLOC_CTX *mem_ctx, - struct ctdb_node_map_old **nodemap); -int ctdb_ctrl_get_ifaces(struct ctdb_context *ctdb, - struct timeval timeout, uint32_t destnode, - TALLOC_CTX *mem_ctx, - struct ctdb_iface_list_old **ifaces); -int ctdb_ctrl_getpnn(struct ctdb_context *ctdb, struct timeval timeout, - uint32_t destnode); -int ctdb_ctrl_getrecmode(struct ctdb_context *ctdb, - TALLOC_CTX *mem_ctx, struct timeval timeout, - uint32_t destnode, uint32_t *recmode); -int ctdb_ctrl_setrecmode(struct ctdb_context *ctdb, struct timeval timeout, - uint32_t destnode, uint32_t recmode); -int ctdb_ctrl_getrecmaster(struct ctdb_context *ctdb, - TALLOC_CTX *mem_ctx, struct timeval timeout, - uint32_t destnode, uint32_t *recmaster); -int ctdb_ctrl_getvnnmap(struct ctdb_context *ctdb, - struct timeval timeout, uint32_t destnode, - TALLOC_CTX *mem_ctx, struct ctdb_vnn_map **vnnmap); -int ctdb_ctrl_getdbseqnum(struct ctdb_context *ctdb, struct timeval timeout, - uint32_t destnode, uint32_t dbid, uint64_t *seqnum); -int ctdb_client_set_message_handler(struct ctdb_context *ctdb, - uint64_t srvid, - srvid_handler_fn handler, - void *private_data); -int ctdb_client_remove_message_handler(struct ctdb_context *ctdb, - uint64_t srvid, - void *private_data); -int ctdb_client_send_message(struct ctdb_context *ctdb, - uint32_t pnn, - uint64_t srvid, TDB_DATA data); -int ctdb_client_check_message_handlers(struct ctdb_context *ctdb, - uint64_t *ids, uint32_t num, - uint8_t *result); -int ctdb_ctrl_getcapabilities(struct ctdb_context *ctdb, - struct timeval timeout, uint32_t destnode, - uint32_t *capabilities); -int ctdb_ctrl_reload_nodes_file(struct ctdb_context *ctdb, - struct timeval timeout, uint32_t destnode); -bool ctdb_sys_have_ip(ctdb_sock_addr *addr); -int -ctdb_client_async_control(struct ctdb_context *ctdb, - enum ctdb_controls opcode, - uint32_t *nodes, - uint64_t srvid, - struct timeval timeout, - bool dont_log_errors, - TDB_DATA data, - client_async_callback client_callback, - client_async_callback fail_callback, - void *callback_data); -struct ctdb_node_capabilities * -ctdb_get_capabilities(struct ctdb_context *ctdb, - TALLOC_CTX *mem_ctx, - struct timeval timeout, - struct ctdb_node_map_old *nodemap); - -#undef TIMELIMIT - -/* CTDB_COMMON_OBJ */ -#include "common/ctdb_io.c" -#include "common/ctdb_util.c" -#include "common/ctdb_ltdb.c" - -/* CTDB_CLIENT_OBJ */ -#include "client/ctdb_client.c" - -/* TEST STUBS */ -#include "ctdb_test_stubs.c" - -#endif /* _CTDBD_TEST_C */ diff --git a/ctdb/tests/src/ctdb_test_stubs.c b/ctdb/tests/src/ctdb_test_stubs.c deleted file mode 100644 index 8ed2840..0000000 --- a/ctdb/tests/src/ctdb_test_stubs.c +++ /dev/null @@ -1,861 +0,0 @@ -/* - Test stubs and support functions for some CTDB client functions - - 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/>. -*/ - -/* Useful for functions that don't get struct ctdb_context passed */ -static struct ctdb_context *ctdb_global; - -static struct ctdb_node_capabilities *global_caps = NULL; - -/* Read a nodemap from stdin. Each line looks like: - * <PNN> <FLAGS> [RECMASTER] [CURRENT] [CAPABILITIES] - * EOF or a blank line terminates input. - * - * By default, capablities for each node are - * CTDB_CAP_RECMASTER|CTDB_CAP_LMASTER. These 2 - * capabilities can be faked off by adding, for example, - * -CTDB_CAP_RECMASTER. - */ - -/* A fake flag that is only supported by some functions */ -#define NODE_FLAGS_FAKE_TIMEOUT 0x80000000 - -static void ctdb_test_stubs_read_nodemap(struct ctdb_context *ctdb) -{ - char line[1024]; - - TALLOC_FREE(ctdb->nodes); - ctdb->pnn = -1; - ctdb->num_nodes = 0; - - ctdb->nodes = NULL; - - while ((fgets(line, sizeof(line), stdin) != NULL) && - (line[0] != '\n')) { - uint32_t pnn, flags, capabilities; - char *tok, *t; - char *ip; - ctdb_sock_addr saddr; - - /* Get rid of pesky newline */ - if ((t = strchr(line, '\n')) != NULL) { - *t = '\0'; - } - -- Samba Shared Repository