verification/dot2k: Add support for name and description options

The dot2k command includes options to set a model name with -n and a
description with -D, however those are not used in practice.

This patch allows to specify a custom model name (by default the name of
the dot file without extension) and a description which overrides the
one in the C file.

Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: John Kacur <jkacur@redhat.com>
Link: https://lore.kernel.org/20241227144752.362911-5-gmonaco@redhat.com
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
Gabriele Monaco
2024-12-27 15:47:48 +01:00
committed by Steven Rostedt (Google)
parent 91f3407e13
commit 64b3e5f0d4
5 changed files with 12 additions and 14 deletions

View File

@@ -17,17 +17,18 @@ class dot2k(Dot2c):
monitor_templates_dir = "dot2/dot2k_templates/"
monitor_type = "per_cpu"
def __init__(self, file_path, MonitorType):
super().__init__(file_path)
def __init__(self, file_path, MonitorType, extra_params={}):
super().__init__(file_path, extra_params.get("model_name"))
self.monitor_type = self.monitor_types.get(MonitorType)
if self.monitor_type is None:
raise Exception("Unknown monitor type: %s" % MonitorType)
raise ValueError("Unknown monitor type: %s" % MonitorType)
self.monitor_type = MonitorType
self.__fill_rv_templates_dir()
self.main_c = self.__open_file(self.monitor_templates_dir + "main.c")
self.enum_suffix = "_%s" % self.name
self.description = extra_params.get("description", self.name) or "auto-generated"
def __fill_rv_templates_dir(self):
@@ -114,6 +115,7 @@ class dot2k(Dot2c):
main_c = main_c.replace("%%TRACEPOINT_HANDLERS_SKEL%%", tracepoint_handlers)
main_c = main_c.replace("%%TRACEPOINT_ATTACH%%", tracepoint_attach)
main_c = main_c.replace("%%TRACEPOINT_DETACH%%", tracepoint_detach)
main_c = main_c.replace("%%DESCRIPTION%%", self.description)
return main_c