[sanitizers] rewriting test assuming assert() changes coverage.
Summary: On windows platform assert() call creates two distinct CFG edges which are coverage-instrumented. Simply calling assert would change coverage numbers on the platform. Subscribers: kubabrecka Differential Revision: http://reviews.llvm.org/D19514 llvm-svn: 267610
This commit is contained in:
parent
38c87c2e50
commit
a3060c1159
|
@ -19,23 +19,47 @@ void assertNotZeroPcs(uintptr_t *buf, uintptr_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
uintptr_t *buf = NULL;
|
{
|
||||||
uintptr_t sz = __sanitizer_get_coverage_pc_buffer(&buf);
|
uintptr_t *buf = NULL;
|
||||||
assertNotZeroPcs(buf, sz);
|
uintptr_t sz = __sanitizer_get_coverage_pc_buffer(&buf);
|
||||||
assert(sz);
|
assertNotZeroPcs(buf, sz);
|
||||||
|
assert(sz);
|
||||||
|
}
|
||||||
|
|
||||||
foo();
|
{
|
||||||
bar();
|
uintptr_t *buf = NULL;
|
||||||
uintptr_t *buf1 = NULL;
|
uintptr_t sz = __sanitizer_get_coverage_pc_buffer(&buf);
|
||||||
uintptr_t sz1 = __sanitizer_get_coverage_pc_buffer(&buf1);
|
// call functions for the first time.
|
||||||
assertNotZeroPcs(buf1, sz1);
|
foo();
|
||||||
assert(buf1 == buf);
|
bar();
|
||||||
assert(sz1 > sz);
|
uintptr_t *buf1 = NULL;
|
||||||
|
uintptr_t sz1 = __sanitizer_get_coverage_pc_buffer(&buf1);
|
||||||
|
assertNotZeroPcs(buf1, sz1);
|
||||||
|
assert(buf1 == buf);
|
||||||
|
assert(sz1 > sz);
|
||||||
|
}
|
||||||
|
|
||||||
__sanitizer_reset_coverage();
|
{
|
||||||
uintptr_t *buf3 = NULL;
|
uintptr_t *buf = NULL;
|
||||||
uintptr_t sz3 = __sanitizer_get_coverage_pc_buffer(&buf3);
|
uintptr_t sz = __sanitizer_get_coverage_pc_buffer(&buf);
|
||||||
assertNotZeroPcs(buf3, sz3);
|
// second call shouldn't increase coverage.
|
||||||
assert(buf3 == buf);
|
bar();
|
||||||
assert(sz3 < sz1);
|
uintptr_t *buf1 = NULL;
|
||||||
|
uintptr_t sz1 = __sanitizer_get_coverage_pc_buffer(&buf1);
|
||||||
|
assertNotZeroPcs(buf1, sz1);
|
||||||
|
assert(buf1 == buf);
|
||||||
|
assert(sz1 == sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
uintptr_t *buf = NULL;
|
||||||
|
uintptr_t sz = __sanitizer_get_coverage_pc_buffer(&buf);
|
||||||
|
// reset coverage to 0.
|
||||||
|
__sanitizer_reset_coverage();
|
||||||
|
uintptr_t *buf1 = NULL;
|
||||||
|
uintptr_t sz1 = __sanitizer_get_coverage_pc_buffer(&buf1);
|
||||||
|
assertNotZeroPcs(buf1, sz1);
|
||||||
|
assert(buf1 == buf);
|
||||||
|
assert(sz1 < sz);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue