Remove some non-determinism from the `Darwin/duplicate_os_log_reports.cpp` test.
authorDan Liew <dan@su-root.co.uk>
Sat, 30 May 2020 22:17:41 +0000 (15:17 -0700)
committerDan Liew <dan@su-root.co.uk>
Sat, 30 May 2020 22:19:32 +0000 (15:19 -0700)
The test read from an uninitialized buffer which could cause the output
to be unpredictable.

The test is currently disabled so this won't actually change anything
until the test is re-enabled.

compiler-rt/test/asan/TestCases/Darwin/duplicate_os_log_reports.cpp

index a8314d8..dd5a257 100644 (file)
@@ -16,6 +16,7 @@
 // RUN: FileCheck %s -input-file=%t.process_syslog_output.txt
 #include <cassert>
 #include <cstdio>
+#include <cstring>
 #include <sanitizer/asan_interface.h>
 
 const int kBufferSize = 512;
@@ -37,6 +38,7 @@ void readOne() {
 
 int main() {
   buffer = static_cast<char *>(malloc(kBufferSize));
+  memset(static_cast<void *>(buffer), static_cast<int>('.'), kBufferSize);
   assert(buffer);
   // Deliberately poison `buffer` so that we have a deterministic way
   // triggering two ASan reports in a row in the no halt_on_error mode (e.g. Two