From: Gabriele Monaco <gmonaco@redhat.com>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
Gabriele Monaco <gmonaco@redhat.com>
Cc: Nam Cao <namcao@linutronix.de>,
Thomas Weissschuh <thomas.weissschuh@linutronix.de>,
Tomas Glozar <tglozar@redhat.com>, John Kacur <jkacur@redhat.com>,
Wen Yang <wen.yang@linux.dev>
Subject: [PATCH v4 04/17] verification/rvgen: Use pathlib instead of os.path
Date: Fri, 17 Jul 2026 17:46:25 +0200 [thread overview]
Message-ID: <20260717154638.220789-5-gmonaco@redhat.com> (raw)
In-Reply-To: <20260717154638.220789-1-gmonaco@redhat.com>
Migrate to the newer patlib library, bundled with python since 3.4 to
increase readability over using os.path.
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
---
tools/verification/rvgen/rvgen/generator.py | 22 +++++++++------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/tools/verification/rvgen/rvgen/generator.py b/tools/verification/rvgen/rvgen/generator.py
index 1c20f7d1905c..f1b37d34b1e9 100644
--- a/tools/verification/rvgen/rvgen/generator.py
+++ b/tools/verification/rvgen/rvgen/generator.py
@@ -6,7 +6,6 @@
# Abstract class for generating kernel runtime verification monitors from specification file
import platform
-import os
from pathlib import Path
@@ -17,7 +16,7 @@ class RVGenerator:
self.name = extra_params.get("model_name")
self.parent = extra_params.get("parent")
self.abs_template_dir = \
- os.path.join(os.path.dirname(__file__), "templates", self.template_dir)
+ Path(__file__).resolve().parent / "templates" / self.template_dir
self.main_c = self._read_template_file("main.c")
self.kconfig = self._read_template_file("Kconfig")
self.description = extra_params.get("description", self.name) or "auto-generated"
@@ -60,12 +59,12 @@ class RVGenerator:
def _read_template_file(self, file):
try:
- path = os.path.join(self.abs_template_dir, file)
+ path = self.abs_template_dir / file
return self._read_file(path)
except OSError:
# Specific template file not found. Try the generic template file in the template/
# directory, which is one level up
- path = os.path.join(self.abs_template_dir, "..", file)
+ path = self.abs_template_dir.parent / file
return self._read_file(path)
def fill_parent(self):
@@ -136,7 +135,7 @@ class RVGenerator:
def _patch_file(self, file, marker, line):
assert self.auto_patch
- file_to_patch = os.path.join(self.rv_dir, file)
+ file_to_patch = Path(self.rv_dir) / file
content = self._read_file(file_to_patch)
content = content.replace(marker, line + "\n" + marker)
self.__write_file(file_to_patch, content)
@@ -190,22 +189,19 @@ obj-$(CONFIG_RV_MON_{name_up}) += monitors/{name}/{name}.o
return f" - Move {self.name}/ to the kernel's monitor directory ({self.rv_dir}/monitors)"
def __create_directory(self):
- path = self.name
+ path = Path(self.name)
if self.auto_patch:
- path = os.path.join(self.rv_dir, "monitors", path)
- try:
- os.mkdir(path)
- except FileExistsError:
- return
+ path = Path(self.rv_dir) / "monitors" / path
+ path.mkdir(exist_ok=True)
def __write_file(self, file_name, content):
with open(file_name, 'w') as file:
file.write(content)
def _create_file(self, file_name, content):
- path = f"{self.name}/{file_name}"
+ path = Path(self.name) / file_name
if self.auto_patch:
- path = os.path.join(self.rv_dir, "monitors", path)
+ path = Path(self.rv_dir) / "monitors" / self.name / file_name
self.__write_file(path, content)
def print_files(self):
--
2.55.0
next prev parent reply other threads:[~2026-07-17 15:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 15:46 [PATCH v4 00/17] rv: Add selftests to tools and KUnit tests Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 01/17] rv: Use generic rv_this for the rv_monitor variable in LTL Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 02/17] tools/rv: Fix exit status when monitor execution fails Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 03/17] verification/rvgen: Improve rv_dir discovery in RVGenerator Gabriele Monaco
2026-07-17 15:46 ` Gabriele Monaco [this message]
2026-07-17 15:46 ` [PATCH v4 05/17] verification/rvgen: Improve consistency in template files Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 06/17] tools/rv: Add selftests Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 07/17] verification/rvgen: Add golden and spec folders for tests Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 08/17] verification/rvgen: Add selftests Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 09/17] verification/rvgen: Add the rvgen kunit subcommand Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 10/17] verification/rvgen: Add selftests for rvgen kunit Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 11/17] rv: Export task monitor slot and react symbols Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 12/17] rv: Add KUnit tests for some DA/HA monitors Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 13/17] rv: Add KUnit stub for current Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 14/17] rv: Add KUnit tests for some LTL monitors Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 15/17] selftests/verification: Fix wrong errexit assumption Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 16/17] selftests/verification: Rearrange the wwnr_printk test Gabriele Monaco
2026-07-17 15:46 ` [PATCH v4 17/17] selftests/verification: Add selftests for deadline and stall monitors Gabriele Monaco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260717154638.220789-5-gmonaco@redhat.com \
--to=gmonaco@redhat.com \
--cc=jkacur@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=namcao@linutronix.de \
--cc=rostedt@goodmis.org \
--cc=tglozar@redhat.com \
--cc=thomas.weissschuh@linutronix.de \
--cc=wen.yang@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox