Skip to content

Commit

Permalink
Fix nasa#729, Add bundle and local config unit test and coverage check
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed Apr 5, 2021
1 parent 65c584f commit 34efdb3
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 8 deletions.
30 changes: 22 additions & 8 deletions .github/workflows/codeql-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
timeout-minutes: 15

steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Install cppcheck
run: sudo apt-get install lcov -y

- name: Checkout bundle
uses: actions/checkout@v2
with:
Expand All @@ -38,21 +40,33 @@ jobs:
languages: c
queries: +security-extended, security-and-quality

# Setup the build system
- name: Set up for build
run: |
cp ./cfe/cmake/Makefile.sample Makefile
cp -r ./cfe/cmake/sample_defs sample_defs
make prep
# Build the code
- name: Build
run: make -j native/default_cpu1/osal/

- name: Baseline coverage and run tests
run: |
lcov --rc lcov_branch_coverage=1 --capture --initial --directory build/native/default_cpu1/osal/ --output-file coverage_base.info
(cd build/native/default_cpu1/osal && make test)
- name: Calculate coverage
run: |
lcov --rc lcov_branch_coverage=1 --capture --directory build/native/default_cpu1/osal/ --output-file coverage_test.info
lcov --rc lcov_branch_coverage=1 --add-tracefile coverage_base.info --add-tracefile coverage_test.info --output-file coverage_total.info
genhtml --branch-coverage coverage_total.info --output-directory lcov | tee lcov_out.txt
- name: Confirm 100% line coverage
run: |
make osal
make native/default_cpu1/osal/tests/
make native/default_cpu1/osal/unit-test-coverage/
make native/default_cpu1/osal/unit-tests/
make native/default_cpu1/osal/ut-stubs/
if [[ `grep -A 3 "Overall coverage rate" lcov_out.txt | grep lines` != *"100.0%"* ]]; then
grep -A 3 "Overall coverage rate" lcov_out.txt
echo "Lacks 100.0% line unit test coverage"
exit -1
fi
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
51 changes: 51 additions & 0 deletions .github/workflows/local_unit_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "Local Unit Test"

on:
push:
pull_request:

env:
SIMULATION: native
ENABLE_UNIT_TESTS: true
OMIT_DEPRECATED: true
BUILDTYPE: release

jobs:

Local-Unit-Test:
runs-on: ubuntu-18.04
timeout-minutes: 15

steps:
- name: Install cppcheck
run: sudo apt-get install lcov -y

- name: Checkout submodule
uses: actions/checkout@v2

- name: Set up for build
run: |
cmake -DENABLE_UNIT_TESTS=true -DOSAL_SYSTEM_BSPTYPE=generic-linux -DOSAL_CONFIG_DEBUG_PERMISSIVE_MODE=TRUE .
- name: Build the code
run: make -j

# Baseline lcov and run all tests
- name: Test
run: |
lcov --rc lcov_branch_coverage=1 --capture --initial --directory ./ --output-file coverage_base.info
make test
- name: Calculate coverage
run: |
lcov --rc lcov_branch_coverage=1 --capture --directory ./ --output-file coverage_test.info
lcov --rc lcov_branch_coverage=1 --add-tracefile coverage_base.info --add-tracefile coverage_test.info --output-file coverage_total.info
genhtml --branch-coverage coverage_total.info --output-directory lcov | tee lcov_out.txt
- name: Confirm 100% line coverage
run: |
if [[ `grep -A 3 "Overall coverage rate" lcov_out.txt | grep lines` != *"100.0%"* ]]; then
grep -A 3 "Overall coverage rate" lcov_out.txt
echo "Lacks 100.0% line unit test coverage"
exit -1
fi

0 comments on commit 34efdb3

Please sign in to comment.