check_test_cases.py: use check_output to capture error and return

This commit includes:
 - use subprocess.check_output to report error and capture return
   value
 - add comment as a reminder for option --list-test-case

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
Yanray Wang 2023-03-03 17:12:29 +08:00
parent 521710e91d
commit cdc0708334
2 changed files with 10 additions and 12 deletions

View file

@ -121,6 +121,7 @@ print_test_case() {
done
}
# list_test_case lists all potential test cases in compat.sh without execution
list_test_case() {
reset_ciphersuites
for TYPE in $TYPES; do
@ -169,6 +170,8 @@ get_options() {
-M|--memcheck)
MEMCHECK=1
;;
# Please check scripts/check_test_cases.py correspondingly
# if you have to modify option, --list-test-case
--list-test-case)
list_test_case
exit 0

View file

@ -116,18 +116,13 @@ state may override this method.
"""Iterate over the test cases compat.sh with a similar format."""
descriptions = self.new_per_file_state() # pylint: disable=assignment-from-none
compat_cmd = ['sh', file_name, '--list-test-case']
result = subprocess.run(compat_cmd,
stdout=subprocess.PIPE,
check=False)
if result.returncode != 0:
print(*compat_cmd, 'returned', str(result.returncode))
return
else:
# Assume compat.sh is responsible for printing identical format of
# test case description between --list-test-case and its OUTCOME.CSV
description = result.stdout.strip().split(b'\n')
for idx, descrip in enumerate(description):
self.process_test_case(descriptions, file_name, idx, descrip)
compat_output = subprocess.check_output(compat_cmd,
stderr=subprocess.STDOUT)
# Assume compat.sh is responsible for printing identical format of
# test case description between --list-test-case and its OUTCOME.CSV
description = compat_output.strip().split(b'\n')
for idx, descrip in enumerate(description):
self.process_test_case(descriptions, file_name, idx, descrip)
@staticmethod
def collect_test_directories():