@@ -114,6 +114,12 @@ def add_parse_arguments(parser = None) -> argparse.ArgumentParser:
114
114
title = "Memory footprint" ,
115
115
description = "Collect and report ROM/RAM size footprint for the test instance images built." )
116
116
117
+ coverage_group = parser .add_argument_group (
118
+ title = "Code coverage" ,
119
+ description = "Build with code coverage support, collect code coverage statistics "
120
+ "executing tests, compose code coverage report at the end.\n "
121
+ "Effective for devices with 'HAS_COVERAGE_SUPPORT'." )
122
+
117
123
test_plan_report_xor .add_argument (
118
124
"-E" ,
119
125
"--save-tests" ,
@@ -342,10 +348,6 @@ def add_parse_arguments(parser = None) -> argparse.ArgumentParser:
342
348
If not provided, seed in generated by system.
343
349
Used only when --shuffle-tests is provided.""" )
344
350
345
- parser .add_argument ("-C" , "--coverage" , action = "store_true" ,
346
- help = "Generate coverage reports. Implies "
347
- "--enable-coverage." )
348
-
349
351
parser .add_argument (
350
352
"-c" , "--clobber-output" , action = "store_true" ,
351
353
help = "Cleaning the output directory will simply delete it instead "
@@ -355,27 +357,38 @@ def add_parse_arguments(parser = None) -> argparse.ArgumentParser:
355
357
"--cmake-only" , action = "store_true" ,
356
358
help = "Only run cmake, do not build or run." )
357
359
358
- parser .add_argument ("--coverage-basedir " , default = ZEPHYR_BASE ,
359
- help = "Base source directory for coverage report ." )
360
+ coverage_group .add_argument ("--enable-coverage " , action = "store_true" ,
361
+ help = "Enable code coverage collection using gcov ." )
360
362
361
- parser .add_argument ("--coverage-platform" , action = "append" , default = [],
362
- help = "Platforms to run coverage reports on. "
363
- "This option may be used multiple times. "
364
- "Default to what was selected with --platform." )
363
+ coverage_group .add_argument ("-C" , "--coverage" , action = "store_true" ,
364
+ help = "Generate coverage reports. Implies "
365
+ "--enable-coverage to collect the coverage data first." )
365
366
366
- parser .add_argument ("--coverage-tool" , choices = ['lcov' , 'gcovr' ], default = 'gcovr' ,
367
- help = "Tool to use to generate coverage report." )
367
+ coverage_group .add_argument ("--gcov-tool" , type = Path , default = None ,
368
+ help = "Path to the 'gcov' tool to use for code coverage reports. "
369
+ "By default it will be chosen in the following order:"
370
+ " using ZEPHYR_TOOLCHAIN_VARIANT ('llvm': from LLVM_TOOLCHAIN_PATH),"
371
+ " gcov installed on the host - for 'native' or 'unit' platform types,"
372
+ " using ZEPHYR_SDK_INSTALL_DIR." )
368
373
369
- parser .add_argument (
370
- "--coverage-formats" ,
371
- action = "store" ,
372
- default = None , # default behavior is set in run_coverage
373
- help = "Output formats to use for generated coverage reports, as a comma-separated list. " +
374
- "Valid options for 'gcovr' tool are: " +
375
- ',' .join (supported_coverage_formats ['gcovr' ]) + " (html - default)." +
376
- " Valid options for 'lcov' tool are: " +
377
- ',' .join (supported_coverage_formats ['lcov' ]) + " (html,lcov - default)."
378
- )
374
+ coverage_group .add_argument ("--coverage-basedir" , default = ZEPHYR_BASE ,
375
+ help = "Base source directory for coverage report." )
376
+
377
+ coverage_group .add_argument ("--coverage-platform" , action = "append" , default = [],
378
+ help = "Platforms to run coverage reports on. "
379
+ "This option may be used multiple times. "
380
+ "Default to what was selected with --platform." )
381
+
382
+ coverage_group .add_argument ("--coverage-tool" , choices = ['lcov' , 'gcovr' ], default = 'gcovr' ,
383
+ help = "Tool to use to generate coverage report (%(default)s - default)." )
384
+
385
+ coverage_group .add_argument ("--coverage-formats" , action = "store" , default = None ,
386
+ help = "Output formats to use for generated coverage reports " +
387
+ "as a comma-separated list without spaces. " +
388
+ "Valid options for 'gcovr' tool are: " +
389
+ ',' .join (supported_coverage_formats ['gcovr' ]) + " (html - default)." +
390
+ " Valid options for 'lcov' tool are: " +
391
+ ',' .join (supported_coverage_formats ['lcov' ]) + " (html,lcov - default)." )
379
392
380
393
parser .add_argument (
381
394
"--test-config" ,
@@ -402,9 +415,6 @@ def add_parse_arguments(parser = None) -> argparse.ArgumentParser:
402
415
help = "Specify tags of tests that should not run. "
403
416
"Default is to run all tests with all tags." )
404
417
405
- parser .add_argument ("--enable-coverage" , action = "store_true" ,
406
- help = "Enable code coverage using gcov." )
407
-
408
418
parser .add_argument (
409
419
"--enable-lsan" , action = "store_true" ,
410
420
help = """Enable leak sanitizer to check for heap memory leaks.
@@ -437,10 +447,6 @@ def add_parse_arguments(parser = None) -> argparse.ArgumentParser:
437
447
help = "Do not filter based on toolchain, use the set "
438
448
" toolchain unconditionally" )
439
449
440
- parser .add_argument ("--gcov-tool" , type = Path , default = None ,
441
- help = "Path to the gcov tool to use for code coverage "
442
- "reports" )
443
-
444
450
footprint_group .add_argument (
445
451
"--create-rom-ram-report" ,
446
452
action = "store_true" ,
0 commit comments