1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

Tests: change ctdb_takeover_tests.c to include ctdbd code

Do this instead of linking to it.  This means that, after previous
cleanups, we can fix ctdb_takeover.c to use static functions when
appropriate and simply include all the code we need to run tests.

To make this reusable in other tests, new file ctdbd_tests.c does all
of the relevant including.  ctdb_takeover_tests.c just includes that
file.

Test objects built in this way can depend on new Makefile macro
$(CTDB_TEST_C), which contains ctdbd_tests.c and everything it
includes.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 41869d42194b74db43a176a068e96e411007e5f2)
This commit is contained in:
Martin Schwenke 2011-11-11 14:15:52 +11:00
parent a2ba5342f5
commit bbe7cfd28f
3 changed files with 106 additions and 13 deletions

View File

@ -217,11 +217,19 @@ tests/bin/ctdb_transaction: $(CTDB_CLIENT_OBJ) tests/src/ctdb_transaction.o
@echo Linking $@
@$(CC) $(CFLAGS) -o $@ tests/src/ctdb_transaction.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
CTDB_TAKEOVER_OBJ = $(CTDB_SERVER_OBJ:server/ctdbd.o=)
CTDB_SERVER_MOST_OBJ = $(CTDB_SERVER_OBJ:server/ctdbd.o=)
CTDB_TEST_C = $(CTDB_SERVER_MOST_OBJ:.o=.c) tests/src/ctdbd_test.c
CTDB_TEST_OBJ = @TALLOC_OBJ@ @TDB_OBJ@ \
@LIBREPLACEOBJ@ $(EXTRA_OBJ) @TEVENT_OBJ@
tests/bin/ctdb_takeover_tests: $(CTDB_TAKEOVER_OBJ) tests/src/ctdb_takeover_tests.o
CTDB_TEST_DEPENDS = $(CTDB_TEST_OBJ) $(CTDB_SERVER_MOST_C) \
tests/src/ctdbd_test.c
tests/src/ctdb_takeover_tests.o: tests/src/ctdb_takeover_tests.c $(CTDB_TEST_C)
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_TAKEOVER_OBJ) $(LIB_FLAGS)
@$(CC) $(CFLAGS) -o $@ tests/src/ctdb_takeover_tests.o $(CTDB_TEST_OBJ) $(LIB_FLAGS)
tests/bin/ibwrapper_test: $(CTDB_CLIENT_OBJ) ib/ibwrapper_test.o
@echo Linking $@

View File

@ -17,21 +17,12 @@
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "../include/ctdb_private.h"
#include "ctdbd_test.c"
/* This is lazy... but it is test code! */
#define CTDB_TEST_MAX_NODES 256
#define CTDB_TEST_MAX_IPS 256
/*
* Need these, since they're defined in ctdbd.c but we can't link
* that.
*/
int script_log_level;
bool fast_start;
void ctdb_load_nodes_file(struct ctdb_context *ctdb) {}
/* Format of each line is "IP pnn" - the separator has to be at least
* 1 space (not a tab or whatever - a space!).
*/

View File

@ -0,0 +1,94 @@
/*
ctdbd 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
#include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h"
#include "ctdb_private.h"
/*
* Need these, since they're defined in ctdbd.c but we can't include
* that.
*/
int script_log_level;
bool fast_start;
void ctdb_load_nodes_file(struct ctdb_context *ctdb) {}
/* UTIL_OBJ */
#include "lib/util/idtree.c"
#include "lib/util/db_wrap.c"
#include "lib/util/strlist.c"
#include "lib/util/util.c"
#include "lib/util/util_time.c"
#include "lib/util/util_file.c"
#include "lib/util/fault.c"
#include "lib/util/substitute.c"
#include "lib/util/signal.c"
/* CTDB_COMMON_OBJ */
#include "common/ctdb_io.c"
#include "common/ctdb_util.c"
#include "common/ctdb_ltdb.c"
#include "common/ctdb_message.c"
#include "common/cmdline.c"
#include "lib/util/debug.c"
#include "common/rb_tree.c"
#ifdef _LINUX_ERRNO_H
#include "common/system_linux.c"
#endif
#include "common/system_common.c"
#include "common/ctdb_logging.c"
/* CTDB_SERVER_OBJ */
#include "server/ctdb_daemon.c"
#include "server/ctdb_lockwait.c"
#include "server/ctdb_recoverd.c"
#include "server/ctdb_recover.c"
#include "server/ctdb_freeze.c"
#include "server/ctdb_tunables.c"
#include "server/ctdb_monitor.c"
#include "server/ctdb_server.c"
#include "server/ctdb_control.c"
#include "server/ctdb_call.c"
#include "server/ctdb_ltdb_server.c"
#include "server/ctdb_traverse.c"
#include "server/eventscript.c"
#include "server/ctdb_takeover.c"
#include "server/ctdb_serverids.c"
#include "server/ctdb_persistent.c"
#include "server/ctdb_keepalive.c"
#include "server/ctdb_logging.c"
#include "server/ctdb_uptime.c"
#include "server/ctdb_vacuum.c"
#include "server/ctdb_banning.c"
#include "server/ctdb_statistics.c"
/* CTDB_CLIENT_OBJ */
#include "client/ctdb_client.c"
/* CTDB_TCP_OBJ */
#include "tcp/tcp_connect.c"
#include "tcp/tcp_io.c"
#include "tcp/tcp_init.c"
#endif /* _CTDBD_TEST_C */