Skip to content

Commit

Permalink
Adds psp lcov
Browse files Browse the repository at this point in the history
  • Loading branch information
Figueroa committed Aug 5, 2024
1 parent 4095156 commit fffb26f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion runCFSscript.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

cfs_apps=( apps/sch_lab apps/ci_lab apps/to_lab apps/sample_app tools/cFS-GroundSystem tools/elf2cfetbl tools/tblCRCTool apps/cf apps/cs apps/ds apps/fm apps/hk apps/hs apps/lc apps/md apps/mm apps/sc cfe )
cfs_apps=( apps/sch_lab apps/ci_lab apps/to_lab apps/sample_app tools/cFS-GroundSystem tools/elf2cfetbl tools/tblCRCTool apps/cf apps/cs apps/ds apps/fm apps/hk apps/hs apps/lc apps/md apps/mm apps/sc cfe psp )
scriptNums=( 1 2 3 4 5 6 7 8 )

# Process each element to get the substring after the last '/'
Expand Down
35 changes: 22 additions & 13 deletions scripts/lcov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
#assumes these are all in the cFS/apps directory
#and that they're all in lowercase
app=$1
applist="cf cs ds fm hk hs lc md mm sc"
results_dir="${app}_lcov_results/"

# start fresh
make distclean
rm -rf ${results_dir}
rm -rf sample_defs
rm Makefile

Expand All @@ -18,11 +21,16 @@ APP_UPPER=$(echo $app | sed 's/[a-z]/\U&/g')
cp ./cfe/cmake/Makefile.sample Makefile
cp -r ./cfe/cmake/sample_defs sample_defs

# add repo to build
app_list_line=$(cat sample_defs/targets.cmake | grep -o "list(APPEND MISSION_GLOBAL_APPLIST.*")
if [[ ${app_list_line} != *"$APP_LOWER"* ]];then
prev_app="sample_lib"
sed -i "s/$prev_app/& $APP_LOWER/" "sample_defs/targets.cmake";
if [[ " $applist " =~ " $app " ]]; then
# add repo to build
app_list_line=$(cat sample_defs/targets.cmake | grep -o "list(APPEND MISSION_GLOBAL_APPLIST.*")
if [[ ${app_list_line} != *"$APP_LOWER"* ]];then
prev_app="sample_lib"
sed -i "s/$prev_app/& $APP_LOWER/" "sample_defs/targets.cmake";
fi
app_dir="apps/"
elif [ ${app} = "psp" ]; then
app_dir=""
fi

# make prep
Expand All @@ -32,15 +40,16 @@ make SIMULATION=native ENABLE_UNIT_TESTS=true OMIT_DEPRECATED=true prep
make -C build/tools/elf2cfetbl

# build app target
make -C build/native/default_cpu1/apps/$APP_LOWER
make -C build/native/default_cpu1/$app_dir$APP_LOWER

# store all result files
mkdir -p ${results_dir}

# capture initial lcov and run test
lcov --capture --initial --directory build --output-file "${app}_coverage_base.info"
(cd build/native/default_cpu1/apps/$APP_LOWER; ctest --verbose) | tee "${app}_test_results.txt"
lcov --capture --initial --directory build --output-file "${results_dir}${app}_coverage_base.info"
(cd build/native/default_cpu1/$app_dir$APP_LOWER; ctest --verbose) | tee "${results_dir}${app}_test_results.txt"

# calculate coveage
lcov --capture --rc lcov_branch_coverage=1 --directory build --output-file "${app}_coverage_test.info"
lcov --rc lcov_branch_coverage=1 --add-tracefile "${app}_coverage_base.info" --add-tracefile "${app}_coverage_test.info" --output-file "${app}_coverage_total.info"
genhtml "${app}_coverage_total.info" --branch-coverage --output-directory "${app}_lcov" | tee "${app}_lcov_out.txt"


lcov --capture --rc lcov_branch_coverage=1 --directory build --output-file "${results_dir}${app}_coverage_test.info"
lcov --rc lcov_branch_coverage=1 --add-tracefile "${results_dir}${app}_coverage_base.info" --add-tracefile "${results_dir}${app}_coverage_test.info" --output-file "${results_dir}${app}_coverage_total.info"
genhtml "${results_dir}${app}_coverage_total.info" --branch-coverage --output-directory "${results_dir}${app}_lcov" | tee "${results_dir}${app}_lcov_out.txt"

0 comments on commit fffb26f

Please sign in to comment.