summaryrefslogtreecommitdiff
path: root/test/msan/coverage-levels.cc
blob: 60d41c8372a332208990709bc7e41dfbd9845530 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Test various levels of coverage
//
// RUN: %clangxx_msan -DINIT_VAR=1 -O1 -fsanitize-coverage=1  %s -o %t
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN
// RUN: %clangxx_msan -O1 -fsanitize-coverage=1  %s -o %t
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_WARN
// RUN: %clangxx_msan -O1 -fsanitize-coverage=2  %s -o %t
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2 --check-prefix=CHECK_WARN
// RUN: %clangxx_msan -O1 -fsanitize-coverage=3  %s -o %t
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN
//
volatile int sink;
int main(int argc, char **argv) {
  int var;
#if INIT_VAR
  var = 0;
#endif
  if (argc == 0)
    sink = 0;
  return *(volatile int*)&var;
}

// CHECK_WARN: WARNING: MemorySanitizer: use-of-uninitialized-value
// CHECK_NOWARN-NOT: ERROR
// CHECK1:  1 PCs written
// CHECK2:  2 PCs written
// CHECK3:  3 PCs written