aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/autogen/Regenerator.py
diff options
context:
space:
mode:
authorViliam Luc <vluc@cisco.com>2021-08-02 14:25:26 +0200
committerViliam Luc <vluc@cisco.com>2021-09-10 10:26:24 +0200
commitec467277744783015a2da6713298b35d13d92e6f (patch)
tree57b1bb084f5ae9c6346be5a92f8fe5fac38f1cd4 /resources/libraries/python/autogen/Regenerator.py
parent9cceefae3248e9a1e9e5586391c9263cf114a753 (diff)
back-to-back tests: add TG tests
Change-Id: I9d028294deb1e31b6d185deb1c7523e0226a0ada Signed-off-by: Viliam Luc <vluc@cisco.com>
Diffstat (limited to 'resources/libraries/python/autogen/Regenerator.py')
-rw-r--r--resources/libraries/python/autogen/Regenerator.py82
1 files changed, 82 insertions, 0 deletions
diff --git a/resources/libraries/python/autogen/Regenerator.py b/resources/libraries/python/autogen/Regenerator.py
index 7003d3905d..14a9fd0ddb 100644
--- a/resources/libraries/python/autogen/Regenerator.py
+++ b/resources/libraries/python/autogen/Regenerator.py
@@ -195,6 +195,20 @@ def add_iperf3_testcases(testcase, file_out, tc_kwargs_list):
file_out.write(testcase.generate(**kwargs))
+def add_trex_testcases(testcase, file_out, tc_kwargs_list):
+ """Add trex testcases to file.
+
+ :param testcase: Testcase class.
+ :param file_out: File to write testcases to.
+ :param tc_kwargs_list: Key-value pairs used to construct testcases.
+ :type testcase: Testcase
+ :type file_out: file
+ :type tc_kwargs_list: dict
+ """
+ for kwargs in tc_kwargs_list:
+ file_out.write(testcase.generate(**kwargs))
+
+
def write_default_files(in_filename, in_prolog, kwargs_list):
"""Using given filename and prolog, write all generated suites.
@@ -480,6 +494,64 @@ def write_iperf3_files(in_filename, in_prolog, kwargs_list):
add_iperf3_testcases(testcase, file_out, kwargs_list)
+def write_trex_files(in_filename, in_prolog, kwargs_list):
+ """Using given filename and prolog, write all generated trex suites.
+
+ :param in_filename: Template filename to derive real filenames from.
+ :param in_prolog: Template content to derive real content from.
+ :param kwargs_list: List of kwargs for add_trex_testcase.
+ :type in_filename: str
+ :type in_prolog: str
+ :type kwargs_list: list of dict
+ """
+ for suite_type in Constants.PERF_TYPE_TO_KEYWORD:
+ tmp_filename = replace_defensively(
+ in_filename, u"ndrpdr", suite_type, 1,
+ u"File name should contain suite type once.", in_filename
+ )
+ tmp_prolog = replace_defensively(
+ in_prolog, u"ndrpdr".upper(), suite_type.upper(), 1,
+ u"Suite type should appear once in uppercase (as tag).",
+ in_filename
+ )
+ tmp_prolog = replace_defensively(
+ tmp_prolog,
+ u"Find NDR and PDR intervals using optimized search",
+ Constants.PERF_TYPE_TO_KEYWORD[suite_type], 1,
+ u"Main search keyword should appear once in suite.",
+ in_filename
+ )
+ tmp_prolog = replace_defensively(
+ tmp_prolog,
+ Constants.PERF_TYPE_TO_SUITE_DOC_VER[u"ndrpdr"],
+ Constants.PERF_TYPE_TO_SUITE_DOC_VER[suite_type],
+ 1, u"Exact suite type doc not found.", in_filename
+ )
+ tmp_prolog = replace_defensively(
+ tmp_prolog,
+ Constants.PERF_TYPE_TO_TEMPLATE_DOC_VER[u"ndrpdr"],
+ Constants.PERF_TYPE_TO_TEMPLATE_DOC_VER[suite_type],
+ 1, u"Exact template type doc not found.", in_filename
+ )
+ _, suite_id, suite_tag = get_iface_and_suite_ids(tmp_filename)
+ testcase = Testcase.trex(suite_id)
+ for nic_name in Constants.NIC_NAME_TO_CODE:
+ out_filename = replace_defensively(
+ tmp_filename, u"10ge2p1x710",
+ Constants.NIC_NAME_TO_CODE[nic_name], 1,
+ u"File name should contain NIC code once.", in_filename
+ )
+ out_prolog = replace_defensively(
+ tmp_prolog, u"Intel-X710", nic_name, 2,
+ u"NIC name should appear twice (tag and variable).",
+ in_filename
+ )
+ check_suite_tag(suite_tag, out_prolog)
+ with open(out_filename, u"wt") as file_out:
+ file_out.write(out_prolog)
+ add_trex_testcases(testcase, file_out, kwargs_list)
+
+
def write_device_files(in_filename, in_prolog, kwargs_list):
"""Using given filename and prolog, write all generated suites.
@@ -637,6 +709,13 @@ class Regenerator:
{u"frame_size": min_frame_size, u"phy_cores": 0}
]
+ trex_kwargs_list = [
+ {u"frame_size": min_frame_size},
+ {u"frame_size": 1518},
+ {u"frame_size": 9000},
+ {u"frame_size": u"IMIX_v4_1"}
+ ]
+
for in_filename in glob(pattern):
if not self.quiet:
print(
@@ -656,6 +735,9 @@ class Regenerator:
in_prolog = u"".join(
file_in.read().partition(u"*** Test Cases ***")[:-1]
)
+ if "-tg-" in in_filename:
+ write_trex_files(in_filename, in_prolog, trex_kwargs_list)
+ continue
if in_filename.endswith(u"-ndrpdr.robot"):
if u"scheduler" in in_filename:
write_default_files(