*/
#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;
}
-/*
- This test checks that
-
- 1) the server does not allow an unlink on a file that is open
-*/
-static BOOL run_unlinktest(void)
-{
- 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));
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
{"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},
{"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},
}
} else {
- start_timer();
+ 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);
}
POPT_TABLEEND
};
+ smbtorture_init_subsystems;
+
setup_logging("smbtorture", DEBUG_STDOUT);
#ifdef HAVE_SETBUFFER
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);
}