Changes in / [bee653c:8a25be9]


Ignore:
Files:
14 added
14 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • configure

    rbee653c r8a25be9  
    1673816738
    1673916739#==============================================================================
    16740 ac_config_files="$ac_config_files Makefile driver/Makefile src/Makefile benchmark/Makefile tests/Makefile longrun_tests/Makefile tools/Makefile tools/prettyprinter/Makefile"
     16740ac_config_files="$ac_config_files Makefile driver/Makefile src/Makefile benchmark/Makefile tests/Makefile tests/preempt_longrun/Makefile tools/Makefile tools/prettyprinter/Makefile"
    1674116741
    1674216742
     
    1787617876    "benchmark/Makefile") CONFIG_FILES="$CONFIG_FILES benchmark/Makefile" ;;
    1787717877    "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
    17878     "longrun_tests/Makefile") CONFIG_FILES="$CONFIG_FILES longrun_tests/Makefile" ;;
     17878    "tests/preempt_longrun/Makefile") CONFIG_FILES="$CONFIG_FILES tests/preempt_longrun/Makefile" ;;
    1787917879    "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;;
    1788017880    "tools/prettyprinter/Makefile") CONFIG_FILES="$CONFIG_FILES tools/prettyprinter/Makefile" ;;
  • configure.ac

    rbee653c r8a25be9  
    211211        benchmark/Makefile
    212212        tests/Makefile
    213         longrun_tests/Makefile
     213        tests/preempt_longrun/Makefile
    214214        tools/Makefile
    215215        tools/prettyprinter/Makefile
  • tests/Makefile.am

    rbee653c r8a25be9  
    3636        -Wno-unused-function \
    3737        -quiet @CFA_FLAGS@ \
    38         -DIN_DIR="${abs_srcdir}/.in/"
     38        -DIN_DIR="${srcdir}/.in/"
    3939
    4040AM_CFLAGS += ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS}
  • tests/Makefile.in

    rbee653c r8a25be9  
    382382# applies to both programs
    383383AM_CFLAGS = $(if $(test), 2> $(test), ) -g -Wall -Wno-unused-function \
    384         -quiet @CFA_FLAGS@ -DIN_DIR="${abs_srcdir}/.in/" \
    385         ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS}
     384        -quiet @CFA_FLAGS@ -DIN_DIR="${srcdir}/.in/" ${DEBUG_FLAGS} \
     385        ${INSTALL_FLAGS} ${ARCH_FLAGS}
    386386PRETTY_PATH = cd ${srcdir} &&
    387387avl_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

    rbee653c r8a25be9  
    1111import subprocess
    1212import sys
    13 import tempfile
    1413import time
    1514import types
    1615
    1716from pybin import settings
     17from subprocess import Popen, PIPE, STDOUT
    1818
    1919################################################################################
     
    2727        # if this is a dry_run, only print the commands that would be ran
    2828        if settings.dry_run :
    29                 cmd = "{} cmd: {}".format(os.getcwd(), ' '.join(cmd))
    30                 if output and not isinstance(output, int):
    31                         cmd += " > "
    32                         cmd += output
    33 
    34                 if error and not isinstance(error, int):
    35                         cmd += " 2> "
    36                         cmd += error
    37 
    38                 if input and not isinstance(input, int) and os.path.isfile(input):
    39                         cmd += " < "
    40                         cmd += input
    41 
    42                 print(cmd)
     29                print("cmd: %s" % ' '.join(cmd))
    4330                return 0, None
    4431
    4532        with contextlib.ExitStack() as onexit:
    4633                # add input redirection if needed
    47                 input = openfd(input, 'r', onexit, True)
     34                if input and input != subprocess.DEVNULL:
     35                        if os.path.isfile(input):
     36                                input = open(input)
     37                                onexit.push(input)
     38                        else:
     39                                input = None
    4840
    4941                # add output redirection if needed
    50                 output = openfd(output, 'w', onexit, False)
    51 
    52                 # add error redirection if needed
    53                 error = openfd(error, 'w', onexit, False)
     42                if output and output != subprocess.DEVNULL and output != subprocess.PIPE:
     43                        output = open(output, 'w')
     44                        onexit.push(output)
    5445
    5546                # run the desired command
     
    5950                                stdin =input,
    6051                                stdout=output,
    61                                 stderr=error,
     52                                stderr=STDOUT,
    6253                                timeout=settings.timeout.single if timeout else None
    6354                        )
     
    8778def is_exe(fname):
    8879        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
    10380
    10481# Remove 1 or more files silently
     
    169146    return None
    170147
    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 
    181148################################################################################
    182149#               file handling
     
    279246
    280247def core_info(path):
    281         if not os.path.isfile(path):
    282                 return 1, "ERR Executable path is wrong"
    283 
    284248        cmd   = os.path.join(settings.SRCDIR, "pybin/print-core.gdb")
    285249        if not os.path.isfile(cmd):
    286250                return 1, "ERR Printing format for core dumps not found"
    287251
    288         core  = os.path.join(os.getcwd(), "core" )
     252        dname = os.path.dirname(path)
     253        core  = os.path.join(dname, "core" )
     254        if not os.path.isfile(path):
     255                return 1, "ERR Executable path is wrong"
    289256
    290257        if not os.path.isfile(core):
  • tests/test.py

    rbee653c r8a25be9  
    88import re
    99import sys
    10 import tempfile
    1110import time
    1211
     
    144143                make_ret, _ = make( test.target(), output=subprocess.DEVNULL, error=out_file, error_file = err_file )
    145144
     145        # if the make command succeds continue otherwise skip to diff
    146146        run_dur = None
    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
     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)
    170152                        else :
    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
     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
    180177
    181178
Note: See TracChangeset for help on using the changeset viewer.