* [PATCH] rteval: Changed logic for when stress-ng is absent
@ 2026-11-06 19:57 Sana Sharma
2026-11-09 11:56 ` Ahmed S. Darwish
0 siblings, 1 reply; 2+ messages in thread
From: Sana Sharma @ 2026-11-06 19:57 UTC (permalink / raw)
To: linux-rt-users; +Cc: jkacur
Changed the failure in case stressng it not found from a sys exit
to return an empty list so as to make it more graceful
Signed-off-by: Sana Sharma <sansshar@redhat.com>
---
rteval/modules/loads/stressng.py | 4 ++--
tests/test_stressng.py | 7 ++-----
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/rteval/modules/loads/stressng.py b/rteval/modules/loads/stressng.py
index ec59bf9..ec812dc 100644
--- a/rteval/modules/loads/stressng.py
+++ b/rteval/modules/loads/stressng.py
@@ -78,10 +78,10 @@ def get_valid_stressors():
return result.stdout.strip().split()
except FileNotFoundError:
print("stress-ng is not installed. Please install the stress-ng package.")
- sys.exit(1)
+ return []
except subprocess.CalledProcessError as e:
print(f"Failed to query stress-ng stressors: {e}")
- sys.exit(1)
+ return []
class Stressng(CommandLineLoad):
" This class creates a load module that runs stress-ng "
diff --git a/tests/test_stressng.py b/tests/test_stressng.py
index 090822a..94e7cbe 100644
--- a/tests/test_stressng.py
+++ b/tests/test_stressng.py
@@ -42,16 +42,13 @@ class TestGetValidStressors(unittest.TestCase):
side_effect=FileNotFoundError)
def test_not_installed_exits(self, _):
"""Test when stress-ng is not installed"""
- with self.assertRaises(SystemExit) as cm:
- stressng.get_valid_stressors()
- self.assertEqual(cm.exception.code, 1)
+ self.assertEqual(stressng.get_valid_stressors(), [])
@patch('rteval.modules.loads.stressng.subprocess.run',
side_effect=subprocess.CalledProcessError(1, 'stress-ng'))
def test_query_failure_exits(self, _):
"""Test when the stress-ng query fails"""
- with self.assertRaises(SystemExit):
- stressng.get_valid_stressors()
+ self.assertEqual(stressng.get_valid_stressors(), [])
class TestValidateStressor(unittest.TestCase):
"""Test suite for the function validate_stressor"""
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-09 11:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06 19:57 [PATCH] rteval: Changed logic for when stress-ng is absent Sana Sharma
2026-11-09 11:56 ` Ahmed S. Darwish
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.