aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/autogen/Regenerator.py
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2020-01-03 16:01:30 +0100
committerJan Gelety <jgelety@cisco.com>2020-01-10 16:08:42 +0100
commitb55e324d526e5b05baef015c3614b9743c955992 (patch)
tree1e42006c4513bdcdee35eb5f677e055b64c06e86 /resources/libraries/python/autogen/Regenerator.py
parent5147d3ac0844b31852a3c221759f31915744b1c7 (diff)
Autogen: Generate also NIC drivers.
+ Disallowed -avf- (or -rdma-) as "template" suites. + GBP suite switched to DPDK driver in repo. + Each NIC has its own list of supported drivers, in Constants. + Updated tag expressions for daily jobs: + Feature, ipsec, memif, scale, srv6, tunnels, vhost and vts are tested only with vfio-pci. + Other (base, dot1q, dot1ad) tested with all drivers. + Setup actions currently depend on driver, generated. - The performance_rdma action is trivial for now. - Several tests fail, to be fixed later, e.g. by performance_rdma. + Reconf tests are also supported. + Added DRV_VFIO_PCI tags missing, mainly in density tests. - Vhost suites (density, reconf) are failing, but suites look good. - TCP suites do not support NIC drivers yet. - DPDK obviously not supported. + Use Python 3 in regenerate scripts. + Fix typos binded => bound. + File open modes set either u"rt" or u"wt" everywhere. + Remove a trailing space in an environment variable name. Change-Id: I290470675dc5c9e88b2eaa5ab6285ecd9ed7827a Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/libraries/python/autogen/Regenerator.py')
-rw-r--r--resources/libraries/python/autogen/Regenerator.py127
1 files changed, 100 insertions, 27 deletions
diff --git a/resources/libraries/python/autogen/Regenerator.py b/resources/libraries/python/autogen/Regenerator.py
index 7271fbcf37..b1d0c9e993 100644
--- a/resources/libraries/python/autogen/Regenerator.py
+++ b/resources/libraries/python/autogen/Regenerator.py
@@ -188,31 +188,66 @@ def write_default_files(in_filename, in_prolog, kwargs_list):
_, suite_id = get_iface_and_suite_id(tmp_filename)
testcase = Testcase.default(suite_id)
for nic_name in Constants.NIC_NAME_TO_CODE:
- out_filename = replace_defensively(
+ tmp2_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(
+ tmp2_prolog = replace_defensively(
tmp_prolog, u"Intel-X710", nic_name, 2,
u"NIC name should appear twice (tag and variable).",
in_filename
)
- if out_prolog.count(u"HW_") == 2:
+ if tmp2_prolog.count(u"HW_") == 2:
# TODO CSIT-1481: Crypto HW should be read
# from topology file instead.
if nic_name in Constants.NIC_NAME_TO_CRYPTO_HW:
- out_prolog = replace_defensively(
- out_prolog, u"HW_DH895xcc",
+ tmp2_prolog = replace_defensively(
+ tmp2_prolog, u"HW_DH895xcc",
Constants.NIC_NAME_TO_CRYPTO_HW[nic_name], 1,
u"HW crypto name should appear.", in_filename
)
- iface, suite_id = get_iface_and_suite_id(out_filename)
- with open(out_filename, "wt") as file_out:
- file_out.write(out_prolog)
- add_default_testcases(
- testcase, iface, suite_id, file_out, kwargs_list
+ iface, old_suite_id = get_iface_and_suite_id(tmp2_filename)
+ if u"DPDK" in in_prolog:
+ with open(tmp2_filename, u"wt") as file_out:
+ file_out.write(tmp2_prolog)
+ add_default_testcases(
+ testcase, iface, old_suite_id, file_out, kwargs_list
+ )
+ return
+ for driver in Constants.NIC_NAME_TO_DRIVER[nic_name]:
+ out_filename = replace_defensively(
+ tmp2_filename, old_suite_id,
+ Constants.NIC_DRIVER_TO_SUITE_PREFIX[driver] + old_suite_id,
+ 1, u"Error adding driver prefix.", in_filename
+ )
+ out_prolog = replace_defensively(
+ tmp2_prolog, u"vfio-pci", driver, 1,
+ u"Driver name should appear once.", in_filename
+ )
+ out_prolog = replace_defensively(
+ out_prolog, Constants.NIC_DRIVER_TO_TAG[u"vfio-pci"],
+ Constants.NIC_DRIVER_TO_TAG[driver], 1,
+ u"Driver tag should appear once.", in_filename
+ )
+ out_prolog = replace_defensively(
+ out_prolog, Constants.NIC_DRIVER_TO_PLUGINS[u"vfio-pci"],
+ Constants.NIC_DRIVER_TO_PLUGINS[driver], 1,
+ u"Driver plugin should appear once.", in_filename
+ )
+ out_prolog = replace_defensively(
+ out_prolog, Constants.NIC_DRIVER_TO_SETUP_ARG[u"vfio-pci"],
+ Constants.NIC_DRIVER_TO_SETUP_ARG[driver], 1,
+ u"Perf setup argument should appear once.", in_filename
)
+ iface, suite_id = get_iface_and_suite_id(out_filename)
+ # TODO: Reorder loops so suite_id is finalized sooner.
+ testcase = Testcase.default(suite_id)
+ with open(out_filename, u"wt") as file_out:
+ file_out.write(out_prolog)
+ add_default_testcases(
+ testcase, iface, suite_id, file_out, kwargs_list
+ )
def write_reconf_files(in_filename, in_prolog, kwargs_list):
@@ -232,36 +267,66 @@ def write_reconf_files(in_filename, in_prolog, kwargs_list):
_, suite_id = get_iface_and_suite_id(in_filename)
testcase = Testcase.default(suite_id)
for nic_name in Constants.NIC_NAME_TO_CODE:
- out_filename = replace_defensively(
+ tmp_filename = replace_defensively(
in_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 = replace_defensively(
in_prolog, u"Intel-X710", nic_name, 2,
u"NIC name should appear twice (tag and variable).",
in_filename
)
- if out_prolog.count(u"HW_") == 2:
+ if tmp_prolog.count(u"HW_") == 2:
# TODO CSIT-1481: Crypto HW should be read
# from topology file instead.
- if nic_name in list(Constants.NIC_NAME_TO_CRYPTO_HW.keys()):
- out_prolog = replace_defensively(
- out_prolog, u"HW_DH895xcc",
+ if nic_name in Constants.NIC_NAME_TO_CRYPTO_HW.keys():
+ tmp_prolog = replace_defensively(
+ tmp_prolog, u"HW_DH895xcc",
Constants.NIC_NAME_TO_CRYPTO_HW[nic_name], 1,
u"HW crypto name should appear.", in_filename
)
- iface, suite_id = get_iface_and_suite_id(out_filename)
- with open(out_filename, "wt") as file_out:
- file_out.write(out_prolog)
- add_default_testcases(
- testcase, iface, suite_id, file_out, kwargs_list
+ iface, old_suite_id = get_iface_and_suite_id(tmp_filename)
+ for driver in Constants.NIC_NAME_TO_DRIVER[nic_name]:
+ out_filename = replace_defensively(
+ tmp_filename, old_suite_id,
+ Constants.NIC_DRIVER_TO_SUITE_PREFIX[driver] + old_suite_id,
+ 1, u"Error adding driver prefix.", in_filename
+ )
+ out_prolog = replace_defensively(
+ tmp_prolog, u"vfio-pci", driver, 1,
+ u"Driver name should appear once.", in_filename
)
+ out_prolog = replace_defensively(
+ out_prolog, Constants.NIC_DRIVER_TO_TAG[u"vfio-pci"],
+ Constants.NIC_DRIVER_TO_TAG[driver], 1,
+ u"Driver tag should appear once.", in_filename
+ )
+ out_prolog = replace_defensively(
+ out_prolog, Constants.NIC_DRIVER_TO_PLUGINS[u"vfio-pci"],
+ Constants.NIC_DRIVER_TO_PLUGINS[driver], 1,
+ u"Driver plugin should appear once.", in_filename
+ )
+ out_prolog = replace_defensively(
+ out_prolog, Constants.NIC_DRIVER_TO_SETUP_ARG[u"vfio-pci"],
+ Constants.NIC_DRIVER_TO_SETUP_ARG[driver], 1,
+ u"Perf setup argument should appear once.", in_filename
+ )
+ iface, suite_id = get_iface_and_suite_id(out_filename)
+ # TODO: Reorder loops so suite_id is finalized sooner.
+ testcase = Testcase.default(suite_id)
+ with open(out_filename, u"wt") as file_out:
+ file_out.write(out_prolog)
+ add_default_testcases(
+ testcase, iface, suite_id, file_out, kwargs_list
+ )
def write_tcp_files(in_filename, in_prolog, kwargs_list):
"""Using given filename and prolog, write all generated tcp suites.
+ TODO: Suport drivers.
+
: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_default_testcase.
@@ -283,7 +348,7 @@ def write_tcp_files(in_filename, in_prolog, kwargs_list):
u"NIC name should appear twice (tag and variable).",
in_filename
)
- with open(out_filename, "wt") as file_out:
+ with open(out_filename, u"wt") as file_out:
file_out.write(out_prolog)
add_tcp_testcases(testcase, file_out, kwargs_list)
@@ -303,9 +368,9 @@ class Regenerator:
"""Regenerate files matching glob pattern based on arguments.
In the current working directory, find all files matching
- the glob pattern. Use testcase template according to suffix
- to regenerate test cases, auto-numbering them,
- taking arguments from list.
+ the glob pattern. Use testcase template to regenerate test cases
+ according to suffix, governed by protocol, autonumbering them.
+ Also generate suites for other NICs and drivers.
Log-like prints are emitted to sys.stderr.
@@ -336,6 +401,9 @@ class Regenerator:
tcp_kwargs_list = [
{u"phy_cores": i, u"frame_size": 0} for i in (1, 2, 4)
]
+ forbidden = [
+ v for v in Constants.NIC_DRIVER_TO_SUITE_PREFIX.values() if v
+ ]
for in_filename in glob(pattern):
if not self.quiet:
print(
@@ -346,9 +414,14 @@ class Regenerator:
raise RuntimeError(
f"Error in {in_filename}: non-primary NIC found."
)
- with open(in_filename, "rt") as file_in:
+ for prefix in forbidden:
+ if prefix in in_filename:
+ raise RuntimeError(
+ f"Error in {in_filename}: non-primary driver found."
+ )
+ with open(in_filename, u"rt") as file_in:
in_prolog = u"".join(
- file_in.read().partition("*** Test Cases ***")[:-1]
+ file_in.read().partition(u"*** Test Cases ***")[:-1]
)
if in_filename.endswith(u"-ndrpdr.robot"):
write_default_files(in_filename, in_prolog, default_kwargs_list)