Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
tools: add coverage support to test scripts
Browse files Browse the repository at this point in the history
This patch adds coverage option in both `check_framework.py`
and `check_module_utest.py` scripts. This update allows
enabling code coverage reporting via the `--coverage` flag.

Signed-off-by: Leandro Belli <[email protected]>
Change-Id: I98bee9053b6664689f1e31de6ae204c39358e0bc
  • Loading branch information
leandro-arm committed Mar 20, 2024
1 parent 9b7d6f0 commit a0e2eeb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
25 changes: 20 additions & 5 deletions tools/check_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@
frameworks tests.
"""

import argparse
import sys
import subprocess
from utils import banner


def run():
def run(coverage=False):
print(banner('Build and run framework tests'))

extra_args = f'ENABLE_COVERAGE={"y" if coverage else "n"}'
result = subprocess.Popen(
'CC=gcc make -f Makefile.cmake fwk_test',
f'CC=gcc make -f Makefile.cmake fwk_test {extra_args}',
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
Expand All @@ -38,9 +40,22 @@ def run():
return True


def main():
return 0 if run() else 1
def parse_args(argv, prog_name):
parser = argparse.ArgumentParser(
prog=prog_name,
description='Build and run framework tests')

parser.add_argument('-c', '--coverage', dest='coverage',
required=False, default=False, action='store_true',
help='Enable code coverage reporting.')

return parser.parse_args(argv)


def main(argv=[], prog_name=''):
args = parse_args(argv, prog_name)
return 0 if run(args.coverage) else 1


if __name__ == '__main__':
sys.exit(main())
sys.exit(main(sys.argv[1:], sys.argv[0]))
25 changes: 20 additions & 5 deletions tools/check_module_utest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@
modules' unit tests.
"""

import argparse
import sys
import subprocess
from utils import banner


def run():
def run(coverage=False):
print(banner('Build and run modules\' unit tests'))

extra_args = f'ENABLE_COVERAGE={"y" if coverage else "n"}'
result = subprocess.Popen(
'CC=gcc make -f Makefile.cmake mod_test',
f'CC=gcc make -f Makefile.cmake mod_test {extra_args}',
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
Expand All @@ -38,9 +40,22 @@ def run():
return True


def main():
return 0 if run() else 1
def parse_args(argv, prog_name):
parser = argparse.ArgumentParser(
prog=prog_name,
description='Build and run modules\' unit tests')

parser.add_argument('-c', '--coverage', dest='coverage',
required=False, default=False, action='store_true',
help='Enable code coverage reporting.')

return parser.parse_args(argv)


def main(argv=[], prog_name=''):
args = parse_args(argv, prog_name)
return 0 if run(args.coverage) else 1


if __name__ == '__main__':
sys.exit(main())
sys.exit(main(sys.argv[1:], sys.argv[0]))

0 comments on commit a0e2eeb

Please sign in to comment.