s4/torture: use monotonic clock for time deltas in denytest
authorBjörn Jacke <bj@sernet.de>
Mon, 30 Aug 2010 16:58:20 +0000 (18:58 +0200)
committerBjörn Jacke <bj@sernet.de>
Tue, 31 Aug 2010 08:26:40 +0000 (10:26 +0200)
source4/torture/basic/denytest.c

index 174a1b2d6cbd3a4f2a21b9b88b75ec8650b3c04d..7480c388ae2ca2c717a8cc528b04e53b1eee1e2c 100644 (file)
@@ -1416,7 +1416,7 @@ bool torture_denytest1(struct torture_context *tctx,
        int fnum1, fnum2;
        int i;
        bool correct = true;
-       struct timeval tv, tv_start;
+       struct timespec tv, tv_start;
        const char *fnames[2] = {"\\denytest1.dat", "\\denytest1.exe"};
        int failures=0;
 
@@ -1431,7 +1431,7 @@ bool torture_denytest1(struct torture_context *tctx,
 
        torture_comment(tctx, "Testing %d entries\n", (int)ARRAY_SIZE(denytable1));
 
-       GetTimeOfDay(&tv_start);
+       clock_gettime_mono(&tv_start);
 
        for (i=0; i<ARRAY_SIZE(denytable1); i++) {
                enum deny_result res;
@@ -1474,9 +1474,9 @@ bool torture_denytest1(struct torture_context *tctx,
                if (torture_setting_bool(tctx, "showall", false) || 
                        res != denytable1[i].result) {
                        int64_t tdif;
-                       GetTimeOfDay(&tv);
-                       tdif = usec_time_diff(&tv, &tv_start);
-                       tdif /= 1000;
+                       clock_gettime_mono(&tv);
+                       tdif = nsec_time_diff(&tv, &tv_start);
+                       tdif /= 1000000;
                        torture_comment(tctx, "%lld: %s %8s %10s    %8s %10s    %s (correct=%s)\n",
                               (long long)tdif,
                               fname,
@@ -1518,7 +1518,7 @@ bool torture_denytest2(struct torture_context *tctx,
        int i;
        bool correct = true;
        const char *fnames[2] = {"\\denytest2.dat", "\\denytest2.exe"};
-       struct timeval tv, tv_start;
+       struct timespec tv, tv_start;
        int failures=0;
 
        for (i=0;i<2;i++) {
@@ -1528,7 +1528,7 @@ bool torture_denytest2(struct torture_context *tctx,
                smbcli_close(cli1->tree, fnum1);
        }
 
-       GetTimeOfDay(&tv_start);
+       clock_gettime_mono(&tv_start);
 
        for (i=0; i<ARRAY_SIZE(denytable2); i++) {
                enum deny_result res;
@@ -1571,9 +1571,9 @@ bool torture_denytest2(struct torture_context *tctx,
                if (torture_setting_bool(tctx, "showall", false) || 
                        res != denytable2[i].result) {
                        int64_t tdif;
-                       GetTimeOfDay(&tv);
-                       tdif = usec_time_diff(&tv, &tv_start);
-                       tdif /= 1000;
+                       clock_gettime_mono(&tv);
+                       tdif = nsec_time_diff(&tv, &tv_start);
+                       tdif /= 1000000;
                        torture_comment(tctx, "%lld: %s %8s %10s    %8s %10s    %s (correct=%s)\n",
                               (long long)tdif,
                               fname,
@@ -1763,7 +1763,7 @@ static bool torture_ntdenytest(struct torture_context *tctx,
        int fnum1;
        int i;
        bool correct = true;
-       struct timeval tv, tv_start;
+       struct timespec tv, tv_start;
        const char *fname;
        int nbits1 = ARRAY_SIZE(share_access_bits);
        int nbits2 = ARRAY_SIZE(access_mask_bits);
@@ -1783,7 +1783,7 @@ static bool torture_ntdenytest(struct torture_context *tctx,
        smbcli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf));
        smbcli_close(cli1->tree, fnum1);
 
-       GetTimeOfDay(&tv_start);
+       clock_gettime_mono(&tv_start);
 
        io1.ntcreatex.level = RAW_OPEN_NTCREATEX;
        io1.ntcreatex.in.root_fid.fnum = 0;
@@ -1871,9 +1871,9 @@ static bool torture_ntdenytest(struct torture_context *tctx,
                                                   read_for_execute,
                                                   &res2);
                
-               GetTimeOfDay(&tv);
-               tdif = usec_time_diff(&tv, &tv_start);
-               tdif /= 1000;
+               clock_gettime_mono(&tv);
+               tdif = nsec_time_diff(&tv, &tv_start);
+               tdif /= 1000000;
                if (torture_setting_bool(tctx, "showall", false) || 
                    !NT_STATUS_EQUAL(status2, status2_p) ||
                    res != res2) {