Changeset f806b61
- Timestamp:
- Mar 28, 2019, 5:19:52 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b611fc3
- Parents:
- ea62265
- Location:
- tests
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/Makefile.am
rea62265 rf806b61 36 36 -Wno-unused-function \ 37 37 -quiet @CFA_FLAGS@ \ 38 -DIN_DIR="${ srcdir}/.in/"38 -DIN_DIR="${abs_srcdir}/.in/" 39 39 40 40 AM_CFLAGS += ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS} -
tests/Makefile.in
rea62265 rf806b61 382 382 # applies to both programs 383 383 AM_CFLAGS = $(if $(test), 2> $(test), ) -g -Wall -Wno-unused-function \ 384 -quiet @CFA_FLAGS@ -DIN_DIR="${ srcdir}/.in/" ${DEBUG_FLAGS}\385 ${ INSTALL_FLAGS} ${ARCH_FLAGS}384 -quiet @CFA_FLAGS@ -DIN_DIR="${abs_srcdir}/.in/" \ 385 ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS} 386 386 PRETTY_PATH = cd ${srcdir} && 387 387 avl_test_SOURCES = avltree/avl_test.cfa avltree/avl0.cfa avltree/avl1.cfa avltree/avl2.cfa avltree/avl3.cfa avltree/avl4.cfa avltree/avl-private.cfa -
tests/pybin/tools.py
rea62265 rf806b61 11 11 import subprocess 12 12 import sys 13 import tempfile 13 14 import time 14 15 import types 15 16 16 17 from pybin import settings 17 from subprocess import Popen, PIPE, STDOUT18 18 19 19 ################################################################################ … … 27 27 # if this is a dry_run, only print the commands that would be ran 28 28 if settings.dry_run : 29 cmd = " cmd: {}".format(' '.join(cmd))30 if output and output != subprocess.DEVNULL and output != subprocess.PIPE:29 cmd = "{} cmd: {}".format(os.getcwd(), ' '.join(cmd)) 30 if output and not isinstance(output, int): 31 31 cmd += " > " 32 32 cmd += output 33 33 34 if error and error != subprocess.DEVNULL and error != subprocess.PIPE and error != subprocess.STDOUT:34 if error and not isinstance(error, int): 35 35 cmd += " 2> " 36 36 cmd += error 37 37 38 if input and input != subprocess.DEVNULLand os.path.isfile(input):38 if input and not isinstance(input, int) and os.path.isfile(input): 39 39 cmd += " < " 40 40 cmd += input … … 45 45 with contextlib.ExitStack() as onexit: 46 46 # add input redirection if needed 47 if input and input != subprocess.DEVNULL: 48 if os.path.isfile(input): 49 input = open(input) 50 onexit.push(input) 51 else: 52 input = None 47 input = openfd(input, 'r', onexit, True) 53 48 54 49 # add output redirection if needed 55 if output and output != subprocess.DEVNULL and output != subprocess.PIPE: 56 output = open(output, 'w') 57 onexit.push(output) 50 output = openfd(output, 'w', onexit, False) 51 52 # add error redirection if needed 53 error = openfd(error, 'w', onexit, False) 58 54 59 55 # run the desired command … … 63 59 stdin =input, 64 60 stdout=output, 65 stderr= STDOUT,61 stderr=error, 66 62 timeout=settings.timeout.single if timeout else None 67 63 ) … … 91 87 def is_exe(fname): 92 88 return os.path.isfile(fname) and os.access(fname, os.X_OK) 89 90 def openfd(file, mode, exitstack, checkfile): 91 if not file: 92 return file 93 94 if isinstance(file, int): 95 return file 96 97 if checkfile and not os.path.isfile(file): 98 return None 99 100 file = open(file, mode) 101 exitstack.push(file) 102 return file 93 103 94 104 # Remove 1 or more files silently … … 159 169 return None 160 170 171 @contextlib.contextmanager 172 def tempdir(): 173 cwd = os.getcwd() 174 with tempfile.TemporaryDirectory() as temp: 175 os.chdir(temp) 176 try: 177 yield temp 178 finally: 179 os.chdir(cwd) 180 161 181 ################################################################################ 162 182 # file handling … … 259 279 260 280 def core_info(path): 281 if not os.path.isfile(path): 282 return 1, "ERR Executable path is wrong" 283 261 284 cmd = os.path.join(settings.SRCDIR, "pybin/print-core.gdb") 262 285 if not os.path.isfile(cmd): 263 286 return 1, "ERR Printing format for core dumps not found" 264 287 265 dname = os.path.dirname(path) 266 core = os.path.join(dname, "core" ) 267 if not os.path.isfile(path): 268 return 1, "ERR Executable path is wrong" 288 core = os.path.join(os.getcwd(), "core" ) 269 289 270 290 if not os.path.isfile(core): -
tests/test.py
rea62265 rf806b61 8 8 import re 9 9 import sys 10 import tempfile 10 11 import time 11 12 … … 143 144 make_ret, _ = make( test.target(), output=subprocess.DEVNULL, error=out_file, error_file = err_file ) 144 145 145 # if the make command succeds continue otherwise skip to diff146 146 run_dur = None 147 if success(make_ret): 148 with Timed() as run_dur: 149 if settings.dry_run or is_exe(exe_file): 150 # run test 151 retcode, _ = sh(exe_file, output=out_file, input=in_file, timeout=True) 147 # run everything in a temp directory to make sure core file are handled properly 148 with tempdir(): 149 # if the make command succeds continue otherwise skip to diff 150 if success(make_ret): 151 with Timed() as run_dur: 152 if settings.dry_run or is_exe(exe_file): 153 # run test 154 retcode, _ = sh(exe_file, output=out_file, input=in_file, timeout=True) 155 else : 156 # simply cat the result into the output 157 retcode = cat(exe_file, out_file) 158 else: 159 retcode = mv(err_file, out_file) 160 161 if success(retcode): 162 if settings.generating : 163 # if we are ounly generating the output we still need to check that the test actually exists 164 if no_rule(out_file, test.target()) : 165 retcode = 1 166 error = "\t\tNo make target for test %s!" % test.target() 167 rm(out_file) 168 else: 169 error = None 152 170 else : 153 # simply cat the result into the output 154 retcode = cat(exe_file, out_file) 155 else: 156 retcode = mv(err_file, out_file) 157 158 if success(retcode): 159 if settings.generating : 160 # if we are ounly generating the output we still need to check that the test actually exists 161 if no_rule(out_file, test.target()) : 162 retcode = 1 163 error = "\t\tNo make target for test %s!" % test.target() 164 rm(out_file) 165 else: 166 error = None 167 else : 168 # fetch return code and error from the diff command 169 retcode, error = diff(cmp_file, out_file) 170 171 else: 172 with open (out_file, "r") as myfile: 173 error = myfile.read() 174 175 ret, info = core_info(exe_file) 176 error = error + info if error else info 171 # fetch return code and error from the diff command 172 retcode, error = diff(cmp_file, out_file) 173 174 else: 175 with open (out_file, "r") as myfile: 176 error = myfile.read() 177 178 ret, info = core_info(exe_file) 179 error = error + info if error else info 177 180 178 181
Note: See TracChangeset
for help on using the changeset viewer.