Skip to content

Commit

Permalink
Add LIT parameter priority (#5032)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
  • Loading branch information
CaseyCarter and StephanTLavavej authored Oct 24, 2024
1 parent 7b199b2 commit 27973ad
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/utils/stl/test/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ def pretty(self, config, litParams):
return 'exclude run.pl tags {}'.format(str(self._taglist))


def beNice(prio: str) -> list[ConfigAction]:
"""
Set the process priority to run tests with.
"""
try:
import psutil
priority_map = {
'normal': psutil.NORMAL_PRIORITY_CLASS,
'low': psutil.BELOW_NORMAL_PRIORITY_CLASS,
'idle': psutil.IDLE_PRIORITY_CLASS,
}
psutil.Process().nice(priority_map[prio])
except ImportError:
import sys
print(f'NOTE: Module "psutil" is not installed, so the priority setting "{prio}" has no effect.', file=sys.stderr)
return []


def getDefaultParameters(config, litConfig):
DEFAULT_PARAMETERS = [
Parameter(name='long_tests', choices=[True, False], type=bool, default=True,
Expand All @@ -47,6 +65,10 @@ def getDefaultParameters(config, litConfig):
Parameter(name="notags", type=list, default=[],
help="Comma-separated list of run.pl tags to exclude tests",
actions=lambda tags: [AddRunPLNotags(tags)]),
Parameter(name="priority", choices=["idle", "low", "normal"], default="idle", type=str,
help='Process priority to run tests with: "idle" (the default), "low", or "normal". ' +
'Module "psutil" must be installed for this to have any effect.',
actions=lambda prio: beNice(prio)),
]

return DEFAULT_PARAMETERS

0 comments on commit 27973ad

Please sign in to comment.