2014-12-04 07:29:14 +08:00
|
|
|
// Test various levels of coverage
|
|
|
|
//
|
2020-05-27 10:37:04 +08:00
|
|
|
// RUN: %clangxx_msan -DINIT_VAR=1 -O1 -fsanitize-coverage=func,trace-pc-guard %s -o %t
|
2018-07-10 20:53:46 +08:00
|
|
|
// RUN: mkdir -p %t-dir
|
|
|
|
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN
|
2020-05-27 10:37:04 +08:00
|
|
|
// RUN: %clangxx_msan -O1 -fsanitize-coverage=func,trace-pc-guard %s -o %t
|
2018-07-10 20:53:46 +08:00
|
|
|
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_WARN
|
2020-05-27 10:37:04 +08:00
|
|
|
// RUN: %clangxx_msan -O1 -fsanitize-coverage=bb,trace-pc-guard %s -o %t
|
2018-07-10 20:53:46 +08:00
|
|
|
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2 --check-prefix=CHECK_WARN
|
2020-05-27 10:37:04 +08:00
|
|
|
// RUN: %clangxx_msan -O1 -fsanitize-coverage=edge,trace-pc-guard %s -o %t
|
2018-07-10 20:53:46 +08:00
|
|
|
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1:coverage_dir=%t-dir not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN
|
2016-08-15 23:14:08 +08:00
|
|
|
|
2014-12-04 07:29:14 +08:00
|
|
|
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
|
2016-04-07 07:24:16 +08:00
|
|
|
// CHECK2: 1 PCs written
|
|
|
|
// CHECK3: 2 PCs written
|