[esan|wset] Further reduce flakiness of sampling test
authorDerek Bruening <bruening@google.com>
Wed, 6 Jul 2016 20:27:44 +0000 (20:27 +0000)
committerDerek Bruening <bruening@google.com>
Wed, 6 Jul 2016 20:27:44 +0000 (20:27 +0000)
Enhances the sampling test to try and reduce flakiness further by
increasing the workload to ensure a few samples are gathered.

llvm-svn: 274669

compiler-rt/test/esan/TestCases/workingset-samples.cpp

index 98a9bc8..09efcd4 100644 (file)
@@ -7,6 +7,7 @@
 #include <sys/mman.h>
 
 const int size = 0x1 << 25; // 523288 cache lines
+const int iters = 6;
 
 int main(int argc, char **argv) {
   char *buf = (char *)mmap(0, size, PROT_READ | PROT_WRITE,
@@ -15,9 +16,12 @@ int main(int argc, char **argv) {
   // scheduled.  Unfortunately we can't do proper synchronization
   // without some form of annotation or something.
   sched_yield();
-  // Do enough work to get at least 2 samples.
-  for (int i = 0; i < size; ++i)
-    buf[i] = i;
+  // Do enough work to get at least 4 samples.
+  for (int j = 0; j < iters; ++j) {
+    for (int i = 0; i < size; ++i)
+      buf[i] = i;
+    sched_yield();
+  }
   munmap(buf, size);
   // We only check for a few samples here to reduce the chance of flakiness.
   // CHECK:      =={{[0-9]+}}== Total number of samples: {{[0-9]+}}