From 873b9cadbcc363a9e5f450b0a1feb1cf2ce1e6c9 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Fri, 23 Aug 2013 17:21:24 +1000 Subject: [PATCH] tests: Remove unused test program ctdb_fetch_lock_once Signed-off-by: Amitay Isaacs --- Makefile.in | 9 +- tests/src/ctdb_fetch_lock_once.c | 146 ------------------------------- 2 files changed, 2 insertions(+), 153 deletions(-) delete mode 100644 tests/src/ctdb_fetch_lock_once.c diff --git a/Makefile.in b/Makefile.in index 41bdb7e9..148c1341 100755 --- a/Makefile.in +++ b/Makefile.in @@ -112,7 +112,6 @@ CTDB_SERVER_OBJ = server/ctdbd.o server/ctdb_daemon.o \ $(CTDB_CLIENT_OBJ) $(CTDB_TCP_OBJ) @INFINIBAND_WRAPPER_OBJ@ TEST_BINS=tests/bin/ctdb_bench tests/bin/ctdb_fetch tests/bin/ctdb_fetch_one \ - tests/bin/ctdb_fetch_lock_once \ tests/bin/ctdb_fetch_readonly_once tests/bin/ctdb_fetch_readonly_loop \ tests/bin/ctdb_store tests/bin/ctdb_trackingdb_test \ tests/bin/ctdb_randrec tests/bin/ctdb_persistent \ @@ -239,13 +238,9 @@ tests/bin/ctdb_fetch_one: $(CTDB_CLIENT_OBJ) tests/src/ctdb_fetch_one.o @echo Linking $@ $(WRAPPER) $(CC) $(CFLAGS) -o $@ tests/src/ctdb_fetch_one.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS) -tests/bin/ctdb_fetch_lock_once: libctdb/libctdb.a tests/src/ctdb_fetch_lock_once.o $(CTDB_EXTERNAL_OBJ) +tests/bin/ctdb_fetch_readonly_once: tests/src/ctdb_fetch_readonly_once.o $(CTDB_EXTERNAL_OBJ) @echo Linking $@ - $(WRAPPER) $(CC) $(CFLAGS) -o $@ tests/src/ctdb_fetch_lock_once.o $(CTDB_EXTERNAL_OBJ) libctdb/libctdb.a $(LIB_FLAGS) - -tests/bin/ctdb_fetch_readonly_once: libctdb/libctdb.a tests/src/ctdb_fetch_readonly_once.o $(CTDB_EXTERNAL_OBJ) - @echo Linking $@ - $(WRAPPER) $(CC) $(CFLAGS) -o $@ tests/src/ctdb_fetch_readonly_once.o $(CTDB_EXTERNAL_OBJ) libctdb/libctdb.a $(LIB_FLAGS) + $(WRAPPER) $(CC) $(CFLAGS) -o $@ tests/src/ctdb_fetch_readonly_once.o $(CTDB_EXTERNAL_OBJ) $(LIB_FLAGS) tests/bin/ctdb_fetch_readonly_loop: $(CTDB_CLIENT_OBJ) tests/src/ctdb_fetch_readonly_loop.o @echo Linking $@ diff --git a/tests/src/ctdb_fetch_lock_once.c b/tests/src/ctdb_fetch_lock_once.c deleted file mode 100644 index f92b0b45..00000000 --- a/tests/src/ctdb_fetch_lock_once.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - simple ctdb test tool - This test just fetch_locks a record and releases it once. - - Copyright (C) Ronnie Sahlberg 2009 - - 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 . -*/ - -#include "includes.h" -#include "system/filesys.h" -#include "popt.h" -#include -#include "ctdb.h" - -#define TESTKEY "testkey" - -static void rrl_cb(struct ctdb_db *ctdb_db, - struct ctdb_lock *lock, TDB_DATA outdata, void *private) -{ - bool *rrl_cb_called = private; - - printf("Record fetchlocked.\n"); - printf("Press enter to release the record ...\n"); - (void)getchar(); - printf("Record released.\n"); - - *rrl_cb_called = true; - return; -} - -/* - Just try locking/unlocking a single record once -*/ -static void fetch_lock_once(struct ctdb_connection *ctdb, struct ctdb_db *ctdb_db) -{ - TDB_DATA key; - bool rrl_cb_finished = false; - - key.dptr = discard_const(TESTKEY); - key.dsize = strlen(TESTKEY); - - printf("Trying to fetch lock the record ...\n"); - - /* In the non-contended case the callback might be invoked - * immediately, before ctdb_readrecordlock_async() returns. - * In the contended case the callback will be invoked later. - * - * Normally an application would not care whether the callback - * has already been invoked here or not, but if the application - * needs to know, it can use the *private_data pointer - * to pass data through to the callback and back. - */ - if (!ctdb_readrecordlock_async(ctdb_db, key, - rrl_cb, &rrl_cb_finished)) { - printf("Failed to send READRECORDLOCK\n"); - exit(10); - } - while (!rrl_cb_finished) { - struct pollfd pfd; - - pfd.fd = ctdb_get_fd(ctdb); - pfd.events = ctdb_which_events(ctdb); - if (poll(&pfd, 1, -1) < 0) { - printf("Poll failed"); - exit(10); - } - if (ctdb_service(ctdb, pfd.revents) < 0) { - printf("Failed to service\n"); - exit(10); - } - } -} - -/* - main program -*/ -int main(int argc, const char *argv[]) -{ - struct ctdb_connection *ctdb; - struct ctdb_db *ctdb_db; - - struct poptOption popt_options[] = { - POPT_AUTOHELP - POPT_TABLEEND - }; - int opt; - const char **extra_argv; - int extra_argc = 0; - poptContext pc; - - pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST); - - while ((opt = poptGetNextOpt(pc)) != -1) { - switch (opt) { - default: - fprintf(stderr, "Invalid option %s: %s\n", - poptBadOption(pc, 0), poptStrerror(opt)); - exit(1); - } - } - - /* setup the remaining options for the main program to use */ - extra_argv = poptGetArgs(pc); - if (extra_argv) { - extra_argv++; - while (extra_argv[extra_argc]) extra_argc++; - } - - ctdb = ctdb_connect("/tmp/ctdb.socket", - ctdb_log_file, stderr); - if (!ctdb) { - printf("Connecting to /tmp/ctdb.socket\n"); - exit(1); - } - - /* attach to a specific database */ - ctdb_db = ctdb_attachdb(ctdb, "test.tdb", false, 0); - if (!ctdb_db) { - printf("ctdb_attachdb failed\n"); - exit(1); - } - - printf("Waiting for cluster\n"); - while (1) { - uint32_t recmode=1; - ctdb_getrecmode(ctdb, CTDB_CURRENT_NODE, &recmode); - if (recmode == 0) break; - sleep(1); - } - - fetch_lock_once(ctdb, ctdb_db); - - return 0; -} -- 2.34.1