X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2Fautogen%2FRegenerator.py;h=bb2e5b5fbcc4a02b56c65bb5396c825de72282f3;hb=refs%2Fchanges%2F76%2F33976%2F2;hp=7003d3905d4929cee839992306b47a64d1a3f057;hpb=9f5525de03c3d1cbca8b7e2a324414308645a9f3;p=csit.git diff --git a/resources/libraries/python/autogen/Regenerator.py b/resources/libraries/python/autogen/Regenerator.py index 7003d3905d..bb2e5b5fbc 100644 --- a/resources/libraries/python/autogen/Regenerator.py +++ b/resources/libraries/python/autogen/Regenerator.py @@ -195,6 +195,32 @@ def add_iperf3_testcases(testcase, file_out, tc_kwargs_list): file_out.write(testcase.generate(**kwargs)) +def add_trex_testcases(testcase, suite_id, file_out, tc_kwargs_list): + """Add trex testcases to file. + + :param testcase: Testcase class. + :param suite_id: Suite ID. + :param file_out: File to write testcases to. + :param tc_kwargs_list: Key-value pairs used to construct testcases. + :type testcase: Testcase + :type suite_id: str + :type file_out: file + :type tc_kwargs_list: dict + """ + for kwargs in tc_kwargs_list: + # TODO: Is there a better way to disable some combinations? + emit = True + if ( + u"-cps-" in suite_id + or u"-pps-" in suite_id + or u"-tput-" in suite_id + ): + if kwargs[u"frame_size"] not in MIN_FRAME_SIZE_VALUES: + emit = False + if emit: + 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 +506,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, suite_id, file_out, kwargs_list) + + def write_device_files(in_filename, in_prolog, kwargs_list): """Using given filename and prolog, write all generated suites. @@ -570,7 +654,7 @@ class Regenerator: Log-like prints are emitted to sys.stderr. - :param pattern: Glob pattern to select files. Example: *-ndrpdr.robot + :param pattern: Glob pattern to select files. Example: \*-ndrpdr.robot :param protocol: String determining minimal frame size. Default: "ip4" :type pattern: str :type protocol: str @@ -637,6 +721,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 +747,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(