зеркало из https://github.com/microsoft/CCF.git
Remove global code coverage (#1968)
This commit is contained in:
Родитель
ce1988dfb6
Коммит
458812d9c2
|
@ -25,9 +25,6 @@ jobs:
|
|||
suite_name_suffix: "${{ parameters.target }} ${{ parameters.suffix }}"
|
||||
ctest_timeout: ${{ parameters.ctest_timeout }}
|
||||
|
||||
- ${{ if eq(parameters.suffix, 'Instrumented') }}:
|
||||
- template: coverage.yml
|
||||
|
||||
- ${{ if eq(parameters.suffix, 'Instrumented') }}:
|
||||
- template: scan_build.yml
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
steps:
|
||||
- script: ../tests/coverage/generate_coverage.sh ${{ parameters.consensus }}
|
||||
displayName: "Push coverage"
|
||||
workingDirectory: build
|
||||
env:
|
||||
CODECOV_TOKEN: $(codecov.token)
|
|
@ -15,7 +15,7 @@ parameters:
|
|||
SGX:
|
||||
cmake_args: "-DCOMPILE_TARGETS=sgx"
|
||||
debug:
|
||||
cmake_args: "-DCMAKE_BUILD_TYPE=Debug -DSAN=ON -DCOVERAGE=ON -DBUILD_SMALLBANK=OFF -DLVI_MITIGATIONS=OFF"
|
||||
cmake_args: "-DCMAKE_BUILD_TYPE=Debug -DSAN=ON -DBUILD_SMALLBANK=OFF -DLVI_MITIGATIONS=OFF"
|
||||
|
||||
jobs:
|
||||
- job: "Make"
|
||||
|
|
19
.codecov.yml
19
.codecov.yml
|
@ -1,19 +0,0 @@
|
|||
# validate this file:
|
||||
# curl --data-binary @.codecov.yml https://codecov.io/validate
|
||||
|
||||
coverage:
|
||||
range: "50...85"
|
||||
round: nearest
|
||||
precision: 2
|
||||
status:
|
||||
project:
|
||||
default: false
|
||||
ccf:
|
||||
target: 70%
|
||||
|
||||
comment:
|
||||
layout: "reach, diff, flags, files"
|
||||
behavior: default
|
||||
require_changes: false
|
||||
require_base: no
|
||||
require_head: yes
|
|
@ -152,7 +152,6 @@ if("virtual" IN_LIST COMPILE_TARGETS)
|
|||
|
||||
set_property(TARGET ccf.virtual PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
enable_coverage(ccf.virtual)
|
||||
use_client_mbedtls(ccf.virtual)
|
||||
add_san(ccf.virtual)
|
||||
add_lvi_mitigations(ccf.virtual)
|
||||
|
|
|
@ -232,7 +232,6 @@ function(add_ccf_app name)
|
|||
|
||||
set_property(TARGET ${virt_name} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
enable_coverage(${virt_name})
|
||||
use_client_mbedtls(${virt_name})
|
||||
add_san(${virt_name})
|
||||
add_lvi_mitigations(${virt_name})
|
||||
|
|
|
@ -270,7 +270,6 @@ if("virtual" IN_LIST COMPILE_TARGETS)
|
|||
add_warning_checks(cchost.virtual)
|
||||
add_san(cchost.virtual)
|
||||
add_lvi_mitigations(cchost.virtual)
|
||||
enable_coverage(cchost.virtual)
|
||||
target_link_libraries(
|
||||
cchost.virtual
|
||||
PRIVATE uv
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the Apache 2.0 License.
|
||||
import time
|
||||
import json
|
||||
|
||||
with open("coverage.json", "r") as file:
|
||||
timestamp = str(int(time.time()))
|
||||
data = json.load(file)["data"][0]
|
||||
lines_covered = str(data["totals"]["lines"]["covered"])
|
||||
lines_valid = str(data["totals"]["lines"]["count"])
|
||||
|
||||
with open("perf_summary.csv", "a") as f:
|
||||
f.write(
|
||||
timestamp
|
||||
+ ","
|
||||
+ lines_valid
|
||||
+ ",Unit_Test_Coverage,0,0,0,"
|
||||
+ lines_covered
|
||||
+ ",0,0,0,0"
|
||||
)
|
|
@ -1,70 +0,0 @@
|
|||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the Apache 2.0 License.
|
||||
import xml.etree.ElementTree as et
|
||||
import json
|
||||
import xml.dom.minidom as minidom
|
||||
import time
|
||||
|
||||
|
||||
def pretty_print(tree_root):
|
||||
tree_string = et.tostring(tree_root, "utf-8")
|
||||
final_string = tree_string
|
||||
reparsed = minidom.parseString(final_string)
|
||||
return reparsed.toprettyxml(indent="\t")
|
||||
|
||||
|
||||
with open("coverage.json", "r") as file:
|
||||
timestamp = str(time.time())
|
||||
data = json.load(file)["data"][0]
|
||||
|
||||
line_rate = str(data["totals"]["lines"]["percent"] / 100.0)
|
||||
lines_covered = str(data["totals"]["lines"]["covered"])
|
||||
lines_valid = str(data["totals"]["lines"]["count"])
|
||||
branch_rate = str(data["totals"]["functions"]["percent"] / 100.0)
|
||||
branch_covered = str(data["totals"]["functions"]["covered"])
|
||||
branch_valid = str(data["totals"]["functions"]["count"])
|
||||
coverage = et.Element(
|
||||
"coverage",
|
||||
attrib={
|
||||
"line-rate": line_rate,
|
||||
"lines-covered": lines_covered,
|
||||
"lines-valid": lines_valid,
|
||||
"branches-covered": branch_covered,
|
||||
"branches-valid": branch_valid,
|
||||
"branch-rate": branch_rate,
|
||||
"version": "1.0",
|
||||
"timestamp": timestamp,
|
||||
},
|
||||
)
|
||||
packages = et.SubElement(coverage, "packages")
|
||||
package = et.SubElement(
|
||||
packages,
|
||||
"package",
|
||||
attrib={"name": "ccf", "line-rate": line_rate, "branch-rate": branch_rate},
|
||||
)
|
||||
classes = et.SubElement(package, "classes")
|
||||
|
||||
files = data["files"]
|
||||
for file in files:
|
||||
filename = file["filename"]
|
||||
line_rate = str(file["summary"]["lines"]["percent"] / 100.0)
|
||||
branch_rate = str(file["summary"]["functions"]["percent"] / 100.0)
|
||||
class_element = et.SubElement(
|
||||
classes,
|
||||
"class",
|
||||
name=filename,
|
||||
attrib={
|
||||
"filename": filename,
|
||||
"line-rate": line_rate,
|
||||
"branch-rate": branch_rate,
|
||||
},
|
||||
)
|
||||
et.SubElement(
|
||||
class_element,
|
||||
"line",
|
||||
attrib={"branch": "false", "hits": "1", "number": "1"},
|
||||
)
|
||||
|
||||
tree = pretty_print(coverage)
|
||||
with open("coverage.xml", "w") as xml_file:
|
||||
xml_file.write(tree)
|
|
@ -1,41 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the Apache 2.0 License.
|
||||
|
||||
set -ex
|
||||
|
||||
suffix=$1
|
||||
|
||||
LLVM_VER=8
|
||||
LLVM_COV=llvm-cov-${LLVM_VER}
|
||||
LLVM_PROFDATA=llvm-profdata-${LLVM_VER}
|
||||
|
||||
objects=()
|
||||
for f in *_test; do
|
||||
PROF_PATH="$f".profraw
|
||||
if [ -f "$PROF_PATH" ]; then
|
||||
objects+=( -object "$f")
|
||||
echo "$PROF_PATH" >> prof_files
|
||||
else
|
||||
echo "Ignoring $PROF_PATH - no corresponding .profraw file"
|
||||
fi
|
||||
done
|
||||
|
||||
# Merge coverage report for all unit tests
|
||||
${LLVM_PROFDATA} merge -sparse -f prof_files -o coverage.profdata
|
||||
|
||||
# Generate combined coverage report
|
||||
${LLVM_COV} show -instr-profile coverage.profdata -output-dir=coverage -format=html "${objects[@]}" -Xdemangler c++filt -Xdemangler -n -ignore-filename-regex="(openenclave|3rdparty|/test/)"
|
||||
${LLVM_COV} export -instr-profile coverage.profdata -format=text "${objects[@]}" -Xdemangler c++filt -Xdemangler -n -ignore-filename-regex="(openenclave|3rdparty|/test/)" -summary-only > coverage.json
|
||||
|
||||
# Generate and upload combined coverage report for Codecov
|
||||
${LLVM_COV} show -instr-profile coverage.profdata "${objects[@]}" -ignore-filename-regex="(openenclave|3rdparty|/test/)" > codecov.txt
|
||||
bash <(curl -s https://codecov.io/bash) -t "${CODECOV_TOKEN}" -f codecov.txt -F "unit_${suffix}"
|
||||
|
||||
for e2e in *.virtual.so; do
|
||||
if compgen -G "./*_$e2e.profraw"; then
|
||||
${LLVM_PROFDATA} merge -sparse ./*_"$e2e".profraw -o "$e2e".profdata
|
||||
${LLVM_COV} show -instr-profile "$e2e".profdata -object cchost.virtual -object "$e2e" -ignore-filename-regex="(openenclave|3rdparty|/test/)" > "$e2e".txt
|
||||
bash <(curl -s https://codecov.io/bash) -t "${CODECOV_TOKEN}" -f "$e2e".txt -F "$(echo $"e2e" | cut -d. -f1)_$suffix"
|
||||
fi
|
||||
done
|
|
@ -1,41 +0,0 @@
|
|||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the Apache 2.0 License.
|
||||
"""
|
||||
Copies the css into the html files
|
||||
"""
|
||||
|
||||
import glob
|
||||
import os
|
||||
|
||||
|
||||
style_file = "coverage/style.css"
|
||||
index_html = "coverage/index.html"
|
||||
|
||||
with open(index_html, "a") as index_file:
|
||||
index_file.write("<p>")
|
||||
index_file.write("<div class='centered'>")
|
||||
index_file.write(
|
||||
"<table><tr><td class='column-entry-bold'>Coverage Per Unit Test</td></tr>"
|
||||
)
|
||||
|
||||
for cov_dir in glob.glob("coverage/cov_*", recursive=False):
|
||||
directory = os.path.basename(cov_dir)
|
||||
index_file.write(
|
||||
"<tr class='light-row'><td><pre><a href='"
|
||||
+ directory
|
||||
+ "/index.html'>"
|
||||
+ directory
|
||||
+ "</a></pre></td></tr>"
|
||||
)
|
||||
index_file.write("</table>")
|
||||
index_file.write("</div>")
|
||||
index_file.write("</p>")
|
||||
|
||||
with open(style_file) as style:
|
||||
css = style.read()
|
||||
for filename in glob.iglob("coverage/**/*.html", recursive=True):
|
||||
with open(filename, "a") as html:
|
||||
html.write('<style type="text/css">')
|
||||
html.write(css)
|
||||
html.write("body { background-color: seashell; }")
|
||||
html.write("</style>")
|
Загрузка…
Ссылка в новой задаче