r3586: Fix some of the issues with the module init functions.
[bbaumbach/samba-autobuild/.git] / source4 / torture / torture.c
index 656607d93448246c0605500299f1306aaf4566b6..883fe4b017ac9b0572642eaf04899bc2a97de10f 100644 (file)
@@ -863,59 +863,6 @@ static BOOL run_fdpasstest(void)
 }
 
 
-/*
-  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
 */
@@ -937,22 +884,19 @@ static BOOL run_deferopen(struct smbcli_state *cli, int dummy)
                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));
@@ -2269,6 +2213,7 @@ double torture_create_procs(BOOL (*fn)(struct smbcli_state *, int), BOOL *result
        char **unc_list = NULL;
        const char *p;
        int num_unc_names = 0;
+       struct timeval tv;
 
        synccount = 0;
 
@@ -2300,7 +2245,7 @@ double torture_create_procs(BOOL (*fn)(struct smbcli_state *, int), BOOL *result
                child_status_out[i] = True;
        }
 
-       start_timer();
+       tv = timeval_current();
 
        for (i=0;i<torture_nprocs;i++) {
                procnum = i;
@@ -2364,18 +2309,18 @@ double torture_create_procs(BOOL (*fn)(struct smbcli_state *, int), BOOL *result
                }
                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;
        }
@@ -2398,7 +2343,7 @@ double torture_create_procs(BOOL (*fn)(struct smbcli_state *, int), BOOL *result
                        *result = False;
                }
        }
-       return end_timer();
+       return timeval_elapsed(&tv);
 }
 
 #define FLAG_MULTIPROC 1
@@ -2417,7 +2362,7 @@ static struct {
        {"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},
@@ -2508,6 +2453,9 @@ static struct {
        {"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},
@@ -2557,12 +2505,12 @@ static BOOL run_test(const char *name)
                                }
                                         
                        } 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);
                }
@@ -2684,6 +2632,8 @@ static BOOL is_binding_string(const char *binding_string)
                POPT_TABLEEND
        };
 
+       smbtorture_init_subsystems;
+
        setup_logging("smbtorture", DEBUG_STDOUT);
 
 #ifdef HAVE_SETBUFFER