power_management: rewrite runpwtests04.sh in C
PATCH v7 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 v7:
- Replace the array-based test with dedicated helper functions.
- Use TST_EXP_FAIL2() for the invalid governor test.
- Clarify the test description.
- Link to v6: https://lore.kernel.org/ltp/[email protected]
Changes in v6:
- Expand test coverage to include 4 core cpuidle sysfs ABIs.
- Add verification of read() system call return values (bytes read).
- Add negative testing for 'current_governor' to verify EINVAL return value.
- Replace manual access() check with LTP .save_restore.
- Link to v5: https://lore.kernel.org/ltp/[email protected]
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/cpuidle01.c | 107 ++++++++++++++++++ .../kernel/power_management/runpwtests04.sh | 58 ---------- 4 files changed, 109 insertions(+), 59 deletions(-) create mode 100644 testcases/kernel/power_management/cpuidle01.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 +cpuidle01 cpuidle01 runpwtests03 runpwtests03.sh -runpwtests04 runpwtests04.sh runpwtests06 runpwtests06.sh
testcases/kernel/power_management/.gitignore +1 -0
@@ -1 +1,2 @@ high_freq_hwp_cap_cppc +cpuidle01
testcases/kernel/power_management/cpuidle01.c new file +107 -0
107 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.
The C version does more than the shell test: it also reads available_governors and current_governor and adds an invalid-governor write-rejection check, whereas runpwtests04.sh only read current_governor_ro and current_driver. Could the commit message be reworded to reflect the added coverage rather than "preserves the original test semantics"?
testcases/kernel/power_management/.gitignore line 2
Quoted 4 lines
+++ b/testcases/kernel/power_management/.gitignore
testcases/kernel/power_management/.gitignore +1
-0@@ -1 +1,2 @@ high_freq_hwp_cap_cppc +cpuidle01
Should the entries stay sorted? Appending cpuidle01 after high_freq_hwp_cap_cppc leaves the file out of alphabetical order (c before h). Leaf-directory entries are also normally anchored with a leading '/' (e.g. /cpuidle01), though the existing entry is unanchored too.
testcases/kernel/power_management/cpuidle01.c line 107
Quoted 8 lines
testcases/kernel/power_management/cpuidle01.c new file +8
-0+static struct tst_test test = { + .test_all = run, + .needs_root =1 , + .save_restore = (const struct tst_path_val []) { + {CPUIDLE_PATH "/current_governor" ,NULL ,TST_SR_TCONF }, + {} + }, +};
TST_SR_TCONF expands to TST_SR_TCONF_MISSING | TST_SR_TCONF_RO, so tst_sys_conf_save() ends the whole test with TCONF at setup when current_governor is missing or read-only. On a system that exposes only current_governor_ro, the readable checks for current_governor_ro and current_driver (which the shell test still ran) would be skipped entirely. Is gating the full test on current_governor intended, or would TST_SR_SKIP / a per-file check keep the other checks running?
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