torture-base.delaywrite: assert the for a delayed write, that it just takes longer...
authorAndrew Bartlett <abartlet@samba.org>
Fri, 20 Jun 2014 10:28:50 +0000 (22:28 +1200)
committerJeremy Allison <jra@samba.org>
Mon, 23 Jun 2014 21:30:14 +0000 (23:30 +0200)
This removes the hardcoded TIMEDELAY_SECS that was then made variable
by the confusing "secs" variable

Andrew Bartlett

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/torture/basic/delaywrite.c

index 30cb5da07054248e5c218b71194defa2951e51d0..8db37da536cfdf85cebd41ea9cd3151ac4cf28db 100644 (file)
 #include "torture/util.h"
 #include "torture/basic/proto.h"
 
-#define W2K8R2_TIMEDELAY_SECS 1
-#define W2K3_TIMEDELAY_SECS 2
-#define TIMEDELAY_SECS W2K3_TIMEDELAY_SECS
-
 #define BASEDIR "\\delaywrite"
 
 static bool test_delayed_write_update(struct torture_context *tctx, struct smbcli_state *cli)
@@ -96,17 +92,16 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
                       nt_time_string(tctx, finfo2.basic_info.out.write_time));
                if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
                        double diff = timeval_elapsed(&start);
-                       if (diff < (TIMEDELAY_SECS * sec)) {
+                       if (diff < used_delay) {
                                torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds"
-                                               "(1 sec == %.2f)(wrong!)\n",
-                                               diff, sec);
+                                               "(expected > %.2f) (wrong!)\n",
+                                               diff, used_delay / (double)1000000);
                                ret = false;
                                break;
                        }
 
-                       torture_comment(tctx, "Server updated write_time after %.2f seconds"
-                                       "(1 sec == %.2f)(correct)\n",
-                                       diff, sec);
+                       torture_comment(tctx, "Server updated write_time after %.2f seconds (correct)\n",
+                                       diff);
                        break;
                }
                fflush(stdout);
@@ -1162,10 +1157,10 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
                       nt_time_string(tctx, finfo2.basic_info.out.write_time));
                if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
                        double diff = timeval_elapsed(&start);
-                       if (diff < (TIMEDELAY_SECS * sec)) {
+                       if (diff < used_delay) {
                                torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds"
-                                               "(1sec == %.2f) (wrong!)\n",
-                                               diff, sec);
+                                               "(expected > %.2f) (wrong!)\n",
+                                               diff, used_delay / (double)1000000);
                                ret = false;
                                break;
                        }
@@ -1543,10 +1538,10 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
 
                if (finfo1.basic_info.out.write_time > finfo0.basic_info.out.write_time) {
                        double diff = timeval_elapsed(&start);
-                       if (diff < (TIMEDELAY_SECS * sec)) {
+                       if (diff < (used_delay)) {
                                torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
-                                               "(1sec == %.2f) (wrong!)\n",
-                                               diff, sec);
+                                               "(write time update delay == %.2f) (wrong!)\n",
+                                               diff, used_delay / (double)1000000);
                                ret = false;
                                break;
                        }
@@ -1705,7 +1700,7 @@ static bool test_delayed_write_update3a(struct torture_context *tctx,
 
                if (finfo1.basic_info.out.write_time > finfo0.basic_info.out.write_time) {
                        double diff = timeval_elapsed(&start);
-                       if (diff < (TIMEDELAY_SECS * sec)) {
+                       if (diff < (used_delay)) {
                                torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
                                                "(1sec == %.2f) (wrong!)\n",
                                                diff, sec);
@@ -1916,17 +1911,17 @@ static bool test_delayed_write_update3b(struct torture_context *tctx,
 
                if (finfo1.basic_info.out.write_time > finfo0.basic_info.out.write_time) {
                        double diff = timeval_elapsed(&start);
-                       if (diff < (TIMEDELAY_SECS * sec)) {
-                               torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
-                                               "(1sec == %.2f) (wrong!)\n",
-                                               diff, sec);
+                       if (diff < used_delay) {
+                               torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds"
+                                               "(expected > %.2f) (wrong!)\n",
+                                               diff, used_delay / (double)1000000);
                                ret = false;
                                break;
                        }
 
                        torture_comment(tctx, "Server updated write_time after %.2f seconds "
-                                       "(1sec == %.2f) (correct)\n",
-                                       diff, sec);
+                                       "(write time update delay == %.2f) (correct)\n",
+                                       diff, used_delay / (double)1000000);
                        break;
                }
                smb_msleep(0.5 * msec);
@@ -2285,17 +2280,17 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
 
                if (finfo1.basic_info.out.write_time > finfo0.basic_info.out.write_time) {
                        double diff = timeval_elapsed(&start);
-                       if (diff < (TIMEDELAY_SECS * sec)) {
-                               torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
-                                               "(1sec == %.2f) (wrong!)\n",
-                                               diff, sec);
+                       if (diff < used_delay) {
+                               torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds"
+                                               "(expected > %.2f) (wrong!)\n",
+                                               diff, used_delay / (double)1000000);
                                ret = false;
                                break;
                        }
 
                        torture_comment(tctx, "Server updated write_time after %.2f seconds "
-                                       "(1sec == %.2f) (correct)\n",
-                                       diff, sec);
+                                       "(write time update delay == %.2f) (correct)\n",
+                                       diff, used_delay / (double)1000000);
                        break;
                }
                smb_msleep(0.5 * msec);