Whamcloud - gitweb
LU-1205 tests: add timestamps to sanityn 18 mmap
authorAndreas Dilger <adilger@whamcloud.com>
Mon, 12 Mar 2012 20:23:07 +0000 (14:23 -0600)
committerOleg Drokin <green@whamcloud.com>
Fri, 18 May 2012 17:19:50 +0000 (13:19 -0400)
The sanityn.sh test_18 mmap_sanity.c test sometimes takes over
an hour to run, and sometimes only seconds.  Add timestamps to
the subtest results so that it is possible to debug where that
time is being spent.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Bob Glossman <bogl@whamcloud.com>
Change-Id: I641566c9a0b204095ad0c2e3bee852a0e8fd6881
Reviewed-on: http://review.whamcloud.com/2721
Tested-by: Hudson
Reviewed-by: Yu Jian <yujian@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/mmap_sanity.c

index 478896e..aaa67c4 100644 (file)
@@ -47,6 +47,7 @@
 #include <netdb.h>
 #include <string.h>
 #include <sys/wait.h>
+#include <sys/time.h>
 
 char *dir = NULL, *dir2 = NULL;
 long page_size;
@@ -761,13 +762,24 @@ int main(int argc, char **argv)
         }
 
         for (test = tests; test->tc; test++) {
-                char *rs = "skip";
-                rc = 0;
+                double duration;
+                char *rs;
+
                 if (test->node_cnt == 1 || dir2 != NULL) {
+                        struct timeval start, end;
+
+                        gettimeofday(&start, NULL);
                         rc = test->test_fn(dir);
-                        rs = rc ? "fail" : "pass";
+                        gettimeofday(&end, NULL);
+
+                        duration = (double)(end.tv_sec - start.tv_sec) +
+                                (double)(end.tv_usec - start.tv_usec) / 1000000;
+                        rs = rc ? "FAIL" : "PASS";
+                } else {
+                        duration = 0.0;
+                        rs = "SKIP";
                 }
-                fprintf(stderr, "%s (%s)\n", test->desc, rs);
+                fprintf(stderr, "%s (%s, %.5gs)\n", test->desc, rs, duration);
                 if (rc)
                         break;
         }