about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2022-03-16 23:00:55 +0000
committerMartinNowack <2443641+MartinNowack@users.noreply.github.com>2022-03-17 11:33:50 +0000
commit8cab09eb98d06d488e036ceec9f4b16090502297 (patch)
treee144a749becfb0f286e48f345a262e7a3808b9c3
parentcec6d63e04157cffb57b49890230f7c9a9777089 (diff)
downloadklee-8cab09eb98d06d488e036ceec9f4b16090502297.tar.gz
Updated test MemoryLimit.c to use FileCheck, and formatted the file
-rw-r--r--test/Feature/MemoryLimit.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/test/Feature/MemoryLimit.c b/test/Feature/MemoryLimit.c
index e9635cab..c077c6b7 100644
--- a/test/Feature/MemoryLimit.c
+++ b/test/Feature/MemoryLimit.c
@@ -1,5 +1,6 @@
 // REQUIRES: not-msan
-// Memsan adds additional memory that overflows the counter
+// MSan adds additional memory that overflows the counter
+//
 // Check that we properly kill states when we exceed our memory bounds, for both
 // small and large allocations (large allocations commonly use mmap(), which can
 // follow a separate path in the allocator and statistics reporting).
@@ -7,50 +8,56 @@
 // RUN: %clang -emit-llvm -DLITTLE_ALLOC -g -c %s -o %t.little.bc
 // RUN: rm -rf %t.klee-out
 // RUN: %klee --output-dir=%t.klee-out --max-memory=20 %t.little.bc > %t.little.log
-// RUN: not grep -q "MALLOC FAILED" %t.little.log
-// RUN: not grep -q "DONE" %t.little.log
-// RUN: grep "WARNING: killing 1 states (over memory cap" %t.klee-out/warnings.txt
+// RUN: FileCheck -check-prefix=CHECK-LITTLE -input-file=%t.little.log %s
+// RUN: FileCheck -check-prefix=CHECK-WRN -input-file=%t.klee-out/warnings.txt %s
 
 // RUN: %clang -emit-llvm -g -c %s -o %t.big.bc
 // RUN: rm -rf %t.klee-out
 // RUN: %klee --output-dir=%t.klee-out --max-memory=20 %t.big.bc > %t.big.log 2> %t.big.err
-// RUN: not grep -q "MALLOC FAILED" %t.big.log
-// RUN: not grep -q "DONE" %t.big.log
-// RUN: grep "WARNING: killing 1 states (over memory cap" %t.klee-out/warnings.txt
+// RUN: FileCheck -check-prefix=CHECK-BIG -input-file=%t.big.log %s
+// RUN: FileCheck -check-prefix=CHECK-WRN -input-file=%t.klee-out/warnings.txt %s
 
-#include <stdlib.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 int main() {
-  int i, j, x=0, malloc_failed = 0;
-  
+  int i, j, x = 0, malloc_failed = 0;
+
 #ifdef LITTLE_ALLOC
   printf("IN LITTLE ALLOC\n");
-    
-  // 200 MBs total (in 1k chunks)
-  for (i=0; i<100 && !malloc_failed; i++) {
-    for (j=0; j<(1<<11); j++){
-      void * p = malloc(1<<10);
+  // CHECK-LITTLE: IN LITTLE ALLOC
+
+  // 200 MB total (in 1 KB chunks)
+  for (i = 0; i < 100 && !malloc_failed; i++) {
+    for (j = 0; j < (1 << 11); j++) {
+      void *p = malloc(1 << 10);
       malloc_failed |= (p == 0);
     }
   }
 #else
   printf("IN BIG ALLOC\n");
-  
+  // CHECK-BIG: IN BIG ALLOC
+
   // 200 MBs total
-  for (i=0; i<100 && !malloc_failed; i++) {
-    void *p = malloc(1<<21);
+  for (i = 0; i < 100 && !malloc_failed; i++) {
+    void *p = malloc(1 << 21);
     malloc_failed |= (p == 0);
     // Ensure we hit the periodic check
     // Use the pointer to be not optimized out by the compiler
-    for (j=0; j<10000; j++)
-      x+=(unsigned)p;
+    for (j = 0; j < 10000; j++)
+      x += (long)p;
   }
 #endif
 
+// CHECK-WRN: WARNING: killing 1 states (over memory cap
+
   if (malloc_failed)
     printf("MALLOC FAILED\n");
+    // CHECK-LITTLE-NOT: MALLOC FAILED
+    // CHECK-BIG-NOT: MALLOC FAILED
   printf("DONE!\n");
+  // CHECK-LITTLE-NOT: DONE!
+  // CHECK-BIG-NOT: DONE!
 
   return x;
 }