* [PATCH v5] rteval: Adding stressor validation for stress-ng
@ 2026-08-26 16:48 Sana Sharma
2026-08-26 17:08 ` John Kacur
0 siblings, 1 reply; 2+ messages in thread
From: Sana Sharma @ 2026-08-26 16:48 UTC (permalink / raw)
To: linux-rt-users; +Cc: jkacur
Previously stressor names were unvalidated.
This has been changed so that now if the user inputs an invalid
stressor name, they get an error message telling them to check
"stress-ng --stressors". The list of stressors is created dynamically
during "WorkloadPrepare()"
Added error handling for when stress-ng is not installed
Signed-off-by: Sana Sharma <sansshar@redhat.com>
---
rteval/modules/loads/stressng.py | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/rteval/modules/loads/stressng.py b/rteval/modules/loads/stressng.py
index 32e2dbd..df4685e 100644
--- a/rteval/modules/loads/stressng.py
+++ b/rteval/modules/loads/stressng.py
@@ -5,11 +5,33 @@ import os.path
import time
import subprocess
import signal
+import sys
from rteval.modules.loads import CommandLineLoad
from rteval.Log import Log
from rteval.systopology import SysTopology
from rteval.cpulist_utils import CpuList
+def get_valid_stressors():
+ """Query stress-ng for list of valid stressor names."""
+ try:
+ result = subprocess.run(['stress-ng', '--stressors'],
+ capture_output=True, text=True, check=True)
+ return result.stdout.strip().split()
+ except FileNotFoundError:
+ print("stress-ng is not installed. Please install the stress-ng package.")
+ sys.exit(1)
+ except subprocess.CalledProcessError as e:
+ print(f"Failed to query stress-ng stressors: {e}")
+ sys.exit(1)
+
+def validate_stressor(stressor_name):
+ """Validate a single stressor name against stress-ng's available stressors."""
+ valid = get_valid_stressors()
+ if stressor_name not in valid:
+ print(f"Invalid stress-ng stressor: '{stressor_name}'. "
+ f"Run 'stress-ng --stressors' to see valid options.")
+ sys.exit(1)
+
class Stressng(CommandLineLoad):
" This class creates a load module that runs stress-ng "
def __init__(self, config, logger):
@@ -51,6 +73,7 @@ class Stressng(CommandLineLoad):
# stress-ng is only run if the user specifies an stressor
self.args = ['stress-ng']
+ validate_stressor(self.cfg.stressor)
self.args.append(f'--{str(self.cfg.stressor)}')
if self.cfg.workers is not None:
self.args.append(self.cfg.workers) #default is 0
--
2.54.0
--
Sana Sharma <sansshar@redhat.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v5] rteval: Adding stressor validation for stress-ng
2026-08-26 16:48 [PATCH v5] rteval: Adding stressor validation for stress-ng Sana Sharma
@ 2026-08-26 17:08 ` John Kacur
0 siblings, 0 replies; 2+ messages in thread
From: John Kacur @ 2026-08-26 17:08 UTC (permalink / raw)
To: Sana Sharma; +Cc: linux-rt-users, jkacur
On Wed, 26 Aug 2026, Sana Sharma wrote:
> Previously stressor names were unvalidated.
> This has been changed so that now if the user inputs an invalid
> stressor name, they get an error message telling them to check
> "stress-ng --stressors". The list of stressors is created dynamically
> during "WorkloadPrepare()"
>
> Added error handling for when stress-ng is not installed
>
> Signed-off-by: Sana Sharma <sansshar@redhat.com>
> ---
> rteval/modules/loads/stressng.py | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
[snip]
Signed-off-by: John Kacur <jkacur@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-26 17:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-26 16:48 [PATCH v5] rteval: Adding stressor validation for stress-ng Sana Sharma
2026-08-26 17:08 ` John Kacur
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.