Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/test.py

    rc2d5e28 rc07d724  
    2424        self.name, self.path = name, path
    2525
    26 class TestResult:
    27         SUCCESS = 0
    28         FAILURE = 1
    29         TIMEOUT = 124
    30 
    3126# parses the Makefile to find the machine type (32-bit / 64-bit)
    3227def getMachineType():
    3328        sh('echo "void ?{}(int*a,int b){}int main(){return 0;}" > .dummy.c')
    3429        ret, out = sh("make .dummy -s", print2stdout=True)
    35 
     30       
    3631        if ret != 0:
    3732                print("Failed to identify architecture:")
     
    166161
    167162        # build, skipping to next test on error
    168         make_ret, _ = sh("""%s test=yes EXTRA_FLAGS="%s" %s 2> %s 1> /dev/null""" % (make_cmd, options, test.name, out_file), dry_run)
    169 
    170         retcode = 0
    171         error = None
     163        make_ret, _ = sh("""%s test=yes EXTRA_FLAGS="-quiet %s" %s 2> %s 1> /dev/null""" % (make_cmd, options, test.name, out_file), dry_run)
    172164
    173165        # if the make command succeds continue otherwise skip to diff
     
    178170                if fileIsExecutable(test.name) :
    179171                        # run test
    180                         retcode, _ = sh("timeout 60 ./%s %s > %s 2>&1" % (test.name, stdinput, out_file), dry_run)
     172                        sh("./%s %s > %s 2>&1" % (test.name, stdinput, out_file), dry_run)
    181173                else :
    182174                        # simply cat the result into the output
     
    187179                sh("mv %s %s" % (err_file, out_file), dry_run)
    188180
    189         if retcode == 0:
    190                 if generate :
    191                         # if we are ounly generating the output we still need to check that the test actually exists
    192                         if not dry_run and fileContainsOnly(out_file, "make: *** No rule to make target `%s'.  Stop." % test.name) :
    193                                 retcode = 1;
    194                                 error = "\t\tNo make target for test %s!" % test.name
    195                                 sh("rm %s" % out_file, False)
    196                 else :
    197                         # fetch return code and error from the diff command
    198                         retcode, error = diff(".expect/%s.txt" % test.path, ".out/%s.log" % test.name, dry_run)
     181        retcode = 0
     182        error = None
     183
     184        if generate :
     185                # if we are ounly generating the output we still need to check that the test actually exists
     186                if not dry_run and fileContainsOnly(out_file, "make: *** No rule to make target `%s'.  Stop." % test.name) :
     187                        retcode = 1;
     188                        error = "\t\tNo make target for test %s!" % test.name
     189                        sh("rm %s" % out_file, False)
     190
     191        else :
     192                # fetch return code and error from the diff command
     193                retcode, error = diff(".expect/%s.txt" % test.path, ".out/%s.log" % test.name, dry_run)
     194       
    199195        # clean the executable
    200196        sh("rm -f %s > /dev/null 2>&1" % test.name, dry_run)
     
    209205        name_txt = "%20s  " % t.name
    210206
    211         retcode, error = run_single_test(t, generate, dry_run, debug)
     207        #run the test instance and collect the result
     208        test_failed, error = run_single_test(t, generate, dry_run, debug)
    212209
    213210        # update output based on current action
    214211        if generate :
    215                 if   retcode == TestResult.SUCCESS:     result_txt = "Done"
    216                 elif retcode == TestResult.TIMEOUT:     result_txt = "TIMEOUT"
    217                 else :                                          result_txt = "ERROR"
    218         else :
    219                 if   retcode == TestResult.SUCCESS:     result_txt = "PASSED"
    220                 elif retcode == TestResult.TIMEOUT:     result_txt = "TIMEOUT"
    221                 else :                                          result_txt = "FAILED"
     212                failed_txt = "ERROR"
     213                success_txt = "Done"
     214        else :
     215                failed_txt = "FAILED"
     216                success_txt = "PASSED"
    222217
    223218        #print result with error if needed
    224         text = name_txt + result_txt
     219        text = name_txt + (failed_txt if test_failed else success_txt)
    225220        out = sys.stdout
    226221        if error :
     
    228223                out = sys.stderr
    229224
    230         print(text, file = out)
     225        print(text, file = out);
    231226        sys.stdout.flush()
    232227        sys.stderr.flush()
    233228        signal.signal(signal.SIGINT, signal.SIG_IGN)
    234229
    235         return retcode != TestResult.SUCCESS
     230        return test_failed
    236231
    237232# run the given list of tests with the given parameters
     
    274269if __name__ == "__main__":
    275270        #always run from same folder
    276         chdir()
    277 
     271        chdir() 
     272       
    278273        # parse the command line arguments
    279274        options = getOptions()
Note: See TracChangeset for help on using the changeset viewer.