Skip to content
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

[gcov-vs]support vs coverate rate #972

Open
wants to merge 45 commits into
base: master
Choose a base branch
from

Conversation

pettershao-ragilenetworks

Signed-off-by: pettershao-ragilenetworks [email protected]

@pettershao-ragilenetworks pettershao-ragilenetworks marked this pull request as draft November 22, 2021 08:40
@pettershao-ragilenetworks pettershao-ragilenetworks marked this pull request as ready for review November 22, 2021 08:45
@pettershao-ragilenetworks pettershao-ragilenetworks marked this pull request as draft November 22, 2021 08:53
@@ -122,4 +122,8 @@ tests_SOURCES = tests.cpp
tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON)
tests_LDADD = -lhiredis -lswsscommon -lpthread libsaivs.la -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq

if GCOV_ENABLED
tests_LDADD += -lgcovpreload
Copy link
Collaborator

Choose a reason for hiding this comment

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

tests probably should not have gcov enabled on them ?

Choose a reason for hiding this comment

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

yea, will optimize them soon.

@pettershao-ragilenetworks
Copy link
Author

@kcudnik https://dev.azure.com/mssonic/build/_build/results?buildId=54671&view=codecoverage-tab the result seems fine, 80%, please check if we need to remove some folders, thanks!

@pettershao-ragilenetworks pettershao-ragilenetworks marked this pull request as ready for review November 29, 2021 01:55
@kcudnik
Copy link
Collaborator

kcudnik commented Nov 29, 2021

@kcudnik https://dev.azure.com/mssonic/build/_build/results?buildId=54671&view=codecoverage-tab the result seems fine, 80%, please check if we need to remove some folders, thanks!

wow, this looks impressive, and we are over the 80% target ! this is great !
4 main directories that we want to cover are

  • lib
  • meta
  • syncd
  • vslib

and i see that this is already covered, and i see that you also covered tests/ and unittests/ which are also fine ! and there are alscovered saiasiccmp/ and saiplayer/ which is also good

thank you @pettershao-ragilenetworks, this is really great work, and we can use this method to report coverage over local unittests which cover currently 60%, and using this will meet MS requirement and we will be done for a while :D

@pettershao-ragilenetworks
Copy link
Author

pettershao-ragilenetworks commented Nov 30, 2021

@kcudnik it already include unittest coverage rate, I have merged unittest coverage rate and vs docker coverage together(by generate .info for unittest and .info for vs docker, and merge them together), you can see that 'test' and 'unittest' folders are come from unittest(i just fix the path prefix for merging and showing), and other folders are come from vs docker.

@pettershao-ragilenetworks
Copy link
Author

@kcudnik help forward this, thanks!

@kcudnik
Copy link
Collaborator

kcudnik commented Jan 10, 2022

what do you need from me here?

@pettershao-ragilenetworks
Copy link
Author

what do you need from me here?

I think we can merge this, right? happy new year!

@pettershao-ragilenetworks
Copy link
Author

@lguohan @qiluo-msft hi, help merge this, thanks!

@kcudnik
Copy link
Collaborator

kcudnik commented Jan 24, 2022

lgtm is failing and 2 pipelines for arm64 and armhf are stuck, not sure if they are required

@pettershao-ragilenetworks
Copy link
Author

@theasianpianist @prsunny can you help check why vstest fail so much?

@talber-nvidia
Copy link

Hi, we were wondering- when is this PR expected to be merged?

@liat-grozovik
Copy link
Collaborator

@pettershao-ragilenetworks would you please help to handle conflicts and retrigger checkers?

@pettershao-ragilenetworks
Copy link
Author

OK. will handle soon.

@pettershao-ragilenetworks
Copy link
Author

lgtm exit abnormal, any one please help check this:
[2022-05-18 09:52:02] [ERROR] Spawned process exited abnormally (code 1; tried to run: [/opt/dist/tools/linux64/preload_tracer, /opt/dist/cpp/tools/do-build])
[2022-05-18 09:52:02] [build-stdout] Semmle autobuild: no supported build system detected.

@pettershao-ragilenetworks
Copy link
Author

@kcudnik @lguohan help check why lgtm failed, i don't think it is caused by my submission, thanks!

@kcudnik
Copy link
Collaborator

kcudnik commented May 23, 2022

[2022-05-18 09:52:02] [build-stdout] sudo cp libgcovpreload.so /usr/lib
[2022-05-18 09:52:02] [build-stderr] sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper

seems like sudo don't work on LGTM, and it requires password, probably is not supported, at all, so that copy should not be used there

@pettershao-ragilenetworks
Copy link
Author

libgcovpreload

any idea to fix this? It seems fine last time, can we just skip lgtm since we have not change any code.
cat gcovpreload/Makefile

DYLIB_MAKE_CMD=$(CC) -shared -fpic gcovpreload.c -o ${DYLIBNAME}

all:
        $(DYLIB_MAKE_CMD)
        sudo cp $(DYLIBNAME) /usr/lib     -> hear
        sudo chmod 777 -R /usr/lib/$(DYLIBNAME)   -> hear
        sudo cp lcov_cobertura.py ../    -> hear

@kcudnik
Copy link
Collaborator

kcudnik commented May 25, 2022

