r22969: fix some more places where we could end up with more than one event
[sfrench/samba-autobuild/.git] / source4 / torture / basic / misc.c
index 13dcf5da932a298fe49896035406783b4284f540..933e4334c03b8a47f6c07a45eb07bffa45eb2f5b 100644 (file)
@@ -66,11 +66,15 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c)
                return False;
        }
 
+       generate_random_buffer(buf, sizeof(buf));
 
        for (i=0;i<torture_numops;i++) {
                uint_t n = (uint_t)random()%10;
                if (i % 10 == 0) {
-                       torture_comment(tctx, "%d\r", i); fflush(stdout);
+                       if (torture_setting_bool(tctx, "progress", true)) {
+                               torture_comment(tctx, "%d\r", i);
+                               fflush(stdout);
+                       }
                }
                asprintf(&fname, "\\torture.%u", n);
 
@@ -161,8 +165,10 @@ BOOL run_pipe_number(struct torture_context *tctx,
                        break;
                }
                num_pipes++;
-               torture_comment(tctx, "%d\r", num_pipes);
-               fflush(stdout);
+               if (torture_setting_bool(tctx, "progress", true)) {
+                       torture_comment(tctx, "%d\r", num_pipes);
+                       fflush(stdout);
+               }
        }
 
        torture_comment(tctx, "pipe_number test - we can open %d %s pipes.\n", num_pipes, pipe_name );
@@ -191,8 +197,10 @@ BOOL torture_holdcon(struct torture_context *tctx)
                if (!torture_open_connection(&cli[i], i)) {
                        return False;
                }
-               torture_comment(tctx, "opened %d connections\r", i);
-               fflush(stdout);
+               if (torture_setting_bool(tctx, "progress", true)) {
+                       torture_comment(tctx, "opened %d connections\r", i);
+                       fflush(stdout);
+               }
        }
 
        torture_comment(tctx, "\nStarting pings\n");
@@ -272,7 +280,10 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int
                        break;
                }
                free(fname);
-               torture_comment(tctx, "%6d\r", i);
+               if (torture_setting_bool(tctx, "progress", true)) {
+                       torture_comment(tctx, "%6d\r", i);
+                       fflush(stdout);
+               }
        }
        torture_comment(tctx, "%6d\n", i);
        i--;
@@ -303,7 +314,10 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int
                }
                free(fname);
 
-               torture_comment(tctx, "%6d %6d\r", i, maxfid-i);
+               if (torture_setting_bool(tctx, "progress", true)) {
+                       torture_comment(tctx, "%6d %6d\r", i, maxfid-i);
+                       fflush(stdout);
+               }
        }
        torture_comment(tctx, "%6d\n", 0);
 
@@ -829,7 +843,7 @@ BOOL run_benchrw(struct torture_context *tctx)
                        torture_numops, torture_nprocs);
 
        /*init talloc context*/
-       ev = event_context_init(tctx);
+       ev = tctx->ev;
        state = talloc_array(tctx, struct benchrw_state *, torture_nprocs);
 
        /* init params using lp_parm_xxx */