Skip to content

Commit 4d46088

Browse files
authored
Improve scs-compliance-check report even further (#701)
Signed-off-by: Kurt Garloff <[email protected]> Signed-off-by: Matthias Büchse <[email protected]>
1 parent 02f4108 commit 4d46088

File tree

2 files changed

+51
-39
lines changed

2 files changed

+51
-39
lines changed

Tests/scs-compatible-iaas.yaml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ modules:
1919
testcases:
2020
- id: flavor-name-check
2121
tags: [mandatory]
22-
description: |
23-
The environment fulfills all requirements of
22+
description: >
23+
Must fulfill all requirements of
2424
https://docs.scs.community/standards/scs-0100-v1-flavor-naming
2525
- id: scs-0100-v2
2626
name: Flavor naming v2
@@ -31,8 +31,8 @@ modules:
3131
testcases:
3232
- id: flavor-name-check
3333
tags: [mandatory]
34-
description: |
35-
The environment fulfills all requirements of
34+
description: >
35+
Must fulfill all requirements of
3636
https://docs.scs.community/standards/scs-0100-v2-flavor-naming
3737
- id: scs-0100-v3.1
3838
name: Flavor naming v3.1
@@ -44,8 +44,8 @@ modules:
4444
testcases:
4545
- id: flavor-name-check
4646
tags: [mandatory]
47-
description: |
48-
The environment fulfills all requirements of
47+
description: >
48+
Must fulfill all requirements of
4949
https://docs.scs.community/standards/scs-0100-v3-flavor-naming -- plus the list of mandatory
5050
and recommended flavors found in https://docs.scs.community/standards/scs-0100-v2-flavor-naming#standard-scs-flavors
5151
- id: scs-0100-v3.2
@@ -58,8 +58,8 @@ modules:
5858
testcases:
5959
- id: flavor-name-check
6060
tags: [mandatory]
61-
description: |
62-
The environment fulfills all requirements of
61+
description: >
62+
Must fulfill all requirements of
6363
https://docs.scs.community/standards/scs-0100-v3-flavor-naming
6464
- id: scs-0101-v1
6565
name: Entropy v1
@@ -80,8 +80,8 @@ modules:
8080
tags: [] # don't use this testcase, but list it anyway because the script will output a result
8181
- id: entropy-check
8282
tags: [mandatory]
83-
description: |
84-
The environment fulfills all requirements of
83+
description: >
84+
Must fulfill all requirements of
8585
https://docs.scs.community/standards/scs-0101-v1-entropy
8686
- id: scs-0101-v1.1
8787
name: Entropy v1
@@ -92,28 +92,28 @@ modules:
9292
testcases:
9393
- id: entropy-check-flavor-properties
9494
tags: [recommended]
95-
description: |
96-
The environment has all flavor properties recommended in
95+
description: >
96+
Must have all flavor properties recommended in
9797
https://docs.scs.community/standards/scs-0101-w1-entropy-implementation-testing#warnings
9898
- id: entropy-check-image-properties
9999
tags: [recommended]
100-
description: |
101-
The environment has all image properties recommended in
100+
description: >
101+
Must have all image properties recommended in
102102
https://docs.scs.community/standards/scs-0101-w1-entropy-implementation-testing#warnings
103103
- id: entropy-check-rngd
104104
tags: [mandatory]
105-
description: |
106-
The images of the test sample have the service `rngd`; see
105+
description: >
106+
Images of the test sample must have the service `rngd`; see
107107
https://docs.scs.community/standards/scs-0101-w1-entropy-implementation-testing#errors
108108
- id: entropy-check-entropy-avail
109109
tags: [mandatory]
110-
description: |
111-
A test instance has the correct `entropy_avail`; see
110+
description: >
111+
A test instance must have the correct `entropy_avail`; see
112112
https://docs.scs.community/standards/scs-0101-w1-entropy-implementation-testing#errors
113113
- id: entropy-check-fips-test
114114
tags: [mandatory]
115-
description: |
116-
A test instance passes the "FIPS test"; see
115+
description: >
116+
A test instance must pass the "FIPS test"; see
117117
https://docs.scs.community/standards/scs-0101-w1-entropy-implementation-testing#errors
118118
- id: entropy-check
119119
tags: [] # don't use this testcase, but list it anyway because the script will output a result
@@ -128,8 +128,8 @@ modules:
128128
testcases:
129129
- id: image-metadata-check
130130
tags: [mandatory]
131-
description: |
132-
The environment fulfills all requirements of https://docs.scs.community/standards/scs-0102-v1-image-metadata
131+
description: >
132+
Must fulfill all requirements of https://docs.scs.community/standards/scs-0102-v1-image-metadata
133133
- id: scs-0103-v1
134134
name: Standard flavors
135135
url: https://docs.scs.community/standards/scs-0103-v1-standard-flavors
@@ -139,8 +139,8 @@ modules:
139139
testcases:
140140
- id: standard-flavors-check
141141
tags: [mandatory]
142-
description: |
143-
The environment fulfills all requirements of https://docs.scs.community/standards/scs-0103-v1-standard-flavors
142+
description: >
143+
Must fulfill all requirements of https://docs.scs.community/standards/scs-0103-v1-standard-flavors
144144
- id: scs-0104-v1
145145
name: Standard images
146146
url: https://docs.scs.community/standards/scs-0104-v1-standard-images
@@ -152,8 +152,8 @@ modules:
152152
testcases:
153153
- id: standard-images-check
154154
tags: [mandatory]
155-
description: |
156-
The environment fulfills all requirements of https://docs.scs.community/standards/scs-0104-v1-standard-images
155+
description: >
156+
Must fulfill all requirements of https://docs.scs.community/standards/scs-0104-v1-standard-images
157157
timeline:
158158
- date: 2024-07-31
159159
versions:

Tests/scs-compliance-check.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ def __init__(self, cwd, assignment, verbosity=0):
199199
self.num_abort = 0
200200
self.num_error = 0
201201
self.verbosity = verbosity
202+
self.spamminess = 0
202203

203204
def run(self, check):
204205
parameters = check.get('parameters')
@@ -221,9 +222,11 @@ def run(self, check):
221222
}
222223
if self.verbosity > 1 and invocation["stdout"]:
223224
print("\n".join(invocation["stdout"]))
225+
self.spamminess += 1
224226
# the following check used to be "> 0", but this is quite verbose...
225227
if invocation['rc'] or self.verbosity > 1 and invocation["stderr"]:
226228
print("\n".join(invocation["stderr"]))
229+
self.spamminess += 1
227230
self.memo[memo_key] = invocation
228231
logger.debug(f".. rc {invocation['rc']}, {invocation['critical']} critical, {invocation['error']} error")
229232
self.num_abort += invocation["critical"]
@@ -260,18 +263,18 @@ def finalize(self, permissible_ids=None):
260263
return final
261264

