From ef195a18aac1f2b1ebfd34741d2242f659896549 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 21 Nov 2012 16:00:53 +1100 Subject: [PATCH] torture: remove source3 locktest and masktest We now just build these in waf, using the source4/torture code. The source4 versions of these are tested in make test. Andrew Bartlett Reviewed-by: Andreas Schneider --- source3/Makefile.in | 9 - source3/torture/locktest.c | 692 --------------------------------------------- source3/wscript_build | 21 -- 3 files changed, 722 deletions(-) delete mode 100644 source3/torture/locktest.c diff --git a/source3/Makefile.in b/source3/Makefile.in index 990217c298b..fe98579d1ea 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -221,7 +221,6 @@ BIN_PROGS3 = bin/smbpasswd bin/rpcclient bin/smbcacls \ bin/smbcquotas bin/eventlogadm TORTURE_PROGS = bin/smbtorture bin/msgtest \ - bin/masktest bin/locktest \ bin/locktest2 bin/nsstest bin/vfstest \ $(TALLOCTORT) bin/replacetort \ $(TDBTORTURE) $(PTHREADPOOLTEST) \ @@ -1279,18 +1278,10 @@ SMBTORTURE_OBJ = $(SMBTORTURE_OBJ1) $(PARAM_OBJ) $(TLDAP_OBJ) \ lib/filename_util.o \ $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(LIBCLI_ECHO_OBJ) -MASKTEST_OBJ = torture/masktest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ - $(LIB_NONSMBD_OBJ) \ - $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) - MSGTEST_OBJ = torture/msgtest.o $(PARAM_OBJ) $(LIBSMB_ERR_OBJ) \ $(LIB_NONSMBD_OBJ) \ $(LIBNDR_GEN_OBJ0) -LOCKTEST_OBJ = torture/locktest.o $(PARAM_OBJ) $(LOCKING_OBJ) $(KRBCLIENT_OBJ) \ - $(LIBSMB_OBJ) $(LIB_NONSMBD_OBJ) \ - $(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(FNAME_UTIL_OBJ) - NSSTEST_OBJ = ../nsswitch/nsstest.o ../lib/util/setid.o $(LIBSAMBAUTIL_OBJ) VFSTEST_OBJ = torture/cmd_vfs.o torture/vfstest.o $(SMBD_OBJ_BASE) $(READLINE_OBJ) \ diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c deleted file mode 100644 index 04928f20ac8..00000000000 --- a/source3/torture/locktest.c +++ /dev/null @@ -1,692 +0,0 @@ -/* - Unix SMB/CIFS implementation. - randomised byte range lock tester - Copyright (C) Andrew Tridgell 1999 - - 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 "libsmb/libsmb.h" -#include "system/filesys.h" -#include "locking/proto.h" -#include "libsmb/nmblib.h" -#include "../libcli/smb/smbXcli_base.h" - -static fstring password[2]; -static fstring username[2]; -static int got_user; -static int got_pass; -static bool use_kerberos; -static int numops = 1000; -static bool showall; -static bool analyze; -static bool hide_unlock_fails; -static bool use_oplocks; -static unsigned lock_range = 100; -static unsigned lock_base = 0; -static unsigned min_length = 0; -static bool exact_error_codes; -static bool zero_zero; - -extern char *optarg; -extern int optind; - -#define FILENAME "\\locktest.dat" - -#define READ_PCT 50 -#define LOCK_PCT 45 -#define UNLOCK_PCT 70 -#define RANGE_MULTIPLE 1 -#define NSERVERS 2 -#define NCONNECTIONS 2 -#define NFILES 2 -#define LOCK_TIMEOUT 0 - -#define NASTY_POSIX_LOCK_HACK 0 - -enum lock_op {OP_LOCK, OP_UNLOCK, OP_REOPEN}; - -static const char *lock_op_type(int op) -{ - if (op == WRITE_LOCK) return "write"; - else if (op == READ_LOCK) return "read"; - else return "other"; -} - -static const char *lock_op_name(enum lock_op op) -{ - if (op == OP_LOCK) return "lock"; - else if (op == OP_UNLOCK) return "unlock"; - else return "reopen"; -} - -struct record { - enum lock_op lock_op; - enum brl_type lock_type; - char conn, f; - uint64_t start, len; - char needed; -}; - -#define PRESETS 0 - -#if PRESETS -static struct record preset[] = { -{OP_LOCK, WRITE_LOCK, 0, 0, 2, 0, 1}, -{OP_LOCK, WRITE_LOCK, 0, 0, 0, 0, 1}, -{OP_LOCK, WRITE_LOCK, 0, 0, 3, 0, 1}, -{OP_UNLOCK, 0 , 0, 0, 2, 0, 1}, -{OP_REOPEN, 0, 0, 0, 0, 0, 1}, - -{OP_LOCK, READ_LOCK, 0, 0, 2, 0, 1}, -{OP_LOCK, READ_LOCK, 0, 0, 1, 1, 1}, -{OP_LOCK, WRITE_LOCK, 0, 0, 0, 0, 1}, -{OP_REOPEN, 0, 0, 0, 0, 0, 1}, - -{OP_LOCK, READ_LOCK, 0, 0, 2, 0, 1}, -{OP_LOCK, WRITE_LOCK, 0, 0, 3, 1, 1}, -{OP_LOCK, WRITE_LOCK, 0, 0, 0, 0, 1}, -{OP_REOPEN, 0, 0, 0, 0, 0, 1}, - -{OP_LOCK, READ_LOCK, 0, 0, 2, 0, 1}, -{OP_LOCK, WRITE_LOCK, 0, 0, 1, 1, 1}, -{OP_LOCK, WRITE_LOCK, 0, 0, 0, 0, 1}, -{OP_REOPEN, 0, 0, 0, 0, 0, 1}, - -{OP_LOCK, WRITE_LOCK, 0, 0, 2, 0, 1}, -{OP_LOCK, READ_LOCK, 0, 0, 1, 1, 1}, -{OP_LOCK, WRITE_LOCK, 0, 0, 0, 0, 1}, -{OP_REOPEN, 0, 0, 0, 0, 0, 1}, - -{OP_LOCK, WRITE_LOCK, 0, 0, 2, 0, 1}, -{OP_LOCK, READ_LOCK, 0, 0, 3, 1, 1}, -{OP_LOCK, WRITE_LOCK, 0, 0, 0, 0, 1}, -{OP_REOPEN, 0, 0, 0, 0, 0, 1}, - -}; -#endif - -static struct record *recorded; - -static void print_brl(struct file_id id, - struct server_id pid, - enum brl_type lock_type, - enum brl_flavour lock_flav, - br_off start, - br_off size, - void *private_data) -{ -#if NASTY_POSIX_LOCK_HACK - { - static SMB_INO_T lastino; - - if (lastino != ino) { - char *cmd; - if (asprintf(&cmd, - "egrep POSIX.*%u /proc/locks", (int)ino) > 0) { - system(cmd); - SAFE_FREE(cmd); - } - } - lastino = ino; - } -#endif - - printf("%s %s %s %.0f:%.0f(%.0f)\n", - procid_str_static(&pid), file_id_string_tos(&id), - lock_type==READ_LOCK?"R":"W", - (double)start, (double)start+size-1,(double)size); - -} - - -static void show_locks(void) -{ - brl_forall(print_brl, NULL); - /* system("cat /proc/locks"); */ -} - - -/***************************************************** -return a connection to a server -*******************************************************/ -static struct cli_state *connect_one(char *share, int snum) -{ - struct cli_state *c; - char *server_n; - fstring server; - fstring myname; - static int count; - NTSTATUS status; - int flags = 0; - - fstrcpy(server,share+2); - share = strchr_m(server,'\\'); - if (!share) return NULL; - *share = 0; - share++; - - server_n = server; - - slprintf(myname,sizeof(myname), "lock-%lu-%u", (unsigned long)getpid(), count++); - - /* have to open a new connection */ - - if (use_kerberos) { - flags |= CLI_FULL_CONNECTION_USE_KERBEROS; - } - if (use_oplocks) { - flags |= CLI_FULL_CONNECTION_OPLOCKS; - } - - status = cli_connect_nb(server_n, NULL, 0, 0x20, myname, - SMB_SIGNING_DEFAULT, flags, &c); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("Connection to %s failed. Error %s\n", server_n, - nt_errstr(status))); - return NULL; - } - - status = smbXcli_negprot(c->conn, c->timeout, PROTOCOL_CORE, - PROTOCOL_NT1); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("protocol negotiation failed: %s\n", - nt_errstr(status))); - cli_shutdown(c); - return NULL; - } - - if (!got_pass) { - char *pass = getpass("Password: "); - if (pass) { - fstrcpy(password[0], pass); - fstrcpy(password[1], pass); - } - } - - if (got_pass == 1) { - strlcpy(password[1], password[0],sizeof(password[1])); - strlcpy(username[1], username[0],sizeof(username[1])); - } - - status = cli_session_setup(c, username[snum], - password[snum], strlen(password[snum]), - password[snum], strlen(password[snum]), - lp_workgroup()); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("session setup failed: %s\n", nt_errstr(status))); - return NULL; - } - - /* - * These next two lines are needed to emulate - * old client behaviour for people who have - * scripts based on client output. - * QUESTION ? Do we want to have a 'client compatibility - * mode to turn these on/off ? JRA. - */ - - if (*c->server_domain || *c->server_os || *c->server_type) - DEBUG(1,("Domain=[%s] OS=[%s] Server=[%s]\n", - c->server_domain,c->server_os,c->server_type)); - - DEBUG(4,(" session setup ok\n")); - - status = cli_tree_connect(c, share, "?????", password[snum], - strlen(password[snum])+1); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("tree connect failed: %s\n", nt_errstr(status))); - cli_shutdown(c); - return NULL; - } - - DEBUG(4,(" tconx ok\n")); - - return c; -} - - -static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], uint16_t fnum[NSERVERS][NCONNECTIONS][NFILES], - char *share[NSERVERS]) -{ - int server, conn, f; - - for (server=0;serverconn; - unsigned f = rec->f; - uint64_t start = rec->start; - uint64_t len = rec->len; - enum brl_type op = rec->lock_type; - int server; - NTSTATUS status[NSERVERS]; - - switch (rec->lock_op) { - case OP_LOCK: - /* set a lock */ - for (server=0;server %s:%s\n", - conn, f, - (double)start, (double)len, - op==READ_LOCK?"READ_LOCK":"WRITE_LOCK", - nt_errstr(status[0]), nt_errstr(status[1])); - } - if (showall || !NT_STATUS_EQUAL(status[0],status[1])) show_locks(); - if (!NT_STATUS_EQUAL(status[0],status[1])) return False; - break; - - case OP_UNLOCK: - /* unset a lock */ - for (server=0;server %s:%s\n", - conn, f, - (double)start, (double)len, - nt_errstr(status[0]), nt_errstr(status[1])); - } - if (showall || !NT_STATUS_EQUAL(status[0],status[1])) show_locks(); - if (!hide_unlock_fails && !NT_STATUS_EQUAL(status[0],status[1])) - return False; - break; - - case OP_REOPEN: - /* reopen the file */ - for (server=0;server 1) { - skip = skip/2; - printf("skip=%d\n", skip); - continue; - } - - if (n1 == n) break; - } - - close_files(cli, fnum); - reconnect(cli, fnum, share); - open_files(cli, fnum); - showall = True; - n1 = retest(cli, fnum, n); - if (n1 != n-1) { - printf("ERROR - inconsistent result (%u %u)\n", n1, n); - } - close_files(cli, fnum); - - for (i=0;i