Skip to content

config: runtime: tests: ltp: enable support for code coverage #2871

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

Merged
merged 2 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions config/runtime/tests/ltp.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
timeout:
minutes: {{ job_timeout|default(15) }}
definitions:
{% if "coverage" in node.data.config_full %}
{% include "util/gcov-reset.jinja2" %}
{% endif %}
- repository: https://github.com/kernelci/test-definitions
from: git
revision: kernelci.org
Expand All @@ -12,3 +15,6 @@
TST_CMDFILES: "{{ tst_cmdfiles|default('') }}"
SKIP_INSTALL: "{{ skip_install }}"
SKIPFILE: {{ skipfile }}
{% if "coverage" in node.data.config_full %}
{% include "util/gcov-upload.jinja2" %}
{% endif %}
12 changes: 12 additions & 0 deletions config/runtime/util/gcov-reset.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- from: inline
repository:
metadata:
format: Lava-Test Test Definition 1.0
name: reset-gcov
description: Reset GCOV data
run:
steps:
- GCOV_RESET="/sys/kernel/debug/gcov/reset"
- if [ -f ${GCOV_RESET} ]; then echo 1 > ${GCOV_RESET}; fi
name: reset-gcov
path: inline/reset-gcov.yaml
39 changes: 39 additions & 0 deletions config/runtime/util/gcov-upload.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
- from: inline
name: upload
path: inline/upload.yaml
repository:
metadata:
description: GCOV artifacts upload
format: Lava-Test Test Definition 1.0
name: upload
environment:
- lava-test-shell
os:
- debian
run:
steps:
- GCDA=/sys/kernel/debug/gcov
# Bail out if $GCDA doesn't exist (as GCOV is likely not enabled)
- test -d ${GCDA} || exit 0
- TEMPDIR=$(mktemp -d)
- UPLOAD_PATH="{{ node.name }}-{{ node.id }}"
- UPLOAD_NAME="gcov.tar.xz"
# Retrieve GCOV artifacts
# Taken from https://www.kernel.org/doc/html/v6.12/dev-tools/gcov.html#appendix-b-gather-on-test-sh
- find $GCDA -type d -exec mkdir -p $TEMPDIR/\{\} \;
- find $GCDA -name '*.gcda' -exec sh -c 'cat < $0 > '$TEMPDIR'/$0' {} \;
- find $GCDA -name '*.gcno' -exec sh -c 'cp -d $0 '$TEMPDIR'/$0' {} \;
- tar cJf ${UPLOAD_NAME} -C $TEMPDIR sys
- rm -rf $TEMPDIR
# Use set +x so we can don't echo secret tokens in the logs
- set +x
- . /lava-${LAVA_JOB_ID}/secrets
- >-
lava-test-case "artifact-upload:coverage_data:{{ storage_config.base_url }}/${UPLOAD_PATH}/${UPLOAD_NAME}"
--shell curl -X POST {{ storage_config.base_url }}/upload
-H "Authorization: Bearer ${UPLOAD_TOKEN}"
-F "file0=@${UPLOAD_NAME}"
-F "path=${UPLOAD_PATH}"

secrets:
UPLOAD_TOKEN: {{ storage_config.name }}-token