aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools/vppapigen
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2020-09-15 10:53:34 +0200
committerDave Barach <openvpp@barachs.net>2020-09-18 15:24:52 +0000
commit3d81267945a732753b0dbd0a83a50ab0625b448a (patch)
treec00b5e6a5e798cbb29c9c450eb37d43f9303cb85 /src/tools/vppapigen
parent34262d4d56295b0872ad4e9a4a4791953f3fa444 (diff)
vat: add infrastructure to align vnet test code and plugin test code
Split vat/api_format.c also for VNET features. Use auto-generated VAT test code and support dynamic message ID allocation as for plugins. The arp and geneve features as Guinea pigs. Type: improvement Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I461591496766bdf10c5f950fd30f1a0ae05909da Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/tools/vppapigen')
-rw-r--r--src/tools/vppapigen/vppapigen_c.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/tools/vppapigen/vppapigen_c.py b/src/tools/vppapigen/vppapigen_c.py
index 59dbbc99fb6..020a880c868 100644
--- a/src/tools/vppapigen/vppapigen_c.py
+++ b/src/tools/vppapigen/vppapigen_c.py
@@ -512,7 +512,7 @@ def generate_include_enum(s, module, stream):
write('typedef enum {\n')
for t in s['Define']:
write(' VL_API_{},\n'.format(t.name.upper()))
- write(' VL_MSG_FIRST_AVAILABLE\n')
+ write(' VL_MSG_{}_LAST\n'.format(module.upper()))
write('}} vl_api_{}_enum_t;\n'.format(module))
@@ -625,8 +625,8 @@ def generate_c_boilerplate(services, defines, file_crc, module, stream):
write('setup_message_id_table (void) {\n')
write(' api_main_t *am = my_api_main;\n')
write(' vl_msg_api_msg_config_t c;\n')
- write(' u16 msg_id_base = vl_msg_api_get_msg_ids ("{}_{crc:08x}", VL_MSG_FIRST_AVAILABLE);\n'
- .format(module, crc=file_crc))
+ write(' u16 msg_id_base = vl_msg_api_get_msg_ids ("{}_{crc:08x}", VL_MSG_{m}_LAST);\n'
+ .format(module, crc=file_crc, m=module.upper()))
for d in defines:
@@ -662,7 +662,7 @@ def generate_c_boilerplate(services, defines, file_crc, module, stream):
write('}\n')
-def generate_c_test_plugin_boilerplate(services, defines, file_crc, module, stream):
+def generate_c_test_boilerplate(services, defines, file_crc, module, plugin, stream):
write = stream.write
define_hash = {d.name:d for d in defines}
@@ -742,8 +742,10 @@ def generate_c_test_plugin_boilerplate(services, defines, file_crc, module, stre
.format(n=e, ID=e.upper()))
write('}\n')
-
- write('clib_error_t * vat_plugin_register (vat_main_t *vam)\n')
+ if plugin:
+ write('clib_error_t * vat_plugin_register (vat_main_t *vam)\n')
+ else:
+ write('clib_error_t * vat_{}_plugin_register (vat_main_t *vam)\n'.format(module))
write('{\n')
write(' {n}_test_main_t * mainp = &{n}_test_main;\n'.format(n=module))
write(' mainp->vat_main = vam;\n')
@@ -758,7 +760,6 @@ def generate_c_test_plugin_boilerplate(services, defines, file_crc, module, stre
write(' return 0;\n')
write('}\n')
-
#
# Plugin entry point
#
@@ -803,10 +804,10 @@ def run(args, input_filename, s):
st.close()
# Generate separate C test file
- # This is only supported for plugins at the moment
st = StringIO()
- generate_c_test_plugin_boilerplate(s['Service'], s['Define'], s['file_crc'],
- modulename, st)
+ plugin = True if 'plugin' in input_filename else False
+ generate_c_test_boilerplate(s['Service'], s['Define'], s['file_crc'],
+ modulename, plugin, st)
with open (filename_c_test, 'w') as fd:
st.seek (0)
shutil.copyfileobj(st, fd)