-# TODO: If the output is sorted, we should report it to the users. Corresponding perl chunk
-# print "WARNING: Both the observed output and expected output were sorted as requested.\n";
-# print "WARNING: Output were only sorted using the $sort_prefix first chars.\n"
-# if ( $sort_prefix > 0 );
-# print "WARNING: Use <! output sort 19> to sort by simulated date and process ID only.\n";
-#
-# print "----8<--------------- Begin of unprocessed observed output (as it should appear in file):\n";
-# map {print "> $_\n"} @{$cmd{'unsorted got'}};
-# print "--------------->8---- End of the unprocessed observed output.\n";
-
-
self.filename = os.path.basename(filename)
self.abspath = os.path.abspath(filename)
self.f = open(self.filename_raw)
self.filename = os.path.basename(filename)
self.abspath = os.path.abspath(filename)
self.f = open(self.filename_raw)
def add_thread(self, thread):
self.threads.append(thread)
def add_thread(self, thread):
self.threads.append(thread)
self.ignore_regexps = TeshState().ignore_regexps_common
def add_input_pipe(self, l):
self.ignore_regexps = TeshState().ignore_regexps_common
def add_input_pipe(self, l):
def set_cmd(self, args, linenumber):
self.args = args
self.linenumber = linenumber
def set_cmd(self, args, linenumber):
self.args = args
self.linenumber = linenumber
def add_ignore(self, txt):
self.ignore_regexps.append(re.compile(txt))
def add_ignore(self, txt):
self.ignore_regexps.append(re.compile(txt))
def remove_ignored_lines(self, lines):
for ign in self.ignore_regexps:
lines = [l for l in lines if not ign.match(l)]
def remove_ignored_lines(self, lines):
for ign in self.ignore_regexps:
lines = [l for l in lines if not ign.match(l)]
if re.match("^mkfile ", self.args) is not None:
self._cmd_mkfile(self.args)
if lock is not None: lock.release()
return
if re.match("^mkfile ", self.args) is not None:
self._cmd_mkfile(self.args)
if lock is not None: lock.release()
return
if re.match("^cd ", self.args) is not None:
self._cmd_cd(self.args)
if lock is not None: lock.release()
return
if re.match("^cd ", self.args) is not None:
self._cmd_cd(self.args)
if lock is not None: lock.release()
return
try:
proc = subprocess.Popen(args, bufsize=1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
try:
proc = subprocess.Popen(args, bufsize=1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
- except OSError as e:
- if e.errno == 8:
- e.strerror += "\nOSError: [Errno 8] Executed scripts should start with shebang line (like #!/bin/sh)"
- raise e
+ except FileNotFoundError:
+ print("["+FileReader().filename+":"+str(self.linenumber)+"] Cannot start '"+args[0]+"': File not found")
+ exit(3)
+ except OSError as osE:
+ if osE.errno == 8:
+ osE.strerror += "\nOSError: [Errno 8] Executed scripts should start with shebang line (like #!/bin/sh)"
+ raise osE
cmdName = FileReader().filename+":"+str(self.linenumber)
try:
(stdout_data, stderr_data) = proc.communicate("\n".join(self.input_pipe), self.timeout)
except subprocess.TimeoutExpired:
print("Test suite `"+FileReader().filename+"': NOK (<"+cmdName+"> timeout after "+str(self.timeout)+" sec)")
cmdName = FileReader().filename+":"+str(self.linenumber)
try:
(stdout_data, stderr_data) = proc.communicate("\n".join(self.input_pipe), self.timeout)
except subprocess.TimeoutExpired:
print("Test suite `"+FileReader().filename+"': NOK (<"+cmdName+"> timeout after "+str(self.timeout)+" sec)")
#remove text colors
ansi_escape = re.compile(r'\x1b[^m]*m')
stdout_data = ansi_escape.sub('', stdout_data)
#remove text colors
ansi_escape = re.compile(r'\x1b[^m]*m')
stdout_data = ansi_escape.sub('', stdout_data)
elif self.sort > 0:
stdouta.sort(key=lambda x: x[:self.sort].lower())
self.output_pipe_stdout.sort(key=lambda x: x[:self.sort].lower())
elif self.sort > 0:
stdouta.sort(key=lambda x: x[:self.sort].lower())
self.output_pipe_stdout.sort(key=lambda x: x[:self.sort].lower())
diff = list(difflib.unified_diff(self.output_pipe_stdout, stdouta,lineterm="",fromfile='expected', tofile='obtained'))
diff = list(difflib.unified_diff(self.output_pipe_stdout, stdouta,lineterm="",fromfile='expected', tofile='obtained'))
print("Output of <"+cmdName+"> mismatch:")
if self.sort >= 0: # If sorted, truncate the diff output and show the unsorted version
difflen = 0;
for line in diff:
print("Output of <"+cmdName+"> mismatch:")
if self.sort >= 0: # If sorted, truncate the diff output and show the unsorted version
difflen = 0;
for line in diff:
print("Unsorted observed output:\n")
for line in stdcpy:
print(line)
else: # If not sorted, just display the diff
for line in diff:
print(line)
print("Unsorted observed output:\n")
for line in stdcpy:
print(line)
else: # If not sorted, just display the diff
for line in diff:
print(line)
print("Test suite `"+FileReader().filename+"': NOK (<"+cmdName+"> output mismatch)")
if lock is not None: lock.release()
if TeshState().keep:
print("Test suite `"+FileReader().filename+"': NOK (<"+cmdName+"> output mismatch)")
if lock is not None: lock.release()
if TeshState().keep:
if proc.returncode != self.expect_return:
if proc.returncode >= 0:
print("Test suite `"+FileReader().filename+"': NOK (<"+cmdName+"> returned code "+str(proc.returncode)+")")
if proc.returncode != self.expect_return:
if proc.returncode >= 0:
print("Test suite `"+FileReader().filename+"': NOK (<"+cmdName+"> returned code "+str(proc.returncode)+")")
print("Test suite `"+FileReader().filename+"': NOK (<"+cmdName+"> got signal "+SIGNALS_TO_NAMES_DICT[-proc.returncode]+")")
if lock is not None: lock.release()
exit(-proc.returncode)
print("Test suite `"+FileReader().filename+"': NOK (<"+cmdName+"> got signal "+SIGNALS_TO_NAMES_DICT[-proc.returncode]+")")
if lock is not None: lock.release()
exit(-proc.returncode)
parser = argparse.ArgumentParser(description='tesh -- testing shell', add_help=True)
group1 = parser.add_argument_group('Options')
group1.add_argument('teshfile', nargs='?', help='Name of teshfile, stdin if omitted')
group1.add_argument('--cd', metavar='some/directory', help='ask tesh to switch the working directory before launching the tests')
group1.add_argument('--setenv', metavar='var=value', action='append', help='set a specific environment variable')
parser = argparse.ArgumentParser(description='tesh -- testing shell', add_help=True)
group1 = parser.add_argument_group('Options')
group1.add_argument('teshfile', nargs='?', help='Name of teshfile, stdin if omitted')
group1.add_argument('--cd', metavar='some/directory', help='ask tesh to switch the working directory before launching the tests')
group1.add_argument('--setenv', metavar='var=value', action='append', help='set a specific environment variable')
- group1.add_argument('--cfg', metavar='arg', help='add parameter --cfg=arg to each command line')
- group1.add_argument('--log', metavar='arg', help='add parameter --log=arg to each command line')
- group1.add_argument('--ignore-jenkins', action='store_true', help='ignore all cruft generated on SimGrid continous integration servers')
+ group1.add_argument('--cfg', metavar='arg', action='append', help='add parameter --cfg=arg to each command line')
+ group1.add_argument('--log', metavar='arg', action='append', help='add parameter --log=arg to each command line')
+ group1.add_argument('--ignore-jenkins', action='store_true', help='ignore all cruft generated on SimGrid continous integration servers')
group1.add_argument('--wrapper', metavar='arg', help='Run each command in the provided wrapper (eg valgrind)')
group1.add_argument('--keep', action='store_true', help='Keep the obtained output when it does not match the expected one')
group1.add_argument('--wrapper', metavar='arg', help='Run each command in the provided wrapper (eg valgrind)')
group1.add_argument('--keep', action='store_true', help='Keep the obtained output when it does not match the expected one')
- re.compile("^profiling:"),
- re.compile(".*WARNING: ASan doesn\'t fully support"),
- re.compile("Unable to clean temporary file C:.*"),
+ re.compile("profiling:"),
+ re.compile("Unable to clean temporary file C:"),
- re.compile(".*Picked up JAVA_TOOL_OPTIONS.*"),
-
- re.compile("==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top:"),
+ re.compile("Picked up JAVA_TOOL_OPTIONS: "),
+ re.compile("Picked up _JAVA_OPTIONS: "),
+ re.compile("==[0-9]+== ?WARNING: ASan doesn\'t fully support"),
+ re.compile("==[0-9]+== ?WARNING: ASan is ignoring requested __asan_handle_no_return: stack top:"),
- re.compile("For details see http://code.google.com/p/address-sanitizer/issues/detail?id=189"),
+ re.compile("For details see http://code.google.com/p/address-sanitizer/issues/detail\\?id=189"),
+ re.compile("For details see https://github.com/google/sanitizers/issues/189"),
+ re.compile("Python runtime initialized with LC_CTYPE=C .*"),
#cmd holds the current command line
# tech commands will add some parameters to it
# when ready, we execute it.
cmd = Cmd()
#cmd holds the current command line
# tech commands will add some parameters to it
# when ready, we execute it.
cmd = Cmd()
elif line[0:2] == "$ ":
if cmd.run_if_possible():
cmd = Cmd()
cmd.set_cmd(line[2:], f.linenumber)
elif line[0:2] == "$ ":
if cmd.run_if_possible():
cmd = Cmd()
cmd.set_cmd(line[2:], f.linenumber)
elif line[0:2] == "& ":
if cmd.run_if_possible():
cmd = Cmd()
cmd.set_cmd(line[2:], f.linenumber)
cmd.background = True
elif line[0:2] == "& ":
if cmd.run_if_possible():
cmd = Cmd()
cmd.set_cmd(line[2:], f.linenumber)
cmd.background = True
elif line[0:len("! output sort")] == "! output sort":
if len(line) >= len("! output sort "):
sort = int(line[len("! output sort "):])
elif line[0:len("! output sort")] == "! output sort":
if len(line) >= len("! output sort "):
sort = int(line[len("! output sort "):])