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 done
} }
# list_test_case lists all potential test cases in compat.sh without execution
list_test_case() { list_test_case() {
reset_ciphersuites reset_ciphersuites
for TYPE in $TYPES; do for TYPE in $TYPES; do
@ -169,6 +170,8 @@ get_options() {
-M|--memcheck) -M|--memcheck)
MEMCHECK=1 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)
list_test_case list_test_case
exit 0 exit 0

View File

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