Skip to content

Commit

Permalink
Enable test coverage on azure pipeline (sonic-net#912)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik authored Aug 28, 2021
1 parent cf1af5f commit 29c454a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
36 changes: 34 additions & 2 deletions .azure-pipelines/build-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ parameters:
type: boolean
default: false

- name: archive_gcov
type: boolean
default: false

jobs:
- job:
displayName: ${{ parameters.arch }}
Expand Down Expand Up @@ -97,20 +101,48 @@ jobs:
- checkout: self
submodules: true
- script: |
set -ex
./autogen.sh
fakeroot dpkg-buildpackage -b -us -uc -Tbinary-syncd-vs -j$(nproc) && cp ../*.deb .
displayName: "Compile sonic sairedis"
fakeroot debian/rules DEB_CONFIGURE_EXTRA_FLAGS='--enable-code-coverage' CFLAGS="" CXXFLAGS="" binary-syncd-vs && cp ../*.deb .
displayName: "Compile sonic sairedis with coverage enabled"
- script: |
sudo cp azsyslog.conf /etc/rsyslog.conf
sudo service rsyslog restart
displayName: "Update rsyslog.conf"
- ${{ if eq(parameters.run_unit_test, true) }}:
- script: |
set -ex
git clone https://github.com/Spacetown/gcovr.git
cd gcovr/
git checkout origin/recursive_search_file
sudo pip3 install setuptools
sudo python3 setup.py install
cd ..
sudo rm -rf gcovr
displayName: "Install gcovr 5.0 with recursive fix"
- script: |
set -ex
make check
gcovr --version
gcovr -r ./ -e ".+/saimetadata.c" -e ".+/json.hpp" -e "swss/.+" --exclude-unreachable-branches --exclude-throw-branches -x -o coverage.xml
displayName: "Run sonic sairedis unit tests"
- publish: $(System.DefaultWorkingDirectory)/
artifact: ${{ parameters.artifact_name }}
displayName: "Archive sonic sairedis debian packages"
- ${{ if eq(parameters.archive_gcov, true) }}:
- script: |
set -ex
# Install .NET CORE
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo apt-add-repository https://packages.microsoft.com/debian/10/prod
sudo apt-get update
sudo apt-get install -y dotnet-sdk-5.0
displayName: "Install .NET CORE"
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml'
displayName: 'Publish test coverage'
- script: |
pwd
sudo chmod a+r /var/log/syslog*
Expand Down
2 changes: 1 addition & 1 deletion SAI
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ binary-syncd-vs:

override_dh_auto_configure:
./autogen.sh
dh_auto_configure -- $(shell cat /tmp/syncd-build) ${SWSS_COMMON_CONFIG}
dh_auto_configure -- $(DEB_CONFIGURE_EXTRA_FLAGS) $(shell cat /tmp/syncd-build) ${SWSS_COMMON_CONFIG}

override_dh_install:
dh_install
Expand Down

0 comments on commit 29c454a

Please sign in to comment.