262265

263-
def run_suite(suite: TestSuite, runner: CheckRunner, results: ResultBuilder):
264-
"""run all checks of `suite` using `runner`, collecting `results`"""
266+
def run_suite(suite: TestSuite, runner: CheckRunner):
267+
"""run all checks of `suite` using `runner`, returning results dict via `ResultBuilder`"""
265268
suite.check_sanity()
269+
builder = ResultBuilder(suite.name)
266270
for check in suite.checks:
267271
invocation = runner.run(check)
268272
for id_, value in invocation["results"].items():
269-
results.record(id_, result=value, invocation=invocation['id'])
273+
builder.record(id_, result=value, invocation=invocation['id'])
274+
return builder.finalize(permissible_ids=suite.ids)
270275

271276

272-
def print_report(subject: str, suite: TestSuite, targets: dict, results: dict, verbose=False):
273-
if verbose:
274-
print("********" * 10)
277+
def print_report(subject: str, suite: TestSuite, targets: dict, results: dict):
275278
print(f"{subject} {suite.name}:")
276279
for tname, target_spec in targets.items():
277280
by_result = suite.select(tname, target_spec).evaluate(results)
@@ -287,10 +290,13 @@ def print_report(subject: str, suite: TestSuite, targets: dict, results: dict, v
287290
for offenders, category in ((failed, 'FAILED'), (missing, 'MISSING')):
288291
if category == 'MISSING' and suite.partial:
289292
continue # do not report each missing testcase if a filter was used
293+
if not offenders:
294+
continue
295+
print(f" - {category}:")
290296
for testcase in offenders:
291-
print(f" - {category} {testcase['id']}")
297+
print(f" - {testcase['id']}:")
292298
if 'description' in testcase: # used to be `verbose and ...`, but users need the URL!
293-
print(' ' + testcase['description'])
299+
print(f" > {testcase['description'].strip()}")
294300

295301

296302
def create_report(argv, config, spec, versions, invocations):
@@ -344,6 +350,8 @@ def main(argv):
344350
check_cwd = os.path.dirname(config.arg0) or os.getcwd()
345351
runner = CheckRunner(check_cwd, config.assignment, verbosity=config.verbose and 2 or not config.quiet)
346352
version_report = {}
353+
# collect report data as tuples (version, suite, results) before printing them
354+
report_data = []
347355
for version in versions:
348356
vname = version['version']
349357
suite = compile_suite(
@@ -352,12 +360,16 @@ def main(argv):
352360
config.sections,
353361
config.tests,
354362
)
355-
builder = ResultBuilder(suite.name)
356-
run_suite(suite, runner, builder)
357-
results = version_report[vname] = builder.finalize(permissible_ids=suite.ids)
358-
if not config.quiet:
359-
print_report(config.subject, suite, version['targets'], results, verbose=config.verbose)
363+
report_data.append((version, suite, run_suite(suite, runner)))
364+
# now report: to console if requested, and likewise for yaml output
365+
if not config.quiet:
366+
# print a horizontal line if we had any script output
367+
if runner.spamminess:
368+
print("********" * 10) # 80 characters
369+
for version, suite, results in report_data:
370+
print_report(config.subject, suite, version['targets'], results)
360371
if config.output:
372+
version_report = {version['version']: results for version, _, results in report_data}
361373
report = create_report(argv, config, spec, version_report, runner.get_invocations())
362374
with open(config.output, 'w', encoding='UTF-8') as fileobj:
363375
yaml.safe_dump(report, fileobj, default_flow_style=False, sort_keys=False)

0 commit comments

Comments
 (0)