-
Notifications
You must be signed in to change notification settings - Fork 38
Split test_psa_compliance.py #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
3008a4a
26cb1a1
43c6cbc
4ff6a49
af6b189
565b4c3
b4035db
954783c
ca98305
1295140
088a99e
581da21
aebb1fa
44ea713
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,10 @@ | |
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later | ||
|
||
import argparse | ||
import glob | ||
import os | ||
import re | ||
import shlex | ||
import shutil | ||
import subprocess | ||
import sys | ||
|
@@ -25,7 +27,7 @@ | |
#pylint: disable=too-many-branches,too-many-statements,too-many-locals | ||
def test_compliance(library_build_dir: str, | ||
psa_arch_tests_ref: str, | ||
patch: str, | ||
patch_files: List[str], | ||
expected_failures: List[int]) -> int: | ||
"""Check out and run compliance tests. | ||
|
||
|
@@ -59,12 +61,12 @@ def test_compliance(library_build_dir: str, | |
subprocess.check_call(['git', 'fetch', PSA_ARCH_TESTS_REPO, psa_arch_tests_ref]) | ||
subprocess.check_call(['git', 'checkout', '--force', 'FETCH_HEAD']) | ||
|
||
if patch: | ||
if patch_files: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand the logic behind running There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to minimize changes in 3.6 which doesn't need any of the new fancy stuff. Also, arguably, it makes things worse for local debugging where you might want to edit the cached psa-arch-test tree until you get it right. On the other hand, I agree with you that I would have made There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my local copy, I've now changed this to be controlled by the psa-arch-tests ref specification:
Does that seem sensible? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good! |
||
subprocess.check_call(['git', 'reset', '--hard']) | ||
subprocess.run(['patch', '-p1'], | ||
check=True, | ||
encoding='utf-8', | ||
input=patch) | ||
for patch_file in patch_files: | ||
abs_path = os.path.abspath(os.path.join(root_dir, patch_file)) | ||
subprocess.check_call(['patch -p1 <' + shlex.quote(abs_path)], | ||
shell=True) | ||
bensze01 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
build_dir = 'api-tests/build' | ||
try: | ||
|
@@ -143,15 +145,15 @@ def test_compliance(library_build_dir: str, | |
os.chdir(root_dir) | ||
|
||
def main(psa_arch_tests_ref: str, | ||
patch: str = '', | ||
expected_failures: Optional[List[int]] = None) -> None: | ||
"""Command line entry point. | ||
|
||
psa_arch_tests_ref: tag or sha to use for the arch-tests. | ||
patch: patch to apply to the arch-tests with ``patch -p1``. | ||
expected_failures: default list of expected failures. | ||
""" | ||
build_dir = 'out_of_source_build' | ||
default_patch_directory = os.path.join(build_tree.guess_project_root(), | ||
'scripts/data_files/psa-arch-tests') | ||
|
||
# pylint: disable=invalid-name | ||
parser = argparse.ArgumentParser() | ||
|
@@ -161,6 +163,9 @@ def main(psa_arch_tests_ref: str, | |
help='''set the list of test codes which are expected to fail | ||
from the command line. If omitted the list given by | ||
EXPECTED_FAILURES (inside the script) is used.''') | ||
parser.add_argument('--patch-directory', nargs=1, | ||
default=default_patch_directory, | ||
mpg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
help='Directory containing patches (*.patch) to apply to psa-arch-tests') | ||
args = parser.parse_args() | ||
|
||
if args.build_dir is not None: | ||
|
@@ -173,7 +178,12 @@ def main(psa_arch_tests_ref: str, | |
else: | ||
expected_failures_list = expected_failures | ||
|
||
if args.patch_directory: | ||
patch_files = glob.glob(os.path.join(args.patch_directory, '*.patch')) | ||
bensze01 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
else: | ||
patch_files = [] | ||
|
||
sys.exit(test_compliance(build_dir, | ||
psa_arch_tests_ref, | ||
patch, | ||
patch_files, | ||
expected_failures_list)) |
Uh oh!
There was an error while loading. Please reload this page.