[MSAN] Fix memcmp_test on MIPS
authorSagar Thakur <sagar.thakur@imgtec.com>
Wed, 24 Feb 2016 13:48:14 +0000 (13:48 +0000)
committerSagar Thakur <sagar.thakur@imgtec.com>
Wed, 24 Feb 2016 13:48:14 +0000 (13:48 +0000)
Summary: As per the test the 4th element of both arrays are not initialized and hence will contain garbage values. Memcmp returns the difference between the garbage values of the 4th element which will be different on every run of the test. And since the return value of memcmp is returned from main, we are getting random exit code every time.

Reviewers: kcc, eugenis
Subscribers: mohit.bhakkad, jaydeep, llvm-commits
Differential: http://reviews.llvm.org/D17534
llvm-svn: 261739

compiler-rt/test/msan/memcmp_test.cc

index 95228eb..5ade58a 100644 (file)
@@ -3,13 +3,16 @@
 // RUN: MSAN_OPTIONS=intercept_memcmp=0 %run %t
 
 #include <string.h>
+#include <stdio.h>
 int main(int argc, char **argv) {
   char a1[4];
   char a2[4];
   for (int i = 0; i < argc * 3; i++)
     a2[i] = a1[i] = i;
   int res = memcmp(a1, a2, 4);
-  return res;
+  if (!res)
+    printf("equals");
+  return 0;
   // CHECK: Uninitialized bytes in __interceptor_memcmp at offset 3
   // CHECK: MemorySanitizer: use-of-uninitialized-value
 }