if we skip this time, error will still persist on changes where code is changed, so it make sense to fix it here and not in next PR

@pettershao-ragilenetworks
Copy link
Author

yea, i understand, but if not skip this, then seems no other solution:

  1. all other components' make depend this so, so the so's make is like make install, this need 'sudo'
  2. if we make and install this so alone, then we should create a folder for gcovpreload.so's building, that means we need to modify build-image, seems complex.
  3. seems no changes will make for this Makefile after this PR
    help check.

@kcudnik
Copy link
Collaborator

kcudnik commented May 26, 2022

hmm, seems like there is no good way for LGTM ice sudo will not work, besides maybe to skip installing that so just for LGTM build, since that only check code quality and not running anything else.
maybe it's worth to make a small Makefile just for LGTM to check whether make install will work or explicit sudo, but i suspect this will not work :(
other workaround, maybe would be to specify explicit lib folder for install so libraries and use that so folder in ld_preload, just for LGTM

hmm, that sudo should work in LGTM, since it's in container, not sure why it started to require password :/

@kcudnik
Copy link
Collaborator

kcudnik commented May 26, 2022

if you look here:
https://github.com/Azure/sonic-sairedis/blob/master/lgtm.yml#L25
or https://github.com/Azure/sonic-sairedis/blob/master/lgtm.yml#L30
this points that everything is installed in LGTM_WORKSPACE directory, and not using system directories, and that resolves to /opt/work/lgtm-workspace, so that "sudo" maybe should use "make install" command which would automatically put required library in the prefix directory, currently for sairedis that prefix is set to /usr, but sairedis is not installed, just configure

you would need to modify gcovpreload/Makefile, "all" to use prefix, and change change prefix from /usr in lgtm.yml, to something that includes LGTM_WORKSPACE, since you have hardcoded

for example if you look at generated Makefile:

exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
libdir = ${exec_prefix}/lib

and prefix is obtained from --prefix in ./configure, you could also use that, ps why you create your own Makefile and mock all targets, instead using Makefile generated by ./configure which would take care of everything for you? you just need to create very simple Makefile.am that will have one source file for preload lib and that's it ?

@pettershao-ragilenetworks
Copy link
Author

OK, I will raise a PR to create gcovpreloader repo soon and add build dependance for sairedis(swss will also depend it), after the pr raised, I will summarize reasons and send a mail for forwarding this.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 3, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

Signed-off-by: pettershao-ragilenetworks <[email protected]>
Signed-off-by: pettershao-ragilenetworks <[email protected]>
Signed-off-by: pettershao-ragilenetworks <[email protected]>
@pettershao-ragilenetworks
Copy link
Author

Should this PR be merged? @kcudnik @liat-grozovik

@Wick324
Copy link

Wick324 commented Nov 18, 2022

/easycla

2 similar comments
@pettershao-ragilenetworks
Copy link
Author

/easycla

@pettershao-ragilenetworks
Copy link
Author

/easycla

Add Makefile.am to make gcov_preload
fix err : "gcov_unittest_artifact_name" must be provided
fix err cannot find library libgcovpreload.so.0 needed by xxx
add pipline to get Makefile
fix  err of whitespace check
del publish Makefile
increase the timeout of vs test
@pettershao-ragilenetworks pettershao-ragilenetworks deleted the support_vs_coverage_rate branch December 1, 2022 05:40
@pettershao-ragilenetworks pettershao-ragilenetworks restored the support_vs_coverage_rate branch December 1, 2022 05:41
@pettershao-ragilenetworks
Copy link
Author

pettershao-ragilenetworks commented Dec 1, 2022

if you look here: https://github.com/Azure/sonic-sairedis/blob/master/lgtm.yml#L25 or https://github.com/Azure/sonic-sairedis/blob/master/lgtm.yml#L30 this points that everything is installed in LGTM_WORKSPACE directory, and not using system directories, and that resolves to /opt/work/lgtm-workspace, so that "sudo" maybe should use "make install" command which would automatically put required library in the prefix directory, currently for sairedis that prefix is set to /usr, but sairedis is not installed, just configure

you would need to modify gcovpreload/Makefile, "all" to use prefix, and change change prefix from /usr in lgtm.yml, to something that includes LGTM_WORKSPACE, since you have hardcoded

for example if you look at generated Makefile:

exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
libdir = ${exec_prefix}/lib

and prefix is obtained from --prefix in ./configure, you could also use that, ps why you create your own Makefile and mock all targets, instead using Makefile generated by ./configure which would take care of everything for you? you just need to create very simple Makefile.am that will have one source file for preload lib and that's it ?

I have create a Makefile.am to replace the Makefile , it works fine and passed the lgtm check.
Here is the result: https://dev.azure.com/mssonic/build/_build/results?buildId=182795&view=codecoverage-tab
Please kindly review the changes and then we could merge if there is no problems.

triger rebuild
change timeout of running vstest to default
update gcov_preload.c
@lgtm-com
Copy link

lgtm-com bot commented Dec 7, 2022

This pull request introduces 1 alert when merging 9199a36 into 4e24c77 - view on LGTM.com

new alerts:

  • 1 for Function declared in block

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine ⚙️ that powers LGTM.com. For more information, please check out our post on the GitHub blog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants