power_management: rewrite runpwtests04.sh in C
PATCH v5 1/1 power_management: rewrite runpwtests04.sh in C
As part of the ongoing effort to reduce shell-based tests in LTP, rewrite the cpuidle sysfs smoke test in C using the modern LTP test API.
The new implementation preserves the original test semantics while removing shell dependencies.
---
Changes in v5:
- Remove runpwtests04.sh
- Link to v4: https://lore.kernel.org/ltp/[email protected]
Changes in v4:
- Fix patch application failure reported by CI.
- Link to v3: https://lore.kernel.org/ltp/[email protected]
Changes in v3:
- Replace SAFE_OPEN() with open() to convert ENOENT to TCONF.
- Add a cleanup function.
- Link to v2: https://lore.kernel.org/ltp/[email protected]
Changes in v2:
- Update runtest entry
- Clarify commit message
- Link to v1: https://lore.kernel.org/ltp/[email protected]
--- runtest/power_management_tests | 2 +- testcases/kernel/power_management/.gitignore | 1 + testcases/kernel/power_management/pwtests01.c | 67 +++++++++++++++++++ .../kernel/power_management/runpwtests04.sh | 58 ---------------- 4 files changed, 69 insertions(+), 59 deletions(-) create mode 100644 testcases/kernel/power_management/pwtests01.c delete mode 100755 testcases/kernel/power_management/runpwtests04.sh
runtest/power_management_tests +1 -1
@@ -1,5 +1,5 @@ #POWER_MANAGEMENT high_freq_hwp_cap_cppc high_freq_hwp_cap_cppc +pwtests01 pwtests01 runpwtests03 runpwtests03.sh -runpwtests04 runpwtests04.sh runpwtests06 runpwtests06.sh
testcases/kernel/power_management/.gitignore +1 -0
@@ -1 +1,2 @@ high_freq_hwp_cap_cppc +pwtests01
testcases/kernel/power_management/pwtests01.c new file +67 -0
67 lines not on this page · raw message
testcases/kernel/power_management/runpwtests04.sh deleted +0 -58
58 lines not on this page · raw message
--
2.43.0
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Jinseok,
Quoted 4 lines · Jinseok Kim
power_management: rewriterunpwtests04.shin CThe new implementation preserves the original test semantics while removing shell dependencies.
This claim is inaccurate in at least two ways:
1. The original shell script calls check_arch from pm_include.sh, which gates the test to x86/x86_64 and reports TCONF on other architectures. The new C test drops this gate entirely, relying on runtime sysfs presence instead. That is arguably better (runtime detection over compile-time assumptions), but it is a semantic change that should be mentioned.
2. When /sys/devices/system/cpu/cpuidle does not exist, the original script skips the loop and falls through to PASS. The new test calls tst_brk(TCONF) in setup. Again an improvement, but not "preserved semantics".
Consider rewording the commit body to acknowledge these intentional behavioral changes rather than claiming equivalence.
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Jinseok,
I can't understand the utility of this test honestly. We are checking if an obsolete ABI [1] such as /sys/devices/system/cpu/cpuidle/current_governor_ro is actually readable. That's ok, it's still there at least. Also, we are not checking the return value or if the file is not writable.
We also have other ABI [2] to test.
Said so, it would be better to _at least_ verify read/write and return value of enough ABI inside /sys/devices/system/cpu/cpuidle/ which are not subject to drivers behaviours. In particular:
- available_governors (ro) — lists registered idle governors
- current_driver (ro) — shows the active cpuidle driver name
- current_governor (rw) — shows/sets the active idle governor
- current_governor_ro (ro) — read-only view of current governor
testcases/kernel/power_management/pwtests01.c line 53
Quoted 4 lines
testcases/kernel/power_management/pwtests01.c new file +4
-0+static void setup (void ) +{ +if (access (CPUIDLE_PATH ,R_OK )) +tst_brk (TCONF ,"%s is not available" ,CPUIDLE_PATH );
Instead of this check we should use .save_restore with TST_SR_TCONF.
[1] https://www.kernel.org/doc/html/latest/admin-guide/abi-obsolete-files.html#abi-file-obsolete-sysfs-cpuidle
[2] https://www.kernel.org/doc/html/latest/admin-guide/abi-testing.html#abi-sys-devices-system-cpu-cpuidle-available-governors
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp