Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
f9c08ea
[gcov] swss support gcov
pettershao-ragilenetworks May 8, 2021
0e117c3
Update gcov_support.sh
pettershao-ragilenetworks May 8, 2021
112e7d4
Update test_zzgcov.py
pettershao-ragilenetworks May 8, 2021
4d81e30
fix conflict
pettershao-ragilenetworks May 8, 2021
254411b
Merge branch 'gcov_for_swss_daemon' of https://github.com/pettershao-…
pettershao-ragilenetworks May 8, 2021
92dd3d9
speed up for build
pettershao-ragilenetworks May 8, 2021
ddf04a6
rm cpp lgtm checking for speed up
pettershao-ragilenetworks May 8, 2021
f81aa65
Update lgtm.yml
pettershao-ragilenetworks May 8, 2021
9a6555e
code change trigger build
pettershao-ragilenetworks May 8, 2021
43d291d
Update test-docker-sonic-vs-template.yml
pettershao-ragilenetworks May 10, 2021
0893a34
Update test-docker-sonic-vs-template.yml
pettershao-ragilenetworks May 10, 2021
87d45c2
Update test-docker-sonic-vs-template.yml
pettershao-ragilenetworks May 10, 2021
6763c2a
Update gcov_support.sh
pettershao-ragilenetworks May 13, 2021
b8734d7
fix container conflicts for lcov
pettershao-ragilenetworks May 17, 2021
9e151da
Update gcov_support.sh
pettershao-ragilenetworks May 18, 2021
c34e006
update gcov_support.sh
pettershao-ragilenetworks May 18, 2021
0c9707d
update gcov_support.sh
pettershao-ragilenetworks May 18, 2021
340441f
Update gcov_support.sh
pettershao-ragilenetworks May 18, 2021
5783f27
Update gcov_support.sh
pettershao-ragilenetworks May 18, 2021
24dff6b
fix vs tests error
pettershao-ragilenetworks May 18, 2021
5d10659
fix can't find gcda issue
pettershao-ragilenetworks May 18, 2021
84fec35
Update test-docker-sonic-vs-template.yml
pettershao-ragilenetworks May 19, 2021
770e49f
mv sleep into script
pettershao-ragilenetworks May 19, 2021
de30000
update work dir
pettershao-ragilenetworks May 20, 2021
2905898
fix conflict
pettershao-ragilenetworks May 20, 2021
6f9a927
fix conflict
pettershao-ragilenetworks May 20, 2021
c09aa2e
update info dir
pettershao-ragilenetworks May 20, 2021
4d066c5
update gcov_support.sh
pettershao-ragilenetworks May 20, 2021
a95e118
add gcov_preload.so
pettershao-ragilenetworks May 23, 2021
3ee3d39
Update gcov_support.sh
pettershao-ragilenetworks May 23, 2021
c32521d
update gcc version
pettershao-ragilenetworks May 24, 2021
da8c474
update test-docker-sonic-vs-template.yml
pettershao-ragilenetworks May 24, 2021
526a359
add gcov.yml
pettershao-ragilenetworks May 24, 2021
82081b5
update gcov.yml paramaters
pettershao-ragilenetworks May 24, 2021
f70b8df
add gcov.yml
pettershao-ragilenetworks May 24, 2021
c3bab57
trigger build
pettershao-ragilenetworks May 25, 2021
8d4aa90
fix conflict
pettershao-ragilenetworks May 25, 2021
57fc240
temp change sai branch to other
pettershao-ragilenetworks May 25, 2021
faecfc0
temp change sai to 829
pettershao-ragilenetworks May 25, 2021
217116a
temp to wget sairedis debs
pettershao-ragilenetworks May 27, 2021
01519f9
fix conflict
pettershao-ragilenetworks May 27, 2021
2814fb3
change wget to curl
pettershao-ragilenetworks May 27, 2021
10855c3
fix curl fail
pettershao-ragilenetworks May 27, 2021
11a5df9
fix dpkg error
pettershao-ragilenetworks May 27, 2021
8cce398
fix docker vs build error
pettershao-ragilenetworks May 27, 2021
670a1da
Merge https://github.com/Azure/sonic-swss into gcov_for_swss_daemon
pettershao-ragilenetworks May 27, 2021
088401f
forbid test failed
pettershao-ragilenetworks May 27, 2021
dec56af
fix gcov temp output folder
pettershao-ragilenetworks May 27, 2021
c1cc68f
adjust gcov folder name
pettershao-ragilenetworks May 27, 2021
d647a3c
unzip gcov artifact
pettershao-ragilenetworks May 27, 2021
66c456b
update yml
pettershao-ragilenetworks May 27, 2021
d9b4251
update yml
pettershao-ragilenetworks May 27, 2021
4b57f87
implement gcov report generation in new container specified by gcov.yml
pettershao-ragilenetworks May 31, 2021
69968b5
update gcov.yml
pettershao-ragilenetworks Jun 1, 2021
0a08eb7
update gcov.yml
pettershao-ragilenetworks Jun 1, 2021
f2e8065
update gcov.yml
pettershao-ragilenetworks Jun 1, 2021
2bf7008
update gcov.yml
pettershao-ragilenetworks Jun 1, 2021
7398f03
update gcov.yml
pettershao-ragilenetworks Jun 1, 2021
7d8ff8f
update gcov.yml
pettershao-ragilenetworks Jun 1, 2021
ee5ed49
update tests/gcov_support.sh
pettershao-ragilenetworks Jun 1, 2021
a4bff79
check gcov fail
pettershao-ragilenetworks Jun 2, 2021
dfc610e
fix conflict
pettershao-ragilenetworks Jun 2, 2021
e66f7a6
fix conflict
pettershao-ragilenetworks Jun 2, 2021
1157911
Merge https://github.com/Azure/sonic-swss into gcov_for_swss_daemon
pettershao-ragilenetworks Jun 2, 2021
76c0225
keep one test case for speed up
pettershao-ragilenetworks Jun 2, 2021
5809e34
temp add ssp.txt file
pettershao-ragilenetworks Jun 2, 2021
78da84b
update gcov.yml
pettershao-ragilenetworks Jun 2, 2021
46489b2
update gcov.yml
pettershao-ragilenetworks Jun 2, 2021
07b1ecf
update gcov_support.sh
pettershao-ragilenetworks Jun 2, 2021
3666083
fix conflict
pettershao-ragilenetworks Jun 2, 2021
7bc6614
update gcov.yml
pettershao-ragilenetworks Jun 2, 2021
ca58c3e
update gcov.yml
pettershao-ragilenetworks Jun 2, 2021
2f71faf
update gcov_support.sh
pettershao-ragilenetworks Jun 3, 2021
5256239
Merge https://github.com/Azure/sonic-swss into gcov_for_swss_daemon
pettershao-ragilenetworks Jun 3, 2021
e4d14c9
update gcov_support.sh
pettershao-ragilenetworks Jun 3, 2021
e84bdea
preload libgcov_preload.so
pettershao-ragilenetworks Jun 3, 2021
e86d027
install libgcov_preload.so
pettershao-ragilenetworks Jun 3, 2021
11972f0
cp lib to /usr/lib
pettershao-ragilenetworks Jun 3, 2021
d8f7598
mkdir usr/lib
pettershao-ragilenetworks Jun 3, 2021
2741801
prepare publish environment
pettershao-ragilenetworks Jun 3, 2021
7b85423
update publish name
pettershao-ragilenetworks Jun 3, 2021
f2b7518
update gcov.yml
pettershao-ragilenetworks Jun 3, 2021
b272321
update publish-gcov.yml
pettershao-ragilenetworks Jun 4, 2021
2faf8c2
update gcov_info folder
pettershao-ragilenetworks Jun 4, 2021
7fce788
check if gcov_info folder downloaded
pettershao-ragilenetworks Jun 4, 2021
0dd818b
check folder
pettershao-ragilenetworks Jun 4, 2021
5e0a3cf
check gcov_info artifacts
pettershao-ragilenetworks Jun 4, 2021
1afddb7
update AllMergeReport folder
pettershao-ragilenetworks Jun 4, 2021
ad81f2d
add source code
pettershao-ragilenetworks Jun 4, 2021
a529559
update scripts
pettershao-ragilenetworks Jun 4, 2021
90dbed2
change to ./s folder
pettershao-ragilenetworks Jun 4, 2021
07343cb
push ./s/ first to tar -zcvf
pettershao-ragilenetworks Jun 4, 2021
a43cc97
fix spell error
pettershao-ragilenetworks Jun 4, 2021
67a2ba0
change source code to a common dir for different container
pettershao-ragilenetworks Jun 4, 2021
289d962
tar source to subfolder gcov
pettershao-ragilenetworks Jun 5, 2021
a4f1815
fix conflict
pettershao-ragilenetworks Jun 5, 2021
d3547cd
convert to xml
pettershao-ragilenetworks Jun 7, 2021
01c246d
cp lcov_cobertura to local folder
pettershao-ragilenetworks Jun 7, 2021
548fdd5
update gcov_support.sh
pettershao-ragilenetworks Jun 7, 2021
61903dd
publish internal container
pettershao-ragilenetworks Jun 7, 2021
c7c4209
lcov extract
pettershao-ragilenetworks Jun 7, 2021
9677675
install dotnet in debian
pettershao-ragilenetworks Jun 7, 2021
d94dc22
adjust code path for publish
pettershao-ragilenetworks Jun 7, 2021
bc4e415
update code path
pettershao-ragilenetworks Jun 7, 2021
4e28e19
update code patch
pettershao-ragilenetworks Jun 7, 2021
0c6224d
sed coverage.xml for source code
pettershao-ragilenetworks Jun 7, 2021
cb9a082
test all
pettershao-ragilenetworks Jun 7, 2021
29c643d
check low coverage rate
pettershao-ragilenetworks Jun 8, 2021
7e26737
check low rate
pettershao-ragilenetworks Jun 8, 2021
549a0df
check low rate
pettershao-ragilenetworks Jun 8, 2021
a851188
optimize for big size
pettershao-ragilenetworks Jun 8, 2021
2096b14
test all
pettershao-ragilenetworks Jun 8, 2021
8b38232
fix timeout
pettershao-ragilenetworks Jun 8, 2021
6b13bb1
check low rate
pettershao-ragilenetworks Jun 9, 2021
b162721
check low rate
pettershao-ragilenetworks Jun 9, 2021
efc9512
publish container info
pettershao-ragilenetworks Jun 9, 2021
c3c1786
fix error
pettershao-ragilenetworks Jun 9, 2021
fffde5b
test all
pettershao-ragilenetworks Jun 9, 2021
2ab0297
add MACRO and preload code
pettershao-ragilenetworks Jun 18, 2021
ad84dd8
fix conflict
pettershao-ragilenetworks Jun 18, 2021
2296c82
fix conflict
pettershao-ragilenetworks Jun 18, 2021
751b457
Merge branch 'master' into gcov_for_swss_daemon
pettershao-ragilenetworks Jun 18, 2021
c86d16e
fix error
pettershao-ragilenetworks Jun 18, 2021
a2bd4a7
fix error
pettershao-ragilenetworks Jun 18, 2021
a60c02a
fix error
pettershao-ragilenetworks Jun 18, 2021
225caf1
fix error
pettershao-ragilenetworks Jun 18, 2021
165066a
add Makefile
pettershao-ragilenetworks Jun 18, 2021
4bd191d
fix error
pettershao-ragilenetworks Jun 18, 2021
3bf64a0
fix error
pettershao-ragilenetworks Jun 18, 2021
2baf49b
fix error
pettershao-ragilenetworks Jun 18, 2021
75532f1
fix fileExists
pettershao-ragilenetworks Jun 18, 2021
b300392
install preload.so
pettershao-ragilenetworks Jun 19, 2021
9aebbdd
install libgcopreload.so
pettershao-ragilenetworks Jun 19, 2021
3238444
Update Makefile
pettershao-ragilenetworks Jun 19, 2021
c9eb9bd
Create lcov_cobertura.py
pettershao-ragilenetworks Jun 19, 2021
c321351
revert bach sai download
pettershao-ragilenetworks Jun 21, 2021
ef11208
update Makefile
pettershao-ragilenetworks Jun 21, 2021
32bf0ac
test all
pettershao-ragilenetworks Jun 21, 2021
886eecf
Compiling process optimization
pettershao-ragilenetworks Jun 21, 2021
964afc0
Update azure-pipelines.yml
pettershao-ragilenetworks Jun 21, 2021
0dc108e
gcovpreload.c -> gcovpreload.cpp
pettershao-ragilenetworks Jun 21, 2021
cd14c5e
revert bach test cases
pettershao-ragilenetworks Jun 22, 2021
01ff966
revert bach test cases version1
pettershao-ragilenetworks Jun 22, 2021
ac48807
fix path
pettershao-ragilenetworks Jun 25, 2021
bc1b23c
fix LGTM alerts
pettershao-ragilenetworks Jul 8, 2021
a89bc59
syncd DVS test modification to check speed
pettershao-ragilenetworks Jul 17, 2021
d42d23a
reload vs container
pettershao-ragilenetworks Jul 21, 2021
0d1af2d
fix test error
pettershao-ragilenetworks Aug 1, 2021
1ceb8e8
Merge branch 'master' into gcov_for_swss_daemon
pettershao-ragilenetworks Aug 2, 2021
73f92dc
Update conftest.py
pettershao-ragilenetworks Aug 8, 2021
9b2dd7f
Merge branch 'master' into gcov_for_swss_daemon
pettershao-ragilenetworks Aug 8, 2021
ed3956f
Update conftest.py
pettershao-ragilenetworks Aug 10, 2021
6ca2c2e
Update test-docker-sonic-vs-template.yml
pettershao-ragilenetworks Aug 10, 2021
c68fc15
try to remove unused gcno for speed up
pettershao-ragilenetworks Sep 6, 2021
cf05e3a
Merge branch 'master' into gcov_for_swss_daemon
pettershao-ragilenetworks Sep 6, 2021
ce60f63
remove duplicate files
pettershao-ragilenetworks Sep 7, 2021
23a2abd
fix file can't find
pettershao-ragilenetworks Sep 8, 2021
8427585
sync conftest.py
pettershao-ragilenetworks Sep 8, 2021
8a396b7
Update conftest.py
pettershao-ragilenetworks Sep 14, 2021
a4d9459
Update conftest.py
pettershao-ragilenetworks Sep 22, 2021
2993055
Update conftest.py
pettershao-ragilenetworks Sep 22, 2021
7a3978d
Merge branch 'master' into gcov_for_swss_daemon
pettershao-ragilenetworks Sep 29, 2021
f801a4a
Update conftest.py
pettershao-ragilenetworks Sep 30, 2021
cb541dc
trigger build
pettershao-ragilenetworks Oct 18, 2021
5002831
Merge remote-tracking branch 'upstream1/master' into gcov_for_swss_da…
prsunny Nov 3, 2021
276840a
Fix gearsyncd
prsunny Nov 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .azure-pipelines/build-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ parameters:
type: boolean
default: false

