Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 1 | // Test for direct coverage writing with lots of data. |
| 2 | // Current implementation maps output file in chunks of 64K. This test overflows |
| 3 | // 1 chunk. |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 4 | |
Pirama Arumuga Nainar | 259f706 | 2015-05-06 11:49:53 -0700 | [diff] [blame^] | 5 | // RUN: %clangxx_asan -fsanitize-coverage=1 -O0 -DSHARED %s -shared -o %dynamiclib -fPIC |
| 6 | // RUN: %clangxx_asan -fsanitize-coverage=1 -O0 %s %libdl -o %t |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 7 | |
| 8 | // RUN: rm -rf %T/coverage-direct-large |
| 9 | |
| 10 | // RUN: mkdir -p %T/coverage-direct-large/normal && cd %T/coverage-direct-large/normal |
Pirama Arumuga Nainar | 259f706 | 2015-05-06 11:49:53 -0700 | [diff] [blame^] | 11 | // RUN: ASAN_OPTIONS=coverage=1:coverage_direct=0:verbosity=1 %run %t %dynamiclib |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 12 | // RUN: %sancov print *.sancov >out.txt |
| 13 | // RUN: cd ../.. |
| 14 | |
| 15 | // RUN: mkdir -p %T/coverage-direct-large/direct && cd %T/coverage-direct-large/direct |
Pirama Arumuga Nainar | 259f706 | 2015-05-06 11:49:53 -0700 | [diff] [blame^] | 16 | // RUN: ASAN_OPTIONS=coverage=1:coverage_direct=1:verbosity=1 %run %t %dynamiclib |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 17 | // RUN: %sancov rawunpack *.sancov.raw |
| 18 | // RUN: %sancov print *.sancov >out.txt |
| 19 | // RUN: cd ../.. |
| 20 | |
| 21 | // RUN: diff -u coverage-direct-large/normal/out.txt coverage-direct-large/direct/out.txt |
| 22 | // |
| 23 | // XFAIL: android |
| 24 | |
| 25 | #define F0(Q, x) Q(x) |
| 26 | #define F1(Q, x) \ |
| 27 | F0(Q, x##0) F0(Q, x##1) F0(Q, x##2) F0(Q, x##3) F0(Q, x##4) F0(Q, x##5) \ |
| 28 | F0(Q, x##6) F0(Q, x##7) F0(Q, x##8) F0(Q, x##9) |
| 29 | #define F2(Q, x) \ |
| 30 | F1(Q, x##0) F1(Q, x##1) F1(Q, x##2) F1(Q, x##3) F1(Q, x##4) F1(Q, x##5) \ |
| 31 | F1(Q, x##6) F1(Q, x##7) F1(Q, x##8) F1(Q, x##9) |
| 32 | #define F3(Q, x) \ |
| 33 | F2(Q, x##0) F2(Q, x##1) F2(Q, x##2) F2(Q, x##3) F2(Q, x##4) F2(Q, x##5) \ |
| 34 | F2(Q, x##6) F2(Q, x##7) F2(Q, x##8) F2(Q, x##9) |
| 35 | #define F4(Q, x) \ |
| 36 | F3(Q, x##0) F3(Q, x##1) F3(Q, x##2) F3(Q, x##3) F3(Q, x##4) F3(Q, x##5) \ |
| 37 | F3(Q, x##6) F3(Q, x##7) F3(Q, x##8) F3(Q, x##9) |
| 38 | |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 39 | #define DECL(x) __attribute__((noinline)) static void x() {} |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 40 | #define CALL(x) x(); |
| 41 | |
| 42 | F4(DECL, f) |
| 43 | |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 44 | #ifdef SHARED |
| 45 | extern "C" void so_entry() { |
| 46 | F4(CALL, f) |
| 47 | } |
| 48 | #else |
| 49 | |
| 50 | #include <assert.h> |
| 51 | #include <dlfcn.h> |
Pirama Arumuga Nainar | 259f706 | 2015-05-06 11:49:53 -0700 | [diff] [blame^] | 52 | #include <stdio.h> |
| 53 | int main(int argc, char **argv) { |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 54 | F4(CALL, f) |
Pirama Arumuga Nainar | 259f706 | 2015-05-06 11:49:53 -0700 | [diff] [blame^] | 55 | assert(argc > 1); |
| 56 | void *handle1 = dlopen(argv[1], RTLD_LAZY); // %dynamiclib |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 57 | assert(handle1); |
| 58 | void (*so_entry)() = (void (*)())dlsym(handle1, "so_entry"); |
| 59 | assert(so_entry); |
| 60 | so_entry(); |
| 61 | |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 62 | return 0; |
| 63 | } |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 64 | |
| 65 | #endif // SHARED |