- Timestamp:
- Aug 15, 2019, 10:21:36 AM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 5c4a473
- Parents:
- 1ee048f
- Location:
- tests
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/Makefile.am
r1ee048f rd65f92c 34 34 35 35 # applies to both programs 36 # since automake doesn't have support for CFA we have to 36 37 AM_CFLAGS = $(if $(test), 2> $(test), ) \ 37 38 -g \ … … 41 42 -DIN_DIR="${abs_srcdir}/.in/" 42 43 43 AM_CFLAGS += ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS} 44 CC = @CFACC@ 44 CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH) -dist-tree -in-tree,@CFACC@ ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS}) 45 CFACCBIN = @CFACC@ 46 CFACC = $(CC) 45 47 46 48 PRETTY_PATH=mkdir -p $(dir $(abspath ${@})) && cd ${srcdir} && … … 56 58 #---------------------------------------------------------------------------------------------------------------- 57 59 all-local : 58 @+${TEST_PY} --debug=${debug} 60 @+${TEST_PY} --debug=${debug} --install=${installed} ${concurrent} ${timeouts} ${quick_test} 59 61 60 62 all-tests : 61 @+${TEST_PY} --debug=${debug} 63 @+${TEST_PY} --debug=${debug} --install=${installed} ${concurrent} ${timeouts} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program 62 64 63 65 clean-local : … … 86 88 87 89 # Use for all tests, make sure the path are correct and all flags are added 88 CFACOMPILETEST=$(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) $($(shell echo "${@}_FLAGS" | sed 's/-\|\//_/g'))90 CFACOMPILETEST=$(PRETTY_PATH) $(CFACOMPILE) -c $(shell realpath --relative-to=${srcdir} ${<}) $($(shell echo "${@}_FLAGS" | sed 's/-\|\//_/g')) 89 91 90 # Use for tests that either generate an executable, print direct ylto stdout or the make command is expected to fail92 # Use for tests that either generate an executable, print directly to stdout or the make command is expected to fail 91 93 CFATEST_STDOUT=$(CFACOMPILETEST) -o $(abspath ${@}) 92 94 … … 97 99 98 100 # implicit rule so not all test require a rule 99 % : %.cfa $(CFACC) 100 $(CFATEST_STDOUT) 101 % : %.cfa $(CFACCBIN) 102 $(CFACOMPILETEST) -o $(abspath ${@}).o 103 $(CFACC) $(abspath ${@}).o -o $(abspath ${@}) 104 101 105 102 106 % : %.cpp … … 122 126 # CUSTOM TARGET 123 127 #------------------------------------------------------------------------------ 124 typedefRedef-ERR1: typedefRedef.cfa $(CFACC )128 typedefRedef-ERR1: typedefRedef.cfa $(CFACCBIN) 125 129 $(CFATEST_STDOUT) -DERR1 126 130 127 alloc-ERROR: alloc.cfa $(CFACC )131 alloc-ERROR: alloc.cfa $(CFACCBIN) 128 132 $(CFATEST_STDOUT) -DERR1 129 133 130 nested-types-ERR1: nested-types.cfa $(CFACC )134 nested-types-ERR1: nested-types.cfa $(CFACCBIN) 131 135 $(CFATEST_STDOUT) -DERR1 132 136 133 nested-types-ERR2: nested-types.cfa $(CFACC )137 nested-types-ERR2: nested-types.cfa $(CFACCBIN) 134 138 $(CFATEST_STDOUT) -DERR2 135 139 136 raii/dtor-early-exit-ERR1: raii/dtor-early-exit.cfa $(CFACC )140 raii/dtor-early-exit-ERR1: raii/dtor-early-exit.cfa $(CFACCBIN) 137 141 $(CFATEST_STDOUT) -DERR1 138 142 139 raii/dtor-early-exit-ERR2: raii/dtor-early-exit.cfa $(CFACC )143 raii/dtor-early-exit-ERR2: raii/dtor-early-exit.cfa $(CFACCBIN) 140 144 $(CFATEST_STDOUT) -DERR2 141 145 142 raii/memberCtors-ERR1: raii/memberCtors.cfa $(CFACC )146 raii/memberCtors-ERR1: raii/memberCtors.cfa $(CFACCBIN) 143 147 $(CFATEST_STDOUT) -DERR1 144 148 145 raii/ctor-autogen-ERR1: raii/ctor-autogen.cfa $(CFACC )149 raii/ctor-autogen-ERR1: raii/ctor-autogen.cfa $(CFACCBIN) 146 150 $(CFATEST_STDOUT) -DERR1 147 151 148 152 #builtins 149 builtins/sync: builtins/sync.cfa $(CFACC )153 builtins/sync: builtins/sync.cfa $(CFACCBIN) 150 154 $(CFATEST_STDERR) -fsyntax-only 151 155 152 156 # Warnings 153 warnings/self-assignment: warnings/self-assignment.cfa $(CFACC )157 warnings/self-assignment: warnings/self-assignment.cfa $(CFACCBIN) 154 158 $(CFATEST_STDERR) -fsyntax-only -
tests/Makefile.in
r1ee048f rd65f92c 212 212 AWK = @AWK@ 213 213 BUILD_IN_TREE_FLAGS = @BUILD_IN_TREE_FLAGS@ 214 CC = @CFACC@214 CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH) -dist-tree -in-tree,@CFACC@ ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS}) 215 215 CCAS = @CCAS@ 216 216 CCASDEPMODE = @CCASDEPMODE@ 217 217 CCASFLAGS = @CCASFLAGS@ 218 218 CCDEPMODE = @CCDEPMODE@ 219 CFACC = @CFACC@219 CFACC = $(CC) 220 220 CFACPP = @CFACPP@ 221 221 CFA_BACKEND_CC = @CFA_BACKEND_CC@ … … 248 248 FGREP = @FGREP@ 249 249 GREP = @GREP@ 250 HAS_DISTCC = @HAS_DISTCC@ 250 251 HOST_FLAGS = @HOST_FLAGS@ 251 252 INSTALL = @INSTALL@ … … 385 386 386 387 # applies to both programs 387 AM_CFLAGS = $(if $(test), 2> $(test), ) -g -Wall -Wno-unused-function \ 388 -quiet @CFA_FLAGS@ -DIN_DIR="${abs_srcdir}/.in/" \ 389 ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS} 388 # since automake doesn't have support for CFA we have to 389 AM_CFLAGS = $(if $(test), 2> $(test), ) \ 390 -g \ 391 -Wall \ 392 -Wno-unused-function \ 393 -quiet @CFA_FLAGS@ \ 394 -DIN_DIR="${abs_srcdir}/.in/" 395 396 CFACCBIN = @CFACC@ 390 397 PRETTY_PATH = mkdir -p $(dir $(abspath ${@})) && cd ${srcdir} && 391 398 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 … … 396 403 397 404 # Use for all tests, make sure the path are correct and all flags are added 398 CFACOMPILETEST = $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) $($(shell echo "${@}_FLAGS" | sed 's/-\|\//_/g'))399 400 # Use for tests that either generate an executable, print direct ylto stdout or the make command is expected to fail405 CFACOMPILETEST = $(PRETTY_PATH) $(CFACOMPILE) -c $(shell realpath --relative-to=${srcdir} ${<}) $($(shell echo "${@}_FLAGS" | sed 's/-\|\//_/g')) 406 407 # Use for tests that either generate an executable, print directly to stdout or the make command is expected to fail 401 408 CFATEST_STDOUT = $(CFACOMPILETEST) -o $(abspath ${@}) 402 409 … … 770 777 #---------------------------------------------------------------------------------------------------------------- 771 778 all-local : 772 @+${TEST_PY} --debug=${debug} 779 @+${TEST_PY} --debug=${debug} --install=${installed} ${concurrent} ${timeouts} ${quick_test} 773 780 774 781 all-tests : 775 @+${TEST_PY} --debug=${debug} 782 @+${TEST_PY} --debug=${debug} --install=${installed} ${concurrent} ${timeouts} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program 776 783 777 784 clean-local : … … 800 807 801 808 # implicit rule so not all test require a rule 802 % : %.cfa $(CFACC) 803 $(CFATEST_STDOUT) 809 % : %.cfa $(CFACCBIN) 810 $(CFACOMPILETEST) -o $(abspath ${@}).o 811 $(CFACC) $(abspath ${@}).o -o $(abspath ${@}) 804 812 805 813 % : %.cpp … … 809 817 # CUSTOM TARGET 810 818 #------------------------------------------------------------------------------ 811 typedefRedef-ERR1: typedefRedef.cfa $(CFACC )819 typedefRedef-ERR1: typedefRedef.cfa $(CFACCBIN) 812 820 $(CFATEST_STDOUT) -DERR1 813 821 814 alloc-ERROR: alloc.cfa $(CFACC )822 alloc-ERROR: alloc.cfa $(CFACCBIN) 815 823 $(CFATEST_STDOUT) -DERR1 816 824 817 nested-types-ERR1: nested-types.cfa $(CFACC )825 nested-types-ERR1: nested-types.cfa $(CFACCBIN) 818 826 $(CFATEST_STDOUT) -DERR1 819 827 820 nested-types-ERR2: nested-types.cfa $(CFACC )828 nested-types-ERR2: nested-types.cfa $(CFACCBIN) 821 829 $(CFATEST_STDOUT) -DERR2 822 830 823 raii/dtor-early-exit-ERR1: raii/dtor-early-exit.cfa $(CFACC )831 raii/dtor-early-exit-ERR1: raii/dtor-early-exit.cfa $(CFACCBIN) 824 832 $(CFATEST_STDOUT) -DERR1 825 833 826 raii/dtor-early-exit-ERR2: raii/dtor-early-exit.cfa $(CFACC )834 raii/dtor-early-exit-ERR2: raii/dtor-early-exit.cfa $(CFACCBIN) 827 835 $(CFATEST_STDOUT) -DERR2 828 836 829 raii/memberCtors-ERR1: raii/memberCtors.cfa $(CFACC )837 raii/memberCtors-ERR1: raii/memberCtors.cfa $(CFACCBIN) 830 838 $(CFATEST_STDOUT) -DERR1 831 839 832 raii/ctor-autogen-ERR1: raii/ctor-autogen.cfa $(CFACC )840 raii/ctor-autogen-ERR1: raii/ctor-autogen.cfa $(CFACCBIN) 833 841 $(CFATEST_STDOUT) -DERR1 834 842 835 843 #builtins 836 builtins/sync: builtins/sync.cfa $(CFACC )844 builtins/sync: builtins/sync.cfa $(CFACCBIN) 837 845 $(CFATEST_STDERR) -fsyntax-only 838 846 839 847 # Warnings 840 warnings/self-assignment: warnings/self-assignment.cfa $(CFACC )848 warnings/self-assignment: warnings/self-assignment.cfa $(CFACCBIN) 841 849 $(CFATEST_STDERR) -fsyntax-only 842 850 -
tests/config.py.in
r1ee048f rd65f92c 8 8 BUILDDIR = "@abs_builddir@" 9 9 HOSTARCH = "@host_cpu@" 10 DISTRIBUTE = @HAS_DISTCC@ -
tests/pybin/settings.py
r1ee048f rd65f92c 11 11 SRCDIR = os.path.abspath(config.SRCDIR) 12 12 BUILDDIR = os.path.abspath(config.BUILDDIR) 13 distribute = config.DISTRIBUTE 13 14 os.chdir(testpath) 14 15 … … 85 86 self.string = "debug" if value else "no debug" 86 87 self.flags = """DEBUG_FLAGS=%s""" % ("-debug -O0" if value else "-nodebug -O2") 88 self.path = "debug" if value else "nodebug" 87 89 88 90 class Install: 89 91 def __init__(self, value): 92 if value: 93 distribute = False 94 90 95 self.string = "installed" if value else "in-tree" 91 96 self.flags = """INSTALL_FLAGS=%s""" % ("" if value else "-in-tree") … … 113 118 global timeout 114 119 global output_width 120 global distcc 115 121 116 122 dry_run = options.dry_run … … 122 128 timeout = Timeouts(options.timeout, options.global_timeout) 123 129 output_width = 24 130 distcc = "DISTCC_CFA_PATH=~/.cfadistcc/%s/cfa" % tools.config_hash() 124 131 132 if distribute and not os.environ.get('DISTCC_LOG'): 133 os.putenv('DISTCC_LOG', os.path.join(BUILDDIR, 'distcc_error.log')) 125 134 126 135 def update_make_cmd(force, jobs): … … 131 140 def validate(): 132 141 errf = os.path.join(BUILDDIR, ".validate.err") 133 make_ret, out = tools.make( ".validate", error_file = errf, output =subprocess.DEVNULL, error=subprocess.DEVNULL )142 make_ret, out = tools.make( ".validate", error_file = errf, output_file=subprocess.DEVNULL, error=subprocess.DEVNULL ) 134 143 if make_ret != 0: 135 144 with open (errf, "r") as myfile: -
tests/pybin/tools.py
r1ee048f rd65f92c 22 22 23 23 # helper functions to run terminal commands 24 def sh(*cmd, timeout = False, output = None, input = None, error = subprocess.STDOUT):24 def sh(*cmd, timeout = False, output_file = None, input_file = None, input_text = None, error = subprocess.STDOUT): 25 25 cmd = list(cmd) 26 27 if input_file and input_text: 28 return 401, "Cannot use both text and file inputs" 26 29 27 30 # if this is a dry_run, only print the commands that would be ran 28 31 if settings.dry_run : 29 32 cmd = "{} cmd: {}".format(os.getcwd(), ' '.join(cmd)) 30 if output and not isinstance(output, int):33 if output_file and not isinstance(output_file, int): 31 34 cmd += " > " 32 cmd += output 35 cmd += output_file 33 36 34 37 if error and not isinstance(error, int): … … 36 39 cmd += error 37 40 38 if input and not isinstance(input, int) and os.path.isfile(input):41 if input_file and not isinstance(input_file, int) and os.path.isfile(input_file): 39 42 cmd += " < " 40 cmd += input 43 cmd += input_file 41 44 42 45 print(cmd) … … 45 48 with contextlib.ExitStack() as onexit: 46 49 # add input redirection if needed 47 input = openfd(input, 'r', onexit, True)50 input_file = openfd(input_file, 'r', onexit, True) 48 51 49 52 # add output redirection if needed 50 output = openfd(output, 'w', onexit, False)53 output_file = openfd(output_file, 'w', onexit, False) 51 54 52 55 # add error redirection if needed … … 57 60 proc = subprocess.run( 58 61 cmd, 59 stdin =input,60 stdout =output,61 stderr =error,62 timeout =settings.timeout.single if timeout else None62 **({'input' : bytes(input_text, encoding='utf-8')} if input_text else {'stdin' : input_file}), 63 stdout = output_file, 64 stderr = error, 65 timeout = settings.timeout.single if timeout else None 63 66 ) 67 64 68 return proc.returncode, proc.stdout.decode("utf-8") if proc.stdout else None 65 69 except subprocess.TimeoutExpired: … … 74 78 return False 75 79 76 code, out = sh("file %s" % fname, output =subprocess.PIPE)80 code, out = sh("file %s" % fname, output_file=subprocess.PIPE) 77 81 if code != 0: 78 82 return False … … 106 110 if isinstance(files, str ): files = [ files ] 107 111 for file in files: 108 sh( 'rm', '-f', file, output =subprocess.DEVNULL, error=subprocess.DEVNULL )112 sh( 'rm', '-f', file, output_file=subprocess.DEVNULL, error=subprocess.DEVNULL ) 109 113 110 114 # Create 1 or more directory … … 114 118 p = os.path.normpath( file ) 115 119 d = os.path.dirname ( p ) 116 sh( 'mkdir', '-p', d, output =subprocess.DEVNULL, error=subprocess.DEVNULL )120 sh( 'mkdir', '-p', d, output_file=subprocess.DEVNULL, error=subprocess.DEVNULL ) 117 121 118 122 … … 137 141 lhs, 138 142 rhs, 139 output =subprocess.PIPE143 output_file=subprocess.PIPE 140 144 ) 141 145 142 146 # call make 143 def make(target, *, flags = '', output = None, error = None, error_file = None, silent = False):147 def make(target, *, flags = '', output_file = None, error = None, error_file = None, silent = False): 144 148 test_param = """test="%s" """ % (error_file) if error_file else None 145 149 cmd = [ … … 150 154 settings.debug.flags, 151 155 settings.install.flags, 156 settings.distcc if settings.distribute else None, 152 157 flags, 153 158 target 154 159 ] 155 160 cmd = [s for s in cmd if s] 156 return sh(*cmd, output =output, error=error)161 return sh(*cmd, output_file=output_file, error=error) 157 162 158 163 def which(program): … … 200 205 # cat one file into the other 201 206 def cat(source, dest): 202 ret, _ = sh("cat", source, output =dest)207 ret, _ = sh("cat", source, output_file=dest) 203 208 return ret 204 209 … … 273 278 ################################################################################ 274 279 280 # get hash for given configuration 281 def config_hash(): 282 path = os.path.normpath(os.path.join( 283 settings.SRCDIR, 284 )) 285 286 distcc_hash = os.path.join(settings.SRCDIR, '../tools/build/distcc_hash') 287 config = "%s-%s" % (settings.arch.target, settings.debug.path) 288 _, out = sh(distcc_hash, config, output_file=subprocess.PIPE) 289 return out.strip() 290 275 291 # check if arguments is yes or no 276 292 def yes_no(string): … … 302 318 return 1, "ERR No core dump" 303 319 304 return sh('gdb', '-n', path, core, '-batch', '-x', cmd, output =subprocess.PIPE)320 return sh('gdb', '-n', path, core, '-batch', '-x', cmd, output_file=subprocess.PIPE) 305 321 306 322 class Timed: -
tests/test.py
r1ee048f rd65f92c 142 142 # build, skipping to next test on error 143 143 with Timed() as comp_dur: 144 make_ret, _ = make( test.target(), output =subprocess.DEVNULL, error=out_file, error_file = err_file )144 make_ret, _ = make( test.target(), output_file=subprocess.DEVNULL, error=out_file, error_file = err_file ) 145 145 146 146 run_dur = None … … 152 152 if settings.dry_run or is_exe(exe_file): 153 153 # run test 154 retcode, _ = sh(exe_file, output =out_file, input=in_file, timeout=True)154 retcode, _ = sh(exe_file, output_file=out_file, input_file=in_file, timeout=True) 155 155 else : 156 156 # simply cat the result into the output … … 215 215 def run_tests(tests, jobs) : 216 216 # clean the sandbox from previous commands 217 make('clean', output =subprocess.DEVNULL, error=subprocess.DEVNULL)217 make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL) 218 218 219 219 # create the executor for our jobs and handle the signal properly … … 256 256 257 257 # clean the workspace 258 make('clean', output =subprocess.DEVNULL, error=subprocess.DEVNULL)258 make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL) 259 259 260 260 return 1 if failed else 0
Note: See TracChangeset
for help on using the changeset viewer.