- name: archive_gcov
type: boolean
default: false

jobs:
- job:
displayName: ${{ parameters.arch }}
Expand Down Expand Up @@ -120,6 +124,9 @@ jobs:
set -x
tar czf pytest.tgz tests
cp -r pytest.tgz $(Build.ArtifactStagingDirectory)/
if [ '${{ parameters.archive_gcov }}' == True ]; then
export ENABLE_GCOV=y
fi
./autogen.sh
dpkg-buildpackage -us -uc -b -j$(nproc) && cp ../*.deb .
displayName: "Compile sonic swss"
Expand Down
4 changes: 4 additions & 0 deletions .azure-pipelines/docker-sonic-vs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ RUN dpkg -i /debs/syncd-vs_1.0.0_amd64.deb

RUN dpkg --purge swss
RUN dpkg -i /debs/swss_1.0.0_amd64.deb

RUN apt-get update

RUN apt-get -y install lcov
114 changes: 114 additions & 0 deletions .azure-pipelines/gcov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
parameters:
- name: arch
type: string
values:
- amd64
default: amd64

- name: pool
type: string
values:
- sonicbld
- default
default: default

- name: timeout
type: number
default: 180

- name: sonic_slave
type: string

- name: sairedis_artifact_name
type: string

- name: swss_common_artifact_name
type: string

- name: swss_artifact_name
type: string

- name: artifact_name
type: string

- name: archive_gcov
type: boolean
default: false

jobs:
- job:
displayName: ${{ parameters.arch }}
timeoutInMinutes: ${{ parameters.timeout }}

pool:
${{ if ne(parameters.pool, 'default') }}:
name: ${{ parameters.pool }}
${{ if eq(parameters.pool, 'default') }}:
vmImage: 'ubuntu-20.04'

container:
image: sonicdev-microsoft.azurecr.io:443/${{ parameters.sonic_slave }}:latest


steps:
- script: |
sudo apt-get install -y lcov
displayName: "Install dependencies"
condition: eq('${{ parameters.archive_gcov }}', true)
- task: DownloadPipelineArtifact@2
inputs:
artifact: ${{ parameters.artifact_name }}
displayName: "Download gcov artifact"
condition: eq('${{ parameters.archive_gcov }}', true)
- script: |
set -x
ls -lh
sudo tar -zxvf sonic-gcov.tar.gz
sudo cp -rf sonic-gcov $(Build.ArtifactStagingDirectory)
sudo rm sonic-gcov.tar.gz
ls -lh
workingDirectory: $(Pipeline.Workspace)
displayName: "store sonic-gcov"
condition: eq('${{ parameters.archive_gcov }}', true)
- checkout: self
submodules: true
condition: eq('${{ parameters.archive_gcov }}', true)
- script: |
set -x
wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y dotnet-sdk-5.0
pushd ./s/
sudo tar -zcvf swss.tar.gz ./*
ls -lh ./*
cp ./gcovpreload/lcov_cobertura.py $(Build.ArtifactStagingDirectory)/
cp ./tests/gcov_support.sh $(Build.ArtifactStagingDirectory)/sonic-gcov
sudo cp -rf swss.tar.gz $(Build.ArtifactStagingDirectory)/sonic-gcov
popd
sudo cp -rf $(Build.ArtifactStagingDirectory)/sonic-gcov ./
pushd sonic-gcov
ls -lh ./*
sudo chmod +x ./gcov_support.sh
sudo ./gcov_support.sh generate
sudo ./gcov_support.sh merge_container_info $(Build.ArtifactStagingDirectory)
sudo cp -rf gcov_output $(Build.ArtifactStagingDirectory)
ls -lh $(Build.ArtifactStagingDirectory)
popd
workingDirectory: $(Pipeline.Workspace)
displayName: "generate gcov reports"
condition: eq('${{ parameters.archive_gcov }}', true)

- publish: $(Build.ArtifactStagingDirectory)/gcov_output
artifact: gcov_info
displayName: "Archive gcov info"
condition: eq('${{ parameters.archive_gcov }}', true)

- task: PublishCodeCoverageResults@1
Copy link
Copy Markdown
Collaborator

@xumia xumia Sep 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the task PublishCodeCoverageResults supports to publish multiple coverage files in single task, @pettershao-ragilenetworks, have you tried to merged the coverage files by the task itself? I am not sure it works or not.
See https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-code-coverage-results?view=azure-devops
See summaryFileLocation and additionalCodeCoverageFiles, both of the arguments support file pattern.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we only publish total.info(which later be convert into coverage.xml)one time.
the reason why we merge the info in gcov_support.sh is that pipeline could't recognize the info files and will merge fail.

inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.ArtifactStagingDirectory)/gcov_output/AllMergeReport/coverage.xml'
reportDirectory: '$(Build.ArtifactStagingDirectory)/gcov_output/AllMergeReport/'
displayName: 'Publish c c++ test coverage'
condition: eq('${{ parameters.archive_gcov }}', true)

29 changes: 28 additions & 1 deletion .azure-pipelines/test-docker-sonic-vs-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ parameters:
- name: log_artifact_name
type: string

- name: gcov_artifact_name
type: string

- name: sonic_slave
type: string

- name: archive_gcov
type: boolean
default: false

jobs:
- job:
displayName: vstest
Expand Down Expand Up @@ -53,7 +63,12 @@ jobs:
sudo /sbin/ip link add Vrf1 type vrf table 1001 || { echo 'vrf command failed' ; exit 1; }
sudo /sbin/ip link del Vrf1 type vrf table 1001
pushd tests
sudo py.test -v --force-flaky --junitxml=tr.xml --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber)

if [ '${{ parameters.archive_gcov }}' == True ]; then
sudo py.test -v --force-flaky --junitxml=tr.xml --keeptb --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber)
else
sudo py.test -v --force-flaky --junitxml=tr.xml --imgname=docker-sonic-vs:$(Build.DefinitionName).$(Build.BuildNumber)
fi
displayName: "Run vs tests"

- task: PublishTestResults@2
Expand All @@ -64,9 +79,21 @@ jobs:

- script: |
cp -r tests/log $(Build.ArtifactStagingDirectory)/

if [ '${{ parameters.archive_gcov }}' == True ]; then
sudo apt-get install -y lcov
./tests/gcov_support.sh set_environment $(Build.ArtifactStagingDirectory)
docker stop $(docker ps -q -a)
docker rm $(docker ps -q -a)
fi
displayName: "Collect logs"
condition: always()

- publish: $(Build.ArtifactStagingDirectory)/gcov_tmp
artifact: ${{ parameters.gcov_artifact_name }}
displayName: "Publish gcov output"
condition: eq('${{ parameters.archive_gcov }}', true)

- publish: $(Build.ArtifactStagingDirectory)/
artifact: ${{ parameters.log_artifact_name }}@$(System.JobAttempt)
displayName: "Publish logs"
Expand Down
7 changes: 6 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
SUBDIRS = fpmsyncd neighsyncd fdbsyncd portsyncd mclagsyncd natsyncd orchagent swssconfig cfgmgr tests gearsyncd
if GCOV_ENABLED
SUBDIRS = gcovpreload fpmsyncd neighsyncd portsyncd mclagsyncd natsyncd fdbsyncd orchagent swssconfig cfgmgr tests gearsyncd
else
SUBDIRS = fpmsyncd neighsyncd portsyncd mclagsyncd natsyncd fdbsyncd orchagent swssconfig cfgmgr tests gearsyncd
endif


if HAVE_LIBTEAM
SUBDIRS += teamsyncd tlm_teamd
Expand Down
20 changes: 20 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ stages:
sairedis_artifact_name: sonic-sairedis
artifact_name: sonic-swss
archive_pytests: true
archive_gcov: true

- stage: BuildArm
dependsOn: Build
Expand All @@ -38,6 +39,7 @@ stages:
swss_common_artifact_name: sonic-swss-common.armhf
sairedis_artifact_name: sonic-sairedis.armhf
artifact_name: sonic-swss.armhf
archive_gcov: false

- template: .azure-pipelines/build-template.yml
parameters:
Expand All @@ -50,6 +52,7 @@ stages:
buildimage_pipeline: 140
sairedis_artifact_name: sonic-sairedis.arm64
artifact_name: sonic-swss.arm64
archive_gcov: false

- stage: BuildDocker
dependsOn: Build
Expand All @@ -69,3 +72,20 @@ stages:
- template: .azure-pipelines/test-docker-sonic-vs-template.yml
parameters:
log_artifact_name: log
gcov_artifact_name: sonic-gcov
sonic_slave: sonic-slave-buster
archive_gcov: true

- stage: Gcov
dependsOn: Test
condition: always()
jobs:
- template: .azure-pipelines/gcov.yml
parameters:
arch: amd64
sonic_slave: sonic-slave-buster
swss_common_artifact_name: sonic-swss-common
sairedis_artifact_name: sonic-sairedis
swss_artifact_name: sonic-swss
artifact_name: sonic-gcov
archive_gcov: true
17 changes: 17 additions & 0 deletions cfgmgr/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,20 @@ macsecmgrd_SOURCES = macsecmgrd.cpp macsecmgr.cpp $(top_srcdir)/orchagent/orch.c
macsecmgrd_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_SAI)
macsecmgrd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_SAI)
macsecmgrd_LDADD = $(COMMON_LIBS) $(SAIMETA_LIBS)

if GCOV_ENABLED
vlanmgrd_LDADD += -lgcovpreload
teammgrd_LDADD += -lgcovpreload
portmgrd_LDADD += -lgcovpreload
intfmgrd_LDADD+= -lgcovpreload
buffermgrd_LDADD += -lgcovpreload
vrfmgrd_LDADD += -lgcovpreload
nbrmgrd_LDADD += -lgcovpreload
vxlanmgrd_LDADD += -lgcovpreload
sflowmgrd_LDADD += -lgcovpreload
natmgrd_LDADD += -lgcovpreload
coppmgrd_LDADD += -lgcovpreload
tunnelmgrd_LDADD += -lgcovpreload
macsecmgrd_LDADD += -lgcovpreload
endif

19 changes: 19 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,25 @@ CFLAGS_COMMON+=" -Wno-switch-default"
CFLAGS_COMMON+=" -Wno-long-long"
CFLAGS_COMMON+=" -Wno-redundant-decls"

# Code testing coverage with gcov
AC_MSG_CHECKING(whether to build with gcov testing)
AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov], [Whether to enable gcov testing]),, enable_gcov=no)

if test "x$enable_gcov" = "xyes"; then
if test "$GCC" = "no"; then
AC_MSG_ERROR(not compiling with gcc, which is required for gcov testing)
fi

CFLAGS_COMMON+=" -fprofile-arcs -ftest-coverage"
AC_SUBST(CFLAGS_COMMON)

LDFLAGS+=" -fprofile-arcs -lgcov"
AC_SUBST(LDFLAGS)
fi

AM_CONDITIONAL(GCOV_ENABLED, test x$enable_gcov = xyes)
AC_MSG_RESULT($enable_gcov)

AC_SUBST(CFLAGS_COMMON)

AC_CONFIG_FILES([
Expand Down
10 changes: 10 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,18 @@ include /usr/share/dpkg/default.mk
# dh_auto_configure -- \
# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

ifeq ($(ENABLE_GCOV), y)
override_dh_auto_configure:
dh_auto_configure -- --enable-gcov
endif

override_dh_auto_install:
dh_auto_install --destdir=debian/swss
ifeq ($(ENABLE_GCOV), y)
mkdir -p debian/swss/tmp/gcov
sh ./tests/gcov_support.sh collect swss
endif

override_dh_strip:
dh_strip --dbg-package=swss-dbg

3 changes: 3 additions & 0 deletions fdbsyncd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ fdbsyncd_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(COV_CFLAGS)
fdbsyncd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(COV_CFLAGS)
fdbsyncd_LDADD = -lnl-3 -lnl-route-3 -lswsscommon $(COV_LDFLAGS)

if GCOV_ENABLED
fdbsyncd_LDADD += -lgcovpreload
endif
4 changes: 4 additions & 0 deletions fpmsyncd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ fpmsyncd_SOURCES = fpmsyncd.cpp fpmlink.cpp routesync.cpp $(top_srcdir)/warmrest
fpmsyncd_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON)
fpmsyncd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON)
fpmsyncd_LDADD = -lnl-3 -lnl-route-3 -lswsscommon

if GCOV_ENABLED
fpmsyncd_LDADD += -lgcovpreload
endif
Loading