BASE-DEFER_OPEN: add torture:sharedelays option to run this test faster
authorStefan Metzmacher <metze@samba.org>
Sat, 23 Feb 2008 23:13:36 +0000 (00:13 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 25 Feb 2008 06:39:23 +0000 (07:39 +0100)
metze
(This used to be commit 877cc375d0523cb31324a5d611e73d666e7a9a78)

source4/torture/basic/base.c

index aa729ec0dff6617f19e7ce32312bd3be0fec1e1f..42d7ddaaa12e4c60c7a6a4c181e227eb51434b0b 100644 (file)
@@ -633,6 +633,13 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
        int retries=4;
        int i = 0;
        bool correct = true;
+       int nsec;
+       int msec;
+       double sec;
+
+       nsec = torture_setting_int(tctx, "sharedelay", 1000000);
+       msec = nsec / 1000;
+       sec = ((double)nsec) / ((double) 1000000);
 
        if (retries <= 0) {
                torture_comment(tctx, "failed to connect\n");
@@ -657,9 +664,10 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
                        }
                        if (NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION)) {
                                double e = timeval_elapsed(&tv);
-                               if (e < 0.5 || e > 1.5) {
-                                       torture_comment(tctx,"Timing incorrect %.2f violation\n",
-                                               e);
+                               if (e < (0.5 * sec) || e > (1.5 * sec)) {
+                                       torture_comment(tctx,"Timing incorrect %.2f violation 1 sec == %.2f\n",
+                                               e, sec);
+                                       return false;
                                }
                        }
                } while (NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION));
@@ -671,13 +679,13 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
 
                torture_comment(tctx, "pid %u open %d\n", (unsigned)getpid(), i);
 
-               sleep(10);
+               msleep(10 * msec);
                i++;
                if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) {
                        torture_comment(tctx,"Failed to close %s, error=%s\n", fname, smbcli_errstr(cli->tree));
                        return false;
                }
-               sleep(2);
+               msleep(2 * msec);
        }
 
        if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) {