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

tests: support coverage report for unit tests #2442

Closed
ajones-rvbd opened this issue Jun 14, 2018 · 5 comments
Closed

tests: support coverage report for unit tests #2442

ajones-rvbd opened this issue Jun 14, 2018 · 5 comments
Assignees

Comments

@ajones-rvbd
Copy link
Contributor

A sample make check coverage report is here: https://codecov.io/gh/ajones-rvbd/frr

It requires gcov and a new make target, let's add that to the repo...

@ajones-rvbd
Copy link
Contributor Author

@mwinter-osr

@ajones-rvbd
Copy link
Contributor Author

I should have a PR ready for this today, still testing...

ajones-rvbd added a commit to ajones-rvbd/frr that referenced this issue Jun 14, 2018
Currently, make check runs the unit tests and reports pass/fail,
but we have no way to guage how much of the code is covered by
these tests.  gcov provides those statistics on a per source
file basis, but requires special CFLAGS and LDFLAGS.  Here, we
add the --enable-gcov configure option to setup those options
correctly.  We also add a make target called check-coverage,
which runs the unit tests, runs gcov and uploads the data to
the codecov.io cloud service for display.

Finally, we include a Dockerfile.gcov which creates a container
image in alpine linux to run the tests.  To create the image:

$ docker build \
	--build-arg commit=`git rev-parse HEAD` \
	--build-arg token=<upload token from codecov.io> \
	-t frr-gcov:latest \
	-f docker/alpine/Dockerfile.gcov .

and to create and upload the report:

$ docker run -it --rm frr-gcov:latest

Testing done: Created and uploaded a report from my fork using alpine linux 3.7
Issue: FRRouting#2442
Signed-off-by: Arthur Jones <arthur.jones@riverbed.com>
@ajones-rvbd
Copy link
Contributor Author

With the PR referenced here, it should be easy for me to setup a nightly (or so) coverage report on my local Bamboo instance which I can push out to here: https://codecov.io/gh/ajones-rvbd/frr/. The details for how I would be running that are in the commit messages. I think that PR is ready to go in...

ajones-rvbd added a commit to ajones-rvbd/frr that referenced this issue Jun 15, 2018
Currently, make check runs the unit tests and reports pass/fail,
but we have no way to guage how much of the code is covered by
these tests.  gcov provides those statistics on a per source
file basis, but requires special CFLAGS and LDFLAGS.  Here, we
add the --enable-gcov configure option to setup those options
correctly.  We also add a make target called check-coverage,
which runs the unit tests, runs gcov and uploads the data to
the codecov.io cloud service for display.

Finally, we include a Dockerfile.gcov which creates a container
image in alpine linux to run the tests.  To create the image:

$ docker build \
	--build-arg commit=`git rev-parse HEAD` \
	--build-arg token=<upload token from codecov.io> \
	-t frr-gcov:latest \
	-f docker/alpine/Dockerfile.gcov .

and to create and upload the report:

$ docker run -it --rm frr-gcov:latest

Testing done: Created and uploaded a report from my fork using alpine linux 3.7
Issue: FRRouting#2442
Signed-off-by: Arthur Jones <arthur.jones@riverbed.com>
@ajones-rvbd
Copy link
Contributor Author

Ugh, looks like I forgot to open the PR... Re-based the commit and added a PR for this...

ajones-rvbd added a commit to ajones-rvbd/frr that referenced this issue Jun 16, 2018
Currently, make check runs the unit tests and reports pass/fail,
but we have no way to guage how much of the code is covered by
these tests.  gcov provides those statistics on a per source
file basis, but requires special CFLAGS and LDFLAGS.  Here, we
add the --enable-gcov configure option to setup those options
correctly.  We also add a make target called check-coverage,
which runs the unit tests, runs gcov and uploads the data to
the codecov.io cloud service for display.

Finally, we include a Dockerfile-coverage which creates a
container image in alpine linux to run the tests.  To create
the image:

$ docker build \
	--build-arg commit=`git rev-parse HEAD` \
	--build-arg token=<upload token from codecov.io> \
	-t frr-gcov:latest \
	-f docker/alpine/Dockerfile-coverage .

and to create and upload the report:

$ docker run -it --rm frr-gcov:latest

Testing done:

Created and uploaded a report from my fork using alpine linux 3.7.
Non-coverage alpine 3.7 build still works.

Issue: FRRouting#2442
Signed-off-by: Arthur Jones <arthur.jones@riverbed.com>
ajones-rvbd added a commit to ajones-rvbd/frr that referenced this issue Jul 4, 2018
Currently, make check runs the unit tests and reports pass/fail,
but we have no way to guage how much of the code is covered by
these tests.  gcov provides those statistics on a per source
file basis, but requires special CFLAGS and LDFLAGS.  Here, we
add the --enable-gcov configure option to setup those options
correctly.  We also add a make target called check-coverage,
which runs the unit tests, runs gcov and uploads the data to
the codecov.io cloud service for display.

Finally, we include a Dockerfile-coverage which creates a
container image in alpine linux to run the tests.  To create
the image:

$ docker build \
	--build-arg commit=`git rev-parse HEAD` \
	--build-arg token=<upload token from codecov.io> \
	-t frr-gcov:latest \
	-f docker/alpine/Dockerfile-coverage .

and to create and upload the report:

$ docker run -it --rm frr-gcov:latest

Testing done:

Created and uploaded a report from my fork using alpine linux 3.7.
Non-coverage alpine 3.7 build still works.

Issue: FRRouting#2442
Signed-off-by: Arthur Jones <arthur.jones@riverbed.com>
@ajones-rvbd
Copy link
Contributor Author

Fixed pushed...

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

No branches or pull requests

3 participants