Skip to content

Commit

Permalink
pinvalidate.py script: add deprecated ARDUINO test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromecoutant committed Jul 21, 2021
1 parent cf66ff0 commit c7d9093
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions hal/tests/pinvalidate/pinvalidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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
Expand Down Expand Up @@ -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])

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit c7d9093

Please sign in to comment.