20 from __future__
import print_function
28 print(
"-", end =
'', file = out)
30 print(
"running test case " + case_string, end=
'\n\n', file = out)
34 print(
"\nFailed Cases:")
35 for case
in failed_cases:
39 print(
'Commands to be executed:')
41 print(cmd.replace(sys.executable,
''))
44 dir_files = [ f
for f
in os.listdir(
'.')
if os.path.exists(f) ]
45 if not 'VERSION' in dir_files
and not 'waf' in dir_files:
46 if os.path.split(os.path.abspath(
'.'))[1] ==
'tests' and os.path.split(os.path.abspath(os.pardir))[1] ==
'utils':
49 print(
'Error: Invalid working directory')
55 Generic class for testing tools based on provided commands and test cases.
68 Provide input argument list, description and mode of the suite being executed.
69 @param self this object
70 @param argv argument list
71 @param desc description
77 self.
my_env[
'LD_LIBRARY_PATH'] = os.getcwd() +
"/build"
84 Parses the commandline arguments
85 @param self this object
86 @param argv argument list
87 @param desc description
88 @return command line arguments
90 parser = argparse.ArgumentParser(description = desc)
91 parser.add_argument(
'-f',
'--file', action=
'store', dest=
'out_file', default = self.
outfile,
93 help=
'File to be used for storing the command specific output (Default: '+self.
outfile+
')')
94 parser.add_argument(
'-c', action=
'store_true', dest=
'cmds', default=
False,
95 help=
'List out all the commands being tested')
96 parser.add_argument(
'-m', action=
'store_true', dest=
'mute', default=
False,
97 help=
'Sends only stderr output to FILE')
98 parser.add_argument(
'-x',
'--customcmd', action=
'store', dest=
'custcmd', default =
None,
99 help=
'Enter a comma-separated list of commands to override the existing ones. NOT APPLICABLE FOR TEST-PY SUITE.')
100 return parser.parse_args(argv)
104 Can be used by importing suite to handle custom commands
105 @param self this object
106 @return custom commands
108 return self.options.custcmd
113 @param self this object
114 @param cmds test commands
117 if self.options.cmds:
122 total_tests = len(cmds)
126 with open(self.options.out_file,
'w')
as out:
128 with open(os.devnull,
'w')
as sink:
129 if self.options.mute:
132 case_string = cmd.replace(sys.executable,
'')
133 print(
"running test case: " + case_string)
136 ret = subprocess.call(cmd, shell=
True, env=self.
my_env, stdout=outstream, stderr=out)
141 failed_cases.append(case_string)
142 print(
"[ %s out of %s ] test cases passed; Progress = %.2f%% \n" % (passed, total_tests, progress*100/total_tests))
143 if final_return != 0:
146 print(
"\nAll cases passed")
147 print (
"Detailed output available in " + self.options.out_file, end=
'\n\n')
def print_failed_cases(failed_cases)
def runtests(self, cmds)
Execute the tests.
def override_cmds(self)
Can be used by importing suite to handle custom commands.
def parseargs(self, argv, desc)
Parses the commandline arguments.
def print_case_in_file(case_string, out)
def __init__(self, argv, desc, mode)
Provide input argument list, description and mode of the suite being executed.