sanitycheck: support exporting instances
Enable exporting tests per platform. sanitycheck --export-tests out.txt -p qemu_x86 -T tests/ Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
f7a6c7d154
commit
bb28035a82
|
@ -103,9 +103,9 @@ identifier:
|
|||
``cmake``::
|
||||
|
||||
# with west
|
||||
west build -b tinytile
|
||||
west build -b reel_board
|
||||
# with cmake
|
||||
cmake -DBOARD=tinytile ..
|
||||
cmake -DBOARD=reel_board ..
|
||||
|
||||
name:
|
||||
The actual name of the board as it appears in marketing material.
|
||||
|
|
|
@ -2214,6 +2214,10 @@ class TestSuite(DisablePyTestCollectionMixin):
|
|||
# hardcoded for now
|
||||
self.connected_hardware = []
|
||||
|
||||
def get_platform_instances(self, platform):
|
||||
filtered_dict = {k:v for k,v in self.instances.items() if k.startswith(platform + "/")}
|
||||
return filtered_dict
|
||||
|
||||
def config(self):
|
||||
logger.info("coverage platform: {}".format(self.coverage_platform))
|
||||
|
||||
|
|
|
@ -170,6 +170,7 @@ import argparse
|
|||
import sys
|
||||
import logging
|
||||
import time
|
||||
import itertools
|
||||
import shutil
|
||||
from collections import OrderedDict
|
||||
import multiprocessing
|
||||
|
@ -178,6 +179,7 @@ import csv
|
|||
from colorama import Fore
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ZEPHYR_BASE = os.getenv("ZEPHYR_BASE")
|
||||
if not ZEPHYR_BASE:
|
||||
# This file has been zephyr/scripts/sanitycheck for years,
|
||||
|
@ -391,7 +393,10 @@ Artificially long but functional example:
|
|||
|
||||
parser.add_argument("--export-tests", action="store",
|
||||
metavar="FILENAME",
|
||||
help="Export tests case meta-data to a file in CSV format.")
|
||||
help="Export tests case meta-data to a file in CSV format."
|
||||
"Test instances can be exported per target by supplying "
|
||||
"the platform name using --platform option. (tests for only "
|
||||
" one platform can be exported at a time)")
|
||||
|
||||
parser.add_argument("--timestamps",
|
||||
action="store_true",
|
||||
|
@ -837,8 +842,8 @@ def main():
|
|||
|
||||
return
|
||||
|
||||
if options.list_tests or options.test_tree or options.list_test_duplicates \
|
||||
or options.sub_test or options.export_tests:
|
||||
if not options.platform and (options.list_tests or options.test_tree or options.list_test_duplicates \
|
||||
or options.sub_test or options.export_tests):
|
||||
cnt = 0
|
||||
all_tests = suite.get_all_tests()
|
||||
|
||||
|
@ -945,6 +950,29 @@ def main():
|
|||
|
||||
)
|
||||
|
||||
if (options.export_tests or options.list_tests) and options.platform:
|
||||
if len(options.platform) > 1:
|
||||
logger.error("When exporting tests, only one platform "
|
||||
"should be specified.")
|
||||
return
|
||||
|
||||
for p in options.platform:
|
||||
inst = suite.get_platform_instances(p)
|
||||
if options.export_tests:
|
||||
tests = [x.testcase.cases for x in inst.values()]
|
||||
merged = list(itertools.chain(*tests))
|
||||
export_tests(options.export_tests, merged)
|
||||
return
|
||||
|
||||
count = 0
|
||||
for i in inst.values():
|
||||
for c in i.testcase.cases:
|
||||
print(f"- {c}")
|
||||
count += 1
|
||||
|
||||
print(f"Tests found: {count}")
|
||||
return
|
||||
|
||||
if VERBOSE > 1 and discards:
|
||||
# if we are using command line platform filter, no need to list every
|
||||
# other platform as excluded, we know that already.
|
||||
|
|
Loading…
Reference in a new issue