-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enabled code coverage measurement #280
Draft
jxyang
wants to merge
2
commits into
oe_port
Choose a base branch
from
jxyang.codecov
base: oe_port
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
if [ -z $SGXLKL_ROOT ]; then | ||
echo "ERROR: 'SGXLKL_ROOT' is undefined. Please export SGXLKL_ROOT=<SGX-LKL-OE> source code repository" | ||
exit 1 | ||
fi | ||
|
||
# TODO: add samples to code coverage measurement. | ||
# For now, only measure anything under 'tests' except for LTP. | ||
test_folder_name=$SGXLKL_ROOT/tests | ||
test_folder_identifier="Makefile" | ||
test_exception_list="ltp" | ||
|
||
file_list=( $(sudo find $test_folder_name -name $test_folder_identifier | grep -v "$test_exception_list") ) | ||
|
||
total_tests=${#file_list[@]} | ||
counter=0 | ||
|
||
rm -f $SGXLKL_ROOT/total_cov.info | ||
|
||
for file in ${file_list[@]}; | ||
do | ||
counter=$(($counter + 1)) | ||
folder=$(dirname $file) | ||
echo "$counter/$total_tests: Measuring code coverage in $folder" | ||
cd $folder | ||
$SGXLKL_ROOT/.azure-pipelines/scripts/measure_one_cov.sh | ||
make clean | ||
done | ||
|
||
echo "Done! All coverage data are aggregated to $SGXLKL_ROOT/total_cov.info" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
|
||
if [ -z $SGXLKL_ROOT ]; then | ||
echo "ERROR: 'SGXLKL_ROOT' is undefined. Please export SGXLKL_ROOT=<SGX-LKL-OE> source code repository" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f "Makefile" ]; then | ||
echo "ERROR: ${0} can only be invoked from a directory that contains Makefile" | ||
exit 1 | ||
fi | ||
|
||
# Get the timeout from the test module | ||
DEFAULT_TIMEOUT=300 | ||
timeout=$(make gettimeout 2> /dev/null) | ||
[[ $? -ne 0 ]] && timeout=$DEFAULT_TIMEOUT | ||
echo "Execution timeout: $timeout" | ||
|
||
timeout --kill-after=$(($timeout + 15)) $timeout make run-hw | ||
timeout --kill-after=$(($timeout + 15)) $timeout make run-sw | ||
|
||
if ls *.img 1> /dev/null 2>&1; then | ||
mkdir img | ||
sudo umount img | ||
sudo mount -o loop *.img img | ||
sudo rm -rf $SGXLKL_ROOT/cov | ||
mkdir $SGXLKL_ROOT/cov | ||
|
||
# Gather all necessary files for lcov | ||
cp -r $SGXLKL_ROOT/src/* $SGXLKL_ROOT/cov | ||
sudo cp -r img$SGXLKL_ROOT/build_musl $SGXLKL_ROOT/cov | ||
sudo cp -r img$SGXLKL_ROOT/sgx-lkl-musl $SGXLKL_ROOT/cov | ||
sudo cp -r $SGXLKL_ROOT/build_musl $SGXLKL_ROOT/cov | ||
sudo cp -r $SGXLKL_ROOT/sgx-lkl-musl $SGXLKL_ROOT/cov | ||
|
||
echo "Creating $SGXLKL_ROOT/cov.info" | ||
sudo lcov -d $SGXLKL_ROOT/cov -c -o $SGXLKL_ROOT/cov.info | ||
|
||
# Accumulate the coverage data with data from other tests | ||
if [ ! -f "$SGXLKL_ROOT/total_cov.info" ]; then | ||
echo "Copy the code coverage for the 1st run" | ||
sudo mv $SGXLKL_ROOT/cov.info $SGXLKL_ROOT/total_cov.info | ||
else | ||
echo "Aggregating code coverage to $SGXLKL_ROOT/total_cov.info..." | ||
sudo lcov -a $SGXLKL_ROOT/total_cov.info -a $SGXLKL_ROOT/cov.info -o $SGXLKL_ROOT/total_cov.info | ||
fi | ||
|
||
# clean up | ||
echo "Cleaning up..." | ||
sudo umount img | ||
rm -rf img | ||
else | ||
echo "ERROR: disk image is not created" | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule sgx-lkl-musl
updated
7 files
+5 −1 | Makefile | |
+1 −0 | ldso/dynlink.c | |
+ − | libgcov_musl.a | |
+1 −0 | src/env/__init_tls.c | |
+1 −6 | src/internal/syscall.h | |
+1 −0 | src/misc/syscall.c | |
+44 −17 | src/thread/x86_64/clone.s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it makes sense that there are new scripts which duplicate the non-coverage test logic. Why not extend the existing scripts and add an extra environment variable to enable it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are key differences between this script and the test runner script.
run-hw
andrun-sw
back to back, and extract the collective coverage data from the image.If you compare this script and
test_runner
, alsomeasure_one_cov
withrun_test
, there aren't many duplicated code. I prefer to keep them separate for easier maintenance.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining. I'm trying to think how this fits into CI. Given that debug/release build modes have slightly different code paths it may make sense to capture code coverage in both modes and merge it. Or we just do it for one mode if the differences are not worth measuring. Either way, it would mean adding at least one new build job with CODE_COVERAGE=1 and corresponding test/coverage job(s).
You're saying that your script runs both hw and sw. This is a bit unfortunate because it prevents running sw on non-SGX machines and in parallel. Would it be possible to run them separately, dump the coverage files and merge them in a follow-up step?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's hard to merge coverage data from two VMs. It requires a global vm for aggregation. We will leave the work of integrating into pipeline in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's actually not that hard to do, you can specify dependencies between jobs and use build artifacts to upload/download job data.