From c7d90935eb8fbe228b1eac4c4c361f1241918b28 Mon Sep 17 00:00:00 2001 From: Jerome Coutant Date: Tue, 20 Jul 2021 16:48:31 +0200 Subject: [PATCH] pinvalidate.py script: add deprecated ARDUINO test --- hal/tests/pinvalidate/pinvalidate.py | 29 +++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/hal/tests/pinvalidate/pinvalidate.py b/hal/tests/pinvalidate/pinvalidate.py index c1452c13a564..05b81132ed5a 100755 --- a/hal/tests/pinvalidate/pinvalidate.py +++ b/hal/tests/pinvalidate/pinvalidate.py @@ -260,7 +260,7 @@ def check_duplicate_markers(test_mode=False): return errors -def target_has_arduino_form_factor(target_name): +def target_has_form_factor(target_name, form_factor): """Check if the target has the Arduino form factor.""" mbed_os_root = pathlib.Path(__file__).absolute().parents[3] @@ -272,7 +272,7 @@ def target_has_arduino_form_factor(target_name): if target_name in target_data: if "supported_form_factors" in target_data[target_name]: form_factors = target_data[target_name]["supported_form_factors"] - if "ARDUINO_UNO" in form_factors: + if form_factor in form_factors: return True return False @@ -464,6 +464,13 @@ def legacy_uart_check(pin_name_dict): return invalid_items +def legacy_arduino_uno_check(arduino_form_factor): + invalid_items = [] + if arduino_form_factor == True: + message = "ARDUINO form factor is deprecated, should be replaced by ARDUIN_UNO" + invalid_items.append({"key": "", "val": "", "message": message}) + return invalid_items + def print_summary(report): targets = set([case["platform_name"] for case in report]) @@ -690,6 +697,12 @@ def has_passed_all_test_cases(report): "case_function": legacy_uart_check, "case_input": "content", }, + { + "suite_name": "generic", + "case_name": "arduino_formfactor", + "case_function": legacy_arduino_uno_check, + "case_input": "arduino_form_factor", + }, { "suite_name": "arduino_uno", "case_name": "duplicate", @@ -740,21 +753,27 @@ def validate_pin_names(args): pin_name_dict = pin_name_to_dict(pin_name_content) - arduino_support = target_has_arduino_form_factor(target) + arduino_uno_support = target_has_form_factor(target, "ARDUINO_UNO") + + arduino_support = target_has_form_factor(target, "ARDUINO") for case in test_cases: if suites: if case["suite_name"] not in suites: continue else: - if not arduino_support and case["suite_name"] == "arduino_uno": + if not arduino_uno_support and case["suite_name"] == "arduino_uno": + continue + if not arduino_uno_support and not arduino_support and case["case_name"] == "arduino_formfactor": continue + if case["case_input"] == "dict": case_input = pin_name_dict elif case["case_input"] == "content": case_input = pin_name_content - + elif case["case_input"] == "arduino_form_factor": + case_input = arduino_support case_output = case["case_function"](case_input) case_result = "FAILED" if case_output else "PASSED"