From c981dbfa80468b70165cfddc4b5846daee0d96d6 Mon Sep 17 00:00:00 2001 From: heck Date: Sat, 23 Jan 2021 02:15:50 +0100 Subject: [PATCH] test_pEpACIDgen.py: Array Support added. --- tests/test_pEpACIDgen.py | 89 ++++++++++++++++++++++++++++++---------- 1 file changed, 67 insertions(+), 22 deletions(-) diff --git a/tests/test_pEpACIDgen.py b/tests/test_pEpACIDgen.py index 3962786..16dc69d 100755 --- a/tests/test_pEpACIDgen.py +++ b/tests/test_pEpACIDgen.py @@ -6,7 +6,7 @@ import re import pytest import pEpACIDgen -input() +# input() # "type" - is the name of the type for which vars of all variations of this type exists # (Variations being combinations of this type with qualifier alias and typedef, # Which means that all variations resolve to the same underlying type) @@ -49,34 +49,64 @@ all_types.append({"type": ["PS"], "struct PS" ]}) +all_types.append({"type": ["_PSIa"], + "requires": [ + "struct _PSIa" + ]}) + +all_types.append({"type": ["PSIa"], + "requires": [ + "struct PSIa" + ]}) + +all_types.append({"type": ["_PSa"], + "requires": [ + "struct _PSa" + ]}) + +all_types.append({"type": ["PSa"], + "requires": [ + "struct PSa" + ]}) + all_types.append({"type": ["_CS"], "requires": [ "struct _CS", + "struct _PS", "struct PS", - "struct _PS" + "struct _PSa", + "struct PSa" ]}) all_types.append({"type": ["CS"], "requires": [ "struct CS", "struct _PS", - "struct PS" + "struct PS", + "struct _PSa", + "struct PSa" ]}) all_types.append({"type": ["_CCS"], "requires": [ "struct _CCS", + "struct _CS", "struct CS", "struct _PS", - "struct PS" + "struct PS", + "struct _PSa", + "struct PSa" ]}) all_types.append({"type": ["CCS"], "requires": [ "struct CCS", + "struct _CS", "struct CS", "struct _PS", - "struct PS" + "struct PS", + "struct _PSa", + "struct PSa" ]}) all_types.append({"type": ["_HS"], @@ -85,7 +115,9 @@ all_types.append({"type": ["_HS"], "struct _NCS", "struct CS", "struct _PS", - "struct PS" + "struct PS", + "struct _PSa", + "struct PSa" ]}) all_types.append({"type": ["HS"], @@ -99,7 +131,9 @@ all_types.append({"type": ["_NCS"], "struct _NCS", "struct CS", "struct _PS", - "struct PS" + "struct PS", + "struct _PSa", + "struct PSa" ]}) all_types.append({"type": ["_NPS"], @@ -120,8 +154,10 @@ all_types.append({"type": ["HHS"], "struct _NHS1", "struct _NNCS", "struct _CS", - "struct PS", "struct _PS", + "struct PS", + "struct _PSa", + "struct PSa", "enum _NENHS" ]}) @@ -141,8 +177,10 @@ all_types.append({"type": ["_NHS1"], "struct _NHS1", "struct _NNCS", "struct _CS", - "struct PS", "struct _PS", + "struct PS", + "struct _PSa", + "struct PSa", "enum _NENHS" ]}) @@ -150,8 +188,10 @@ all_types.append({"type": ["_NNCS"], "requires": [ "struct _NNCS", "struct _CS", + "struct _PS", "struct PS", - "struct _PS" + "struct _PSa", + "struct PSa" ]}) all_types.append({"type": ["_NENHS"], @@ -215,38 +255,43 @@ def check_expected_types_resolved(vars, funcs, type_names_expected): # * TAX var_TAX # * TTX var_TTX # * TTAX var_TTAX -# AND the type of ALL these vars resolves to the same underlying type X +# AND the type of ALL these vars resolves to the same underlying type X (and its dependencies) # # types with no alias -# type with no alias can only exists in variations NOT ending with A +# ------------------- +# type with no alias can only exist in variations NOT ending with A # # Anonymous types (enum only) +# --------------------------- # an anonymous type only exists because of its alias typedef enum { a;b;c } XE; # Therefore, only variations ending with A are valid -@pytest.mark.parametrize('variation', ["var_", "var_A", "var_T", "var_TA", "var_TT", "var_TTA"]) -@pytest.mark.parametrize('data', all_types) -def test_single_var_no_alias(data, variation): - type = data["type"][0] - var_name = variation + type +@pytest.mark.parametrize('variation_a', ["","a"]) +@pytest.mark.parametrize('variation_A_and_T', ["", "A", "T", "TA", "TT", "TTA"]) +# TODO: Typdefs of arrays ot workig curretly, SHOULD BE: +# @pytest.mark.parametrize('variation_A_and_T', ["", "A", "T", "TA", "TaT", "TaTA", "TaT", "TaTA"]) +@pytest.mark.parametrize('typekind', all_types) +def test_single_var_no_alias(typekind,variation_a, variation_A_and_T): + type = typekind["type"][0] + var_name = "var_" + variation_a + variation_A_and_T + type # it the type begins with _ it has no alias re_type_no_alias = re.compile("^_") - # if the variation ends with a is an alias of something + # if the variation ends with an A is an alias of something re_vari_alias = re.compile("A$") # if the type contains an X is is an anonymous type re_type_anonynmous = re.compile("X") - skipmsg = "variation not valid:" + variation + " for type:" + type + skipmsg = "variation not valid:" + variation_A_and_T + " for type:" + type re_vari_invalid_for_anon = re.compile("") if re_type_no_alias.search(type): - if re_vari_alias.search(variation): + if re_vari_alias.search(variation_A_and_T): print(skipmsg) pytest.skip(skipmsg) # the anonymous type only exists because of its alias if re_type_anonynmous.search(type): - if not re_vari_alias.search(variation): + if not re_vari_alias.search(variation_A_and_T): print(skipmsg) pytest.skip(skipmsg) - check_expected_types_resolved([var_name], [], data["requires"]) + check_expected_types_resolved([var_name], [], typekind["requires"])