Compiler projects using llvm
# Test "report" command with and without multiple threads.

RUN: llvm-cov report -num-threads=1 \
RUN:   -path-equivalence=/tmp,%S/Inputs \
RUN:   -instr-profile %S/Inputs/multithreaded_report/main.profdata \
RUN:   %S/Inputs/multithreaded_report/main.covmapping > %t.1.report

RUN: llvm-cov report -num-threads=10 \
RUN:   -path-equivalence=/tmp,%S/Inputs \
RUN:   -instr-profile %S/Inputs/multithreaded_report/main.profdata \
RUN:   %S/Inputs/multithreaded_report/main.covmapping > %t.2.report

RUN: diff %t.1.report %t.2.report

# Test "export" command with and without multiple threads.
RUN: llvm-cov export -num-threads=1 \
RUN:   -path-equivalence=/tmp,%S/Inputs \
RUN:   -instr-profile %S/Inputs/multithreaded_report/main.profdata \
RUN:   %S/Inputs/multithreaded_report/main.covmapping > %t.1.json

RUN: llvm-cov export -num-threads=10 \
RUN:   -path-equivalence=/tmp,%S/Inputs \
RUN:   -instr-profile %S/Inputs/multithreaded_report/main.profdata \
RUN:   %S/Inputs/multithreaded_report/main.covmapping > %t.2.json

RUN: diff %t.1.json %t.2.json

# Test "show" command with and without multiple threads, single text file.
RUN: llvm-cov show -format=text -num-threads=1 \
RUN:   -path-equivalence=/tmp,%S/Inputs \
RUN:   -instr-profile %S/Inputs/multithreaded_report/main.profdata \
RUN:   %S/Inputs/multithreaded_report/main.covmapping > %t.1.text

RUN: llvm-cov show -format=text -num-threads=10 \
RUN:   -path-equivalence=/tmp,%S/Inputs \
RUN:   -instr-profile %S/Inputs/multithreaded_report/main.profdata \
RUN:   %S/Inputs/multithreaded_report/main.covmapping > %t.2.text

RUN: diff %t.1.text %t.2.text

# Test "show" command with and without multiple threads, single HTML file.
RUN: llvm-cov show -format=html -num-threads=1 \
RUN:   -path-equivalence=/tmp,%S/Inputs \
RUN:   -instr-profile %S/Inputs/multithreaded_report/main.profdata \
RUN:   %S/Inputs/multithreaded_report/main.covmapping > %t.1.html

RUN: llvm-cov show -format=html -num-threads=10 \
RUN:   -path-equivalence=/tmp,%S/Inputs \
RUN:   -instr-profile %S/Inputs/multithreaded_report/main.profdata \
RUN:   %S/Inputs/multithreaded_report/main.covmapping > %t.2.html

RUN: diff %t.1.html %t.2.html 

# Test "show" command with and without multiple threads, text directory.
RUN: llvm-cov show -format=text -num-threads=1 \
RUN:   -path-equivalence=/tmp,%S/Inputs \
RUN:   -instr-profile %S/Inputs/multithreaded_report/main.profdata \
RUN:   %S/Inputs/multithreaded_report/main.covmapping -o %t.1.text_dir

RUN: llvm-cov show -format=text -num-threads=10 \
RUN:   -path-equivalence=/tmp,%S/Inputs \
RUN:   -instr-profile %S/Inputs/multithreaded_report/main.profdata \
RUN:   %S/Inputs/multithreaded_report/main.covmapping -o %t.2.text_dir

RUN: diff -r %t.1.text_dir %t.2.text_dir

# Test "show" command with and without multiple threads, HTML directory.
RUN: llvm-cov show -format=html -num-threads=1 \
RUN:   -path-equivalence=/tmp,%S/Inputs \
RUN:   -instr-profile %S/Inputs/multithreaded_report/main.profdata \
RUN:   %S/Inputs/multithreaded_report/main.covmapping -o %t.1.html_dir

RUN: llvm-cov show -format=html -num-threads=10 \
RUN:   -path-equivalence=/tmp,%S/Inputs \
RUN:   -instr-profile %S/Inputs/multithreaded_report/main.profdata \
RUN:   %S/Inputs/multithreaded_report/main.covmapping -o %t.2.html_dir

RUN: diff -r %t.1.html_dir %t.2.html_dir


Instructions for regenerating the test:

# cd %S/Inputs/multithreaded_report

cp -r . /tmp/multithreaded_report

clang++ -std=c++11 -mllvm -enable-name-compression=false \
    -fprofile-instr-generate -fcoverage-mapping \
    /tmp/multithreaded_report/*.cc -o main

LLVM_PROFILE_FILE="main.profraw" ./main
llvm-profdata merge main.profraw -o main.profdata
llvm-cov convert-for-testing ./main -o ./main.covmapping
rm main main.profraw