Skip to contentSkip to conversation

verification/rvgen: Use .old instead of .bak for kunit backup files

PATCH In review Gabriele Monaco 4 participants 4 messages Aug 24 – Aug 25

Subsystems (2)
lore
Share & tools
lore

Gabriele Monaco

author maintainer
#0 lore raw

PATCH 1/1 verification/rvgen: Use .old instead of .bak for kunit backup files

The rvgen kunit command generates .bak backup files and these can be checked in for selftests (make check). Clean targets like make disclean remove such files, leaving the tree dirty.

Switch to .old to preserve a clean tree after make disclean.

Fixes 7b6246294eb0 ("verification/rvgen: Add selftests for rvgen kunit")
---
 tools/verification/rvgen/rvgen/kunit.py                         | 2 +-
 .../{test_bak_kunit_kunit.c.bak => test_bak_kunit_kunit.c.old}  | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename tools/verification/rvgen/tests/golden/test_bak_kunit/{test_bak_kunit_kunit.c.bak => test_bak_kunit_kunit.c.old} (100%)
tools/verification/rvgen/rvgen/kunit.py +1 -1
index ed2082d7d3bc..85973f918c9b 100644
@@ -173,7 +173,7 @@ EXPORT_SYMBOL_IF_KUNIT({struct_name});
             for path in (header_file_path, kunit_c_file_path):
                 if path.exists():
                     try:
-                        path.rename(path.with_suffix(path.suffix + ".bak"))
+                        path.rename(path.with_suffix(path.suffix + ".old"))
                     except OSError as e:
                         raise KUnitError(f"Error backing up file {path}: {e}") from e
 
tools/verification/rvgen/tests/golden/test_bak_kunit/test_bak_kunit_kunit.c.old renamed from tools/verification/rvgen/tests/golden/test_bak_kunit/test_bak_kunit_kunit.c.bak +0 -0
similarity index 100%
rename from tools/verification/rvgen/tests/golden/test_bak_kunit/test_bak_kunit_kunit.c.bak
rename to tools/verification/rvgen/tests/golden/test_bak_kunit/test_bak_kunit_kunit.c.old

base-commit: 0a0d1d55dad570724bf8c7ea83409639cfb4be9b

Signature · 1 line
2.55.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The `rvgen kunit` tool generates `.old` backup files which are not cleaned up by `make…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The rvgen kunit tool generates .old backup files which are not cleaned up by make distclean, polluting the user's working directory. --

--- Patch [1]: [PATCH] verification/rvgen: Use .old instead of .bak for kunit backup files --- commit 293b444e4dfea5692931faee1bc9c58a549085d8
Author: Gabriele Monaco <[email protected]>

verification/rvgen: Use .old instead of .bak for kunit backup files

The rvgen kunit command generates .bak backup files and these can be checked in for selftests (make check). Clean targets like make disclean remove such files, leaving the tree dirty. Switch to .old to preserve a clean tree after make disclean.

Quoted 4 lines
tools/verification/rvgen/rvgen/kunit.py +0 -0
index ed2082d7d3bc4..85973f918c9b5 100644

[ ... ]

tools/verification/rvgen/rvgen/kunit.py EXPORT_SYMBOL_IF_KUNIT({struct_name}); · line 176

Quoted 6 lines
tools/verification/rvgen/rvgen/kunit.py +1 -1
@@ -173,7 +173,7 @@ EXPORT_SYMBOL_IF_KUNIT({struct_name});
             for path in (header_file_path, kunit_c_file_path):
                 if path.exists():
                     try:
-                        path.rename(path.with_suffix(path.suffix + ".bak"))
+                        path.rename(path.with_suffix(path.suffix + ".old"))

[Severity: Medium]
Will this regression leave users' working directories polluted with .old backup files that aren't cleaned up by the top-level make distclean target?

The kernel's global Makefile explicitly cleans *.bak files during distclean, but ignores *.old files.

When a user runs rvgen kunit in a directory with existing kunit files and accepts the backup prompt, print_files() will generate these .old files. Since they are no longer .bak files, is it expected that they will persist after running make distclean?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Tested-by on v1 1/1
#2 lore raw
In reply to Gabriele Monaco
Quoted 10 lines · Gabriele Monaco

The rvgen kunit command generates .bak backup files and these can be checked in for selftests (make check). Clean targets like make disclean remove such files, leaving the tree dirty.

Switch to .old to preserve a clean tree after make disclean.

Fixes 7b6246294eb0 ("verification/rvgen: Add selftests for rvgen kunit")

Thanks for the quick fix!
The working tree now remains clean after running make distclean.

Regards,
Kuan-Wei

Quoted 28 lines
---
 tools/verification/rvgen/rvgen/kunit.py                         | 2 +-
 .../{test_bak_kunit_kunit.c.bak => test_bak_kunit_kunit.c.old}  | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename tools/verification/rvgen/tests/golden/test_bak_kunit/{test_bak_kunit_kunit.c.bak => test_bak_kunit_kunit.c.old} (100%)
tools/verification/rvgen/rvgen/kunit.py +1 -1
index ed2082d7d3bc..85973f918c9b 100644
@@ -173,7 +173,7 @@ EXPORT_SYMBOL_IF_KUNIT({struct_name});
             for path in (header_file_path, kunit_c_file_path):
                 if path.exists():
                     try:
-                        path.rename(path.with_suffix(path.suffix + ".bak"))
+                        path.rename(path.with_suffix(path.suffix + ".old"))
                     except OSError as e:
                         raise KUnitError(f"Error backing up file {path}: {e}") from e
 
tools/verification/rvgen/tests/golden/test_bak_kunit/test_bak_kunit_kunit.c.old renamed from tools/verification/rvgen/tests/golden/test_bak_kunit/test_bak_kunit_kunit.c.bak +0 -0
similarity index 100%
rename from tools/verification/rvgen/tests/golden/test_bak_kunit/test_bak_kunit_kunit.c.bak
rename to tools/verification/rvgen/tests/golden/test_bak_kunit/test_bak_kunit_kunit.c.old

base-commit: 0a0d1d55dad570724bf8c7ea83409639cfb4be9b

Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#3 lore raw
In reply to Gabriele Monaco
Quoted 10 lines · Gabriele Monaco

The rvgen kunit command generates .bak backup files and these can be checked in for selftests (make check). Clean targets like make disclean remove such files, leaving the tree dirty.

Switch to .old to preserve a clean tree after make disclean.

Fixes 7b6246294eb0 ("verification/rvgen: Add selftests for rvgen kunit")

We should send it to v7.3 as soon as possible, to avoid further complains.

Nam