#include <stdio.h>
static volatile int sink;
-__attribute__((noinline)) void bar() { sink = 2; }
__attribute__((noinline)) void foo() { sink = 1; }
void assertNotZeroPcs(uintptr_t *buf, uintptr_t size) {
{
uintptr_t sz = __sanitizer_get_coverage_pc_buffer_pos();
- // call functions for the first time.
foo();
- bar();
uintptr_t sz1 = __sanitizer_get_coverage_pc_buffer_pos();
assertNotZeroPcs(buf.get(), sz1);
assert(sz1 > sz);
{
uintptr_t sz = __sanitizer_get_coverage_pc_buffer_pos();
- // second call shouldn't increase coverage.
- bar();
- uintptr_t sz1 = __sanitizer_get_coverage_pc_buffer_pos();
- assert(sz1 == sz);
- assertNotZeroPcs(buf.get(), sz1);
- }
-
- {
- uintptr_t sz = __sanitizer_get_coverage_pc_buffer_pos();
// reset coverage to 0.
__sanitizer_reset_coverage();
uintptr_t sz1 = __sanitizer_get_coverage_pc_buffer_pos();