File: mcdc-maxbs.test

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (49 lines) | stat: -rw-r--r-- 1,873 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Test not to trigger the assertion failure in llvm-cov with empty bitmap.
# REQUIRES: asserts

# mcdc-maxbs.o contains the record:
#
# sub:
#   Decision,File 0, 5:11 -> 5:59 = M:1, C:4
#   Branch,File 0, 5:12 -> 5:20 = #5, ((#0 - #1) - #5) [1,3,2]
#   Branch,File 0, 5:24 -> 5:32 = #6, (#5 - #6) [3,0,2]
#   Branch,File 0, 5:38 -> 5:46 = #7, (#4 - #7) [2,4,0]
#   Branch,File 0, 5:50 -> 5:58 = #8, (#7 - #8) [4,0,0]
#   Decision,File 1, 1:23 -> 1:47 = M:0, C:2
#   Branch,File 1, 1:23 -> 1:33 = #2, (#0 - #2) [1,2,0]
#   Branch,File 1, 1:37 -> 1:47 = #3, (#2 - #3) [2,0,0]
#
# With the previous implementation, `Decision M:0 C:2` was picked up as
# the last `Decision`.
# The size of the bitmap was reported as `1` in this case.
# Actually, the largest `Decision` is `M:1 C:4` and the size should be `3`
# (Idx=1, len=16 bits).
#
# When a corresponding bitmap was not emitted, the dummy zero-ed bitmap is
# allocated as `BitmapBytes` with `getMaxBitmapSize(Record) + 1`
# (in this case, `1 + 1`, less than `3`).
# It may overrun and would trigger `unexpected test vector`
# by trailing uninitialized garbage.

# RUN: llvm-profdata merge %S/Inputs/mcdc-maxbs.proftext -o %t.profdata
# RUN: llvm-cov report --show-mcdc-summary %S/Inputs/mcdc-maxbs.o -instr-profile %t.profdata

# Instructions for regenerating the test object:

cd %S/Inputs # or copy %S/Inputs/mcdc-maxbs.c into the working directory

clang -Os -fcoverage-mcdc -fprofile-instr-generate \
    -fcoverage-mapping -fcoverage-compilation-dir=. \
    -mllvm -enable-name-compression=false \
    mcdc-maxbs.c -c -o mcdc-maxbs.o

# Instructions for regenerating the test vector:

clang -fprofile-instr-generate mcdc-maxbs.o
rm -f default.prof*

# Doesn't crash if argc > 1
./a.out

llvm-profdata merge --sparse -o default.profdata default.profraw
llvm-profdata merge --text -o mcdc-maxbs.proftext default.profdata