Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Javagedes committed May 2, 2024
1 parent cdea65d commit 0096329
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
26 changes: 15 additions & 11 deletions BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def do_post_build(self, thebuilder):
""").strip())
return 0

error_messages = [] # MU_CHANGE- Check for invalid tests
for test in testList:
# Configure output name if test uses cmocka.
shell_env.set_shell_var(
Expand All @@ -117,23 +118,22 @@ def do_post_build(self, thebuilder):
os.path.basename(test))
file_match_pattern = test + ".*." + arch + ".result.xml"
xml_results_list = glob.glob(file_match_pattern)
# MU_CHANGE [BEGIN] - Check for invalid tests
if len(xml_results_list) == 0:
logging.error(f'{os.path.basename(test)} did not generate any test suites.')
logging.error('Review Code to ensure Test suites are created and tests are registered!')
failure_count += 1
# MU_CHANGE [END] - Check for invalid tests

for xml_result_file in xml_results_list:
root = xml.etree.ElementTree.parse(
xml_result_file).getroot()
# MU_CHANGE [BEGIN] - Check for invalid tests
if len(root) == 0:
error_messages.append(f'{os.path.basename(test)} did not generate a test suite(s).')
error_messages.append(' Review source code to ensure Test suites are created and tests are registered!')
failure_count += 1
for suite in root:
# MU_CHANGE [BEGIN] - Check for invalid tests
if len(suite) == 0:
logging.error(f'TestSuite [{suite.attrib["name"]}] for test {test} did '
'not contain any test case.')
logging.error('Review Code to ensure test cases are registered to the suite!')
error_messages.append(f'TestSuite [{suite.attrib["name"]}] for test {test} did '
'not contain a test case(s).')
error_messages.append(' Review source code to ensure test cases are registered to the suite!')
failure_count += 1
# MU_CHANGE [END] - Check for invalid tests
# MU_CHANGE [END] - Check for invalid tests
for case in suite:
for result in case:
if result.tag == 'failure':
Expand Down Expand Up @@ -164,6 +164,10 @@ def do_post_build(self, thebuilder):
return -1
# MU_CHANGE end - reformat coverage data

# MU_CHANGE [BEGIN] - Check for invalid tests
for error in error_messages:
logging.error(error)
# MU_CHANGE [END] - Check for invalid tests
return failure_count

def gen_code_coverage_gcc(self, thebuilder):
Expand Down
4 changes: 2 additions & 2 deletions UnitTestFrameworkPkg/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -1515,9 +1515,9 @@ or FALSE e.g. `CC_REORGANIZE=TRUE`:

1. `CC_REORGANIZE`: Controls if code coverage results are re-formatted into a "by-inf" folder
structure rather than the default "by-test" folder structure. Default: `TRUE`
1. `CC_FULL`: Generates zero'd out coverage data for untested source files in the package.
1. `CC_FULL`: Generates zero'd out coverage data for untested source files in the package.
Default: `FALSE`
2. `CC_FLATTEN`: Groups all source files together, rather than by INF. Default: `FALSE`
1. `CC_FLATTEN`: Groups all source files together, rather than by INF. Default: `FALSE`

** NOTE: `CC_FULL` and `CC_FLATTEN` values only matter if `CC_REORGANIZE=TRUE`, as they only
effect how the coverage report is reorganized.
Expand Down

0 comments on commit 0096329

Please sign in to comment.