Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 1 | // Test coverage_order_pcs=1 flag which orders the PCs by their appearance. |
| 2 | // RUN: DIR=%T/coverage-order-pcs |
| 3 | // RUN: rm -rf $DIR |
| 4 | // RUN: mkdir $DIR |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 5 | // RUN: %clangxx_asan -fsanitize-coverage=func %s -o %t |
| 6 | // RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:coverage_dir=$DIR:coverage=1:coverage_order_pcs=0 %run %t |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 7 | // RUN: mv $DIR/*sancov $DIR/A |
| 8 | |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 9 | // RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:coverage_dir=$DIR:coverage=1:coverage_order_pcs=0 %run %t 1 |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 10 | // RUN: mv $DIR/*sancov $DIR/B |
| 11 | |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 12 | // RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:coverage_dir=$DIR:coverage=1:coverage_order_pcs=1 %run %t |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 13 | // RUN: mv $DIR/*sancov $DIR/C |
| 14 | |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 15 | // RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:coverage_dir=$DIR:coverage=1:coverage_order_pcs=1 %run %t 1 |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 16 | // RUN: mv $DIR/*sancov $DIR/D |
| 17 | // |
| 18 | // RUN: (%sancov print $DIR/A; %sancov print $DIR/B; %sancov print $DIR/C; %sancov print $DIR/D) | FileCheck %s |
| 19 | // |
| 20 | // RUN: rm -rf $DIR |
| 21 | // Ordering works only in 64-bit mode for now. |
| 22 | // REQUIRES: asan-64-bits |
| 23 | #include <stdio.h> |
| 24 | |
| 25 | void foo() { fprintf(stderr, "FOO\n"); } |
| 26 | void bar() { fprintf(stderr, "BAR\n"); } |
| 27 | |
| 28 | int main(int argc, char **argv) { |
| 29 | if (argc == 2) { |
| 30 | foo(); |
| 31 | bar(); |
| 32 | } else { |
| 33 | bar(); |
| 34 | foo(); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | // Run A: no ordering |
| 39 | // CHECK: [[FOO:0x[0-9a-f]*]] |
| 40 | // CHECK-NEXT: [[BAR:0x[0-9a-f]*]] |
| 41 | // CHECK-NEXT: [[MAIN:0x[0-9a-f]*]] |
| 42 | // |
| 43 | // Run B: still no ordering |
| 44 | // CHECK-NEXT: [[FOO]] |
| 45 | // CHECK-NEXT: [[BAR]] |
| 46 | // CHECK-NEXT: [[MAIN]] |
| 47 | // |
| 48 | // Run C: MAIN, BAR, FOO |
| 49 | // CHECK-NEXT: [[MAIN]] |
| 50 | // CHECK-NEXT: [[BAR]] |
| 51 | // CHECK-NEXT: [[FOO]] |
| 52 | // |
| 53 | // Run D: MAIN, FOO, BAR |
| 54 | // CHECK-NEXT: [[MAIN]] |
| 55 | // CHECK-NEXT: [[FOO]] |
| 56 | // CHECK-NEXT: [[BAR]] |