Skip to content

Commit 6c432b5

Browse files
glemcorostedt
authored andcommitted
verification/dot2k: Fix template directory detection
dot2k can be run as installed (e.g. make install) or from the kernel tree. In the former case it looks for templates in a known location; in the latter, the PWD has to be `<linux>/tools/verification` to properly import python modules. The current version looks for the template in a wrong directory in this latter case. This patch adjusts the directory where dot2k looks for templates if run from the kernel tree (i.e. not installed). Additionally we fix a few simple pylint warnings in boolean expressions. Cc: Juri Lelli <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: John Kacur <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Gabriele Monaco <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 4bbf902 commit 6c432b5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tools/verification/dot2/dot2k.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414

1515
class dot2k(Dot2c):
1616
monitor_types = { "global" : 1, "per_cpu" : 2, "per_task" : 3 }
17-
monitor_templates_dir = "dot2k/rv_templates/"
17+
monitor_templates_dir = "dot2/dot2k_templates/"
1818
monitor_type = "per_cpu"
1919

2020
def __init__(self, file_path, MonitorType):
2121
super().__init__(file_path)
2222

2323
self.monitor_type = self.monitor_types.get(MonitorType)
24-
if self.monitor_type == None:
24+
if self.monitor_type is None:
2525
raise Exception("Unknown monitor type: %s" % MonitorType)
2626

2727
self.monitor_type = MonitorType
@@ -31,19 +31,19 @@ def __init__(self, file_path, MonitorType):
3131

3232
def __fill_rv_templates_dir(self):
3333

34-
if os.path.exists(self.monitor_templates_dir) == True:
34+
if os.path.exists(self.monitor_templates_dir):
3535
return
3636

3737
if platform.system() != "Linux":
3838
raise Exception("I can only run on Linux.")
3939

4040
kernel_path = "/lib/modules/%s/build/tools/verification/dot2/dot2k_templates/" % (platform.release())
4141

42-
if os.path.exists(kernel_path) == True:
42+
if os.path.exists(kernel_path):
4343
self.monitor_templates_dir = kernel_path
4444
return
4545

46-
if os.path.exists("/usr/share/dot2/dot2k_templates/") == True:
46+
if os.path.exists("/usr/share/dot2/dot2k_templates/"):
4747
self.monitor_templates_dir = "/usr/share/dot2/dot2k_templates/"
4848
return
4949

@@ -98,7 +98,7 @@ def fill_tracepoint_detach_helper(self):
9898
def fill_main_c(self):
9999
main_c = self.main_c
100100
min_type = self.get_minimun_type()
101-
nr_events = self.events.__len__()
101+
nr_events = len(self.events)
102102
tracepoint_handlers = self.fill_tracepoint_handlers_skel()
103103
tracepoint_attach = self.fill_tracepoint_attach_probe()
104104
tracepoint_detach = self.fill_tracepoint_detach_helper()
@@ -160,8 +160,8 @@ def __create_file(self, file_name, content):
160160

161161
def __get_main_name(self):
162162
path = "%s/%s" % (self.name, "main.c")
163-
if os.path.exists(path) == False:
164-
return "main.c"
163+
if not os.path.exists(path):
164+
return "main.c"
165165
return "__main.c"
166166

167167
def print_files(self):

0 commit comments

Comments
 (0)