Skip to content
Snippets Groups Projects
Commit 70b5d773 authored by Florent Thiery's avatar Florent Thiery
Browse files

support single user test execution, refs #21724

parent 7f7aca77
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ def strip_colors(text):
class Tester():
USAGE = '''%s [-e] [-f] [-b] [-d] [-h]
USAGE = '''%s [-e] [-f] [-b] [-d] [-h] [msuser]
-e: send email with report.
-f: send email with report only if at least one test failed.
-b: run only basic tests (exclude mediaserver tests).
......@@ -55,15 +55,23 @@ class Tester():
log('\033[96m- UbiCast applications tester -\033[0m')
log('\033[96m-------------------------------\033[0m')
args = list(args)
msuser = None
# Check if help is required
if '-h' in args:
log('USAGE: ' + self.USAGE)
sys.exit(0)
for arg in args:
if arg not in self.VALID_ARGS:
for index, arg in enumerate(args):
if arg not in self.VALID_ARGS and index + 1 != len(args):
log('Invalid argument given: "%s".\n' % arg)
log('USAGE: ' + self.USAGE)
sys.exit(1)
else:
log("Optional target user : %s" % arg)
if not os.path.isdir(os.path.join('/home', arg)):
log("Mediaserver user %s does not exist" % arg)
sys.exit(1)
else:
msuser = arg
# Check current dir
root_dir = utils.get_dir(__file__)
if root_dir != '':
......@@ -89,7 +97,7 @@ class Tester():
email = '-e' in args
email_if_fail = '-f' in args
basic_only = '-b' in args
tests = self.discover_tests(basic_only)
tests = self.discover_tests(basic_only, msuser)
if not tests:
sys.exit(1)
exit_code = self.run_tests(tests, email, email_if_fail)
......@@ -123,7 +131,7 @@ class Tester():
criticality = 'not specified'
return criticality, description
def discover_tests(self, basic_only=False):
def discover_tests(self, basic_only=False, msuser=None):
ignored_tests = utils.get_conf('TESTER_IGNORED_TESTS', '').split(',')
# Get standard tests
path = os.path.join(self.root_dir, 'tests')
......@@ -151,10 +159,12 @@ class Tester():
if basic_only:
tests.sort(key=lambda i: (-criticalities_map.get(i[1], 0), i[0]))
return tests
elif msuser:
tests = list()
# Get MS instances
ms_users = list()
for user in os.listdir('/home'):
if os.path.exists('/home/%s/msinstance' % user):
if os.path.exists('/home/%s/msinstance' % user) and user == msuser:
ms_users.append(user)
# Get MediaServer tests
if ms_users:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment