diff --git a/tester.py b/tester.py index 2725d146eb35f1c485e55ad3782d7497781339df..795c7612dc9c0d4f0aaa04eb23327988eeaf403c 100755 --- a/tester.py +++ b/tester.py @@ -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: