*/
#include "includes.h"
+#include "dynconfig.h"
+#include "client.h"
+#include "lib/cmdline/popt_common.h"
+#include "libcli/raw/libcliraw.h"
+#include "system/time.h"
+#include "system/wait.h"
+#include "ioctl.h"
int torture_nprocs=4;
int torture_numops=100;
int torture_entries=1000;
int torture_failures=1;
+int torture_seed=0;
static int procnum; /* records process count number when forking */
static struct smbcli_state *current_cli;
static BOOL use_oplocks;
ssize_t sent = 0;
BOOL correct = True;
- srandom(1);
for (i = 0; i < sizeof(buf); i += sizeof(uint32_t))
{
SIVAL(buf, i, sys_random());
return correct;
}
-static BOOL run_readwritetest(int dummy)
+static BOOL run_readwritetest(void)
{
struct smbcli_state *cli1, *cli2;
BOOL test1, test2 = True;
this checks to see if a secondary tconx can use open files from an
earlier tconx
*/
-static BOOL run_tcon_test(int dummy)
+static BOOL run_tcon_test(void)
{
struct smbcli_state *cli;
const char *fname = "\\tcontest.tmp";
/*
checks for correct tconX support
*/
-static BOOL run_tcon_devtype_test(int dummy)
+static BOOL run_tcon_devtype_test(void)
{
struct smbcli_state *cli1 = NULL;
BOOL retry;
test whether fnums and tids open on one VC are available on another (a major
security hole)
*/
-static BOOL run_fdpasstest(int dummy)
+static BOOL run_fdpasstest(void)
{
struct smbcli_state *cli1, *cli2;
const char *fname = "\\fdpass.tst";
}
-/*
- This test checks that
-
- 1) the server does not allow an unlink on a file that is open
-*/
-static BOOL run_unlinktest(int dummy)
-{
- struct smbcli_state *cli;
- const char *fname = "\\unlink.tst";
- int fnum;
- BOOL correct = True;
-
- if (!torture_open_connection(&cli)) {
- return False;
- }
-
- printf("starting unlink test\n");
-
- smbcli_unlink(cli->tree, fname);
-
- cli->session->pid = 1;
-
- printf("Opening a file\n");
-
- fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
- if (fnum == -1) {
- printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
- return False;
- }
-
- printf("Unlinking a open file\n");
-
- if (NT_STATUS_IS_OK(smbcli_unlink(cli->tree, fname))) {
- printf("error: server allowed unlink on an open file\n");
- correct = False;
- } else {
- correct = check_error(__location__, cli, ERRDOS, ERRbadshare,
- NT_STATUS_SHARING_VIOLATION);
- }
-
- smbcli_close(cli->tree, fnum);
- smbcli_unlink(cli->tree, fname);
-
- if (!torture_close_connection(cli)) {
- correct = False;
- }
-
- printf("unlink test finished\n");
-
- return correct;
-}
-
-
/*
test the timing of deferred open requests
*/
int fnum = -1;
do {
- struct timeval tv_start, tv_end;
- GetTimeOfDay(&tv_start);
+ struct timeval tv;
+ tv = timeval_current();
fnum = smbcli_nt_create_full(cli->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE,
NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum != -1) {
break;
}
- GetTimeOfDay(&tv_end);
if (NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION)) {
- /* Sharing violation errors need to be 1 second apart. */
- int64_t tdif = usec_time_diff(&tv_end, &tv_start);
- if (tdif < 500000 || tdif > 1500000) {
- fprintf(stderr,"Timing incorrect %lld.%lld for share violation\n",
- tdif / (int64_t)1000000,
- tdif % (int64_t)1000000);
+ double e = timeval_elapsed(&tv);
+ if (e < 0.5 || e > 1.5) {
+ fprintf(stderr,"Timing incorrect %.2f violation\n",
+ e);
}
}
} while (NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION));
}
/* send smb negprot commands, not reading the response */
-static BOOL run_negprot_nowait(int dummy)
+static BOOL run_negprot_nowait(void)
{
int i;
struct smbcli_state *cli, *cli2;
/*
This checks how the getatr calls works
*/
-static BOOL run_attrtest(int dummy)
+static BOOL run_attrtest(void)
{
struct smbcli_state *cli;
int fnum;
/*
This checks a couple of trans2 calls
*/
-static BOOL run_trans2test(int dummy)
+static BOOL run_trans2test(void)
{
struct smbcli_state *cli;
int fnum;
/*
print out server properties
*/
-static BOOL run_properties(int dummy)
+static BOOL run_properties(void)
{
struct smbcli_state *cli;
BOOL correct = True;
/*
Test ntcreate calls made by xcopy
*/
-static BOOL run_xcopy(int dummy)
+static BOOL run_xcopy(void)
{
struct smbcli_state *cli1;
const char *fname = "\\test.txt";
/*
see how many RPC pipes we can open at once
*/
-static BOOL run_pipe_number(int dummy)
+static BOOL run_pipe_number(void)
{
struct smbcli_state *cli1;
const char *pipe_name = "\\WKSSVC";
used for testing performance when there are N idle users
already connected
*/
- static BOOL torture_holdcon(int dummy)
+ static BOOL torture_holdcon(void)
{
int i;
struct smbcli_state **cli;
Try with a wrong vuid and check error message.
*/
-static BOOL run_vuidtest(int dummy)
+static BOOL run_vuidtest(void)
{
struct smbcli_state *cli;
const char *fname = "\\vuid.tst";
/*
Test open mode returns on read-only files.
*/
- static BOOL run_opentest(int dummy)
+ static BOOL run_opentest(void)
{
static struct smbcli_state *cli1;
static struct smbcli_state *cli2;
/*
sees what IOCTLs are supported
*/
-BOOL torture_ioctl_test(int dummy)
+BOOL torture_ioctl_test(void)
{
struct smbcli_state *cli;
uint16_t device, function;
/*
tries variants of chkpath
*/
-BOOL torture_chkpath_test(int dummy)
+BOOL torture_chkpath_test(void)
{
struct smbcli_state *cli;
int fnum;
-static void sigcont(void)
+static void sigcont(int sig)
{
}
char **unc_list = NULL;
const char *p;
int num_unc_names = 0;
+ struct timeval tv;
synccount = 0;
child_status_out[i] = True;
}
- start_timer();
+ tv = timeval_current();
for (i=0;i<torture_nprocs;i++) {
procnum = i;
}
if (synccount == torture_nprocs) break;
msleep(100);
- } while (end_timer() < start_time_limit);
+ } while (timeval_elapsed(&tv) < start_time_limit);
if (synccount != torture_nprocs) {
printf("FAILED TO START %d CLIENTS (started %d)\n", torture_nprocs, synccount);
*result = False;
- return end_timer();
+ return timeval_elapsed(&tv);
}
printf("Starting %d clients\n", torture_nprocs);
/* start the client load */
- start_timer();
+ tv = timeval_current();
for (i=0;i<torture_nprocs;i++) {
child_status[i] = 0;
}
for (i=0;i<torture_nprocs;i++) {
int ret;
- while ((ret=waitpid(0, &status, 0)) == -1 && errno == EINTR) /* noop */ ;
+ while ((ret=sys_waitpid(0, &status, 0)) == -1 && errno == EINTR) /* noop */ ;
if (ret == -1 || WEXITSTATUS(status) != 0) {
*result = False;
}
*result = False;
}
}
- return end_timer();
+ return timeval_elapsed(&tv);
}
#define FLAG_MULTIPROC 1
static struct {
const char *name;
- BOOL (*fn)(int);
- uint_t flags;
+ BOOL (*fn)(void);
+ BOOL (*multi_fn)(struct smbcli_state *, int );
} torture_ops[] = {
/* base tests */
{"BASE-FDPASS", run_fdpasstest, 0},
{"BASE-LOCK5", torture_locktest5, 0},
{"BASE-LOCK6", torture_locktest6, 0},
{"BASE-LOCK7", torture_locktest7, 0},
- {"BASE-UNLINK", run_unlinktest, 0},
+ {"BASE-UNLINK", torture_unlinktest, 0},
{"BASE-ATTR", run_attrtest, 0},
{"BASE-TRANS2", run_trans2test, 0},
{"BASE-NEGNOWAIT", run_negprot_nowait, 0},
{"BASE-DENY1", torture_denytest1, 0},
{"BASE-DENY2", torture_denytest2, 0},
{"BASE-DENY3", torture_denytest3, 0},
+ {"BASE-NTDENY1", NULL, torture_ntdenytest1},
+ {"BASE-NTDENY2", torture_ntdenytest2, 0},
{"BASE-TCON", run_tcon_test, 0},
{"BASE-TCONDEV", run_tcon_devtype_test, 0},
{"BASE-VUID", run_vuidtest, 0},
{"BASE-RW1", run_readwritetest, 0},
- {"BASE-RW2", run_readwritemulti, FLAG_MULTIPROC},
+ {"BASE-RW2", NULL, run_readwritemulti},
{"BASE-OPEN", run_opentest, 0},
- {"BASE-DEFER_OPEN", run_deferopen, FLAG_MULTIPROC},
+ {"BASE-DEFER_OPEN", NULL, run_deferopen},
{"BASE-XCOPY", run_xcopy, 0},
{"BASE-RENAME", torture_test_rename, 0},
{"BASE-DELETE", torture_test_delete, 0},
/* benchmarking tests */
{"BENCH-HOLDCON", torture_holdcon, 0},
{"BENCH-NBENCH", torture_nbench, 0},
- {"BENCH-TORTURE",run_torture, FLAG_MULTIPROC},
+ {"BENCH-TORTURE", NULL, run_torture},
/* RAW smb tests */
{"RAW-QFSINFO", torture_raw_qfsinfo, 0},
{"SCAN-NTTRANS", torture_nttrans_scan, 0},
{"SCAN-ALIASES", torture_trans2_aliases, 0},
{"SCAN-SMB", torture_smb_scan, 0},
- {"SCAN-MAXFID", run_maxfidtest, FLAG_MULTIPROC},
+ {"SCAN-MAXFID", NULL, run_maxfidtest},
{"SCAN-UTABLE", torture_utable, 0},
{"SCAN-CASETABLE", torture_casetable, 0},
{"SCAN-PIPE_NUMBER", run_pipe_number, 0},
{"RPC-EPMAPPER", torture_rpc_epmapper, 0},
{"RPC-WINREG", torture_rpc_winreg, 0},
{"RPC-OXIDRESOLVE", torture_rpc_oxidresolve, 0},
+ {"RPC-REMACT", torture_rpc_remact, 0},
{"RPC-MGMT", torture_rpc_mgmt, 0},
{"RPC-SCANNER", torture_rpc_scanner, 0},
{"RPC-AUTOIDL", torture_rpc_autoidl, 0},
{"RPC-MULTIBIND", torture_multi_bind, 0},
{"RPC-DRSUAPI", torture_rpc_drsuapi, 0},
+ /* Distributed COM testers */
+ {"DCOM-SIMPLE", torture_dcom_simple, 0},
+
/* local (no server) testers */
{"LOCAL-NTLMSSP", torture_ntlmssp_self_check, 0},
{"LOCAL-ICONV", torture_local_iconv, 0},
matched = True;
init_iconv();
printf("Running %s\n", torture_ops[i].name);
- if (torture_ops[i].flags & FLAG_MULTIPROC) {
+ if (torture_ops[i].multi_fn) {
BOOL result;
- t = torture_create_procs(torture_ops[i].fn, &result);
+ t = torture_create_procs(torture_ops[i].multi_fn,
+ &result);
if (!result) {
ret = False;
printf("TEST %s FAILED!\n", torture_ops[i].name);
}
} else {
- start_timer();
- if (!torture_ops[i].fn(0)) {
+ struct timeval tv = timeval_current();
+ if (!torture_ops[i].fn()) {
ret = False;
printf("TEST %s FAILED!\n", torture_ops[i].name);
}
- t = end_timer();
+ t = timeval_elapsed(&tv);
}
printf("%s took %g secs\n\n", torture_ops[i].name, t);
}
struct poptOption long_options[] = {
POPT_AUTOHELP
{"smb-ports", 'p', POPT_ARG_STRING, NULL, 0, "SMB ports", NULL},
- {"seed", 0, POPT_ARG_STRING, NULL, 0, "seed", NULL},
+ {"seed", 0, POPT_ARG_INT, &torture_seed, 0, "seed", NULL},
{"num-progs", 0, POPT_ARG_INT, &torture_nprocs, 0, "num progs", NULL},
{"num-ops", 0, POPT_ARG_INT, &torture_numops, 0, "num ops", NULL},
{"entries", 0, POPT_ARG_INT, &torture_entries, 0, "entries", NULL},
POPT_TABLEEND
};
+ smbtorture_init_subsystems;
+
setup_logging("smbtorture", DEBUG_STDOUT);
#ifdef HAVE_SETBUFFER
lp_load(dyn_CONFIGFILE,True,False,False);
load_interfaces();
- srandom(time(NULL));
+ if (torture_seed == 0) {
+ torture_seed = time(NULL);
+ }
+ printf("Using seed %d\n", torture_seed);
+ srandom(torture_seed);
- argv_new = (const char **)poptGetArgs(pc);
+ argv_new = discard_const_p(char *, poptGetArgs(pc));
argc_new = argc;
for (i=0; i<argc; i++) {
char *host = NULL, *share = NULL;
if (!parse_unc(argv_new[1], &host, &share)) {
+ d_printf("Invalid option: %s is not a valid torture target (share or binding string)\n\n", argv_new[1]);
usage(pc);
}