aboutsummaryrefslogtreecommitdiff
path: root/test/asan/TestCases/coverage-pc-buffer.cc
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-07-23 20:45:36 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-07-23 20:45:36 +0000
commit6f08730ec5f639f05f2f15354171e4a3c9af9dc1 (patch)
tree7374e9d4448083010ada98d17976199c7e945d47 /test/asan/TestCases/coverage-pc-buffer.cc
parentc003a57e2e4a1ad9be0338806bc1038b6987155f (diff)
downloadsrc-6f08730ec5f639f05f2f15354171e4a3c9af9dc1.tar.gz
src-6f08730ec5f639f05f2f15354171e4a3c9af9dc1.zip
Vendor import of compiler-rt release_39 branch r276489:vendor/compiler-rt/compiler-rt-release_39-r276489
Notes
Notes: svn path=/vendor/compiler-rt/dist/; revision=303235 svn path=/vendor/compiler-rt/compiler-rt-release_39-r276489/; revision=303236; tag=vendor/compiler-rt/compiler-rt-release_39-r276489
Diffstat (limited to 'test/asan/TestCases/coverage-pc-buffer.cc')
-rw-r--r--test/asan/TestCases/coverage-pc-buffer.cc69
1 files changed, 43 insertions, 26 deletions
diff --git a/test/asan/TestCases/coverage-pc-buffer.cc b/test/asan/TestCases/coverage-pc-buffer.cc
index 67b6935ec602..5895a5c45d15 100644
--- a/test/asan/TestCases/coverage-pc-buffer.cc
+++ b/test/asan/TestCases/coverage-pc-buffer.cc
@@ -19,30 +19,47 @@ void assertNotZeroPcs(uintptr_t *buf, uintptr_t size) {
}
int main() {
- uintptr_t *buf = NULL;
- uintptr_t sz = __sanitizer_get_coverage_pc_buffer(&buf);
- assertNotZeroPcs(buf, sz);
- assert(sz);
-
- foo();
- bar();
- uintptr_t *buf1 = NULL;
- uintptr_t sz1 = __sanitizer_get_coverage_pc_buffer(&buf1);
- assertNotZeroPcs(buf1, sz1);
- assert(buf1 == buf);
- assert(sz1 > sz);
-
- bar();
- uintptr_t *buf2 = NULL;
- uintptr_t sz2 = __sanitizer_get_coverage_pc_buffer(&buf2);
- assertNotZeroPcs(buf2, sz2);
- assert(buf2 == buf);
- assert(sz2 > sz1);
-
- __sanitizer_reset_coverage();
- uintptr_t *buf3 = NULL;
- uintptr_t sz3 = __sanitizer_get_coverage_pc_buffer(&buf3);
- assertNotZeroPcs(buf3, sz3);
- assert(buf3 == buf);
- assert(sz3 < sz2);
+ {
+ uintptr_t *buf = NULL;
+ uintptr_t sz = __sanitizer_get_coverage_pc_buffer(&buf);
+ assertNotZeroPcs(buf, sz);
+ assert(sz);
+ }
+
+ {
+ uintptr_t *buf = NULL;
+ uintptr_t sz = __sanitizer_get_coverage_pc_buffer(&buf);
+ // call functions for the first time.
+ foo();
+ bar();
+ 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);
+ // second call shouldn't increase coverage.
+ bar();
+ 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);
+ }
}