Print this page
11814 test-runner exit code should reflect test results

Split Close
Expand all
Collapse all
          --- old/usr/src/test/test-runner/cmd/run
          +++ new/usr/src/test/test-runner/cmd/run
↓ open down ↓ 6 lines elided ↑ open up ↑
   7    7  # 1.0 of the CDDL.
   8    8  #
   9    9  # A full copy of the text of the CDDL should have accompanied this
  10   10  # source.  A copy of the CDDL is also available via the Internet at
  11   11  # http://www.illumos.org/license/CDDL.
  12   12  #
  13   13  
  14   14  #
  15   15  # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
  16   16  # Copyright (c) 2017, Chris Fraire <cfraire@me.com>.
  17      -# Copyright 2018 Joyent, Inc.
       17 +# Copyright 2019 Joyent, Inc.
  18   18  #
  19   19  
  20   20  import ConfigParser
  21   21  import os
  22   22  import logging
  23   23  import platform
  24   24  from logging.handlers import WatchedFileHandler
  25   25  from datetime import datetime
  26   26  from optparse import OptionParser
  27   27  from pwd import getpwnam
↓ open down ↓ 4 lines elided ↑ open up ↑
  32   32  from sys import argv
  33   33  from sys import maxint
  34   34  from threading import Timer
  35   35  from time import time
  36   36  
  37   37  BASEDIR = '/var/tmp/test_results'
  38   38  KILL = '/usr/bin/kill'
  39   39  TRUE = '/usr/bin/true'
  40   40  SUDO = '/usr/bin/sudo'
  41   41  
       42 +retcode = 0
       43 +
  42   44  # Custom class to reopen the log file in case it is forcibly closed by a test.
  43   45  class WatchedFileHandlerClosed(WatchedFileHandler):
  44   46      """Watch files, including closed files.
  45   47      Similar to (and inherits from) logging.handler.WatchedFileHandler,
  46   48      except that IOErrors are handled by reopening the stream and retrying.
  47   49      This will be retried up to a configurable number of times before
  48   50      giving up, default 5.
  49   51      """
  50   52  
  51   53      def __init__(self, filename, mode='a', encoding=None, delay=0, max_tries=5):
↓ open down ↓ 25 lines elided ↑ open up ↑
  77   79          self.stdout = []
  78   80          self.stderr = []
  79   81          self.result = ''
  80   82  
  81   83      def done(self, proc, killed):
  82   84          """
  83   85          Finalize the results of this Cmd.
  84   86          Report SKIP for return codes 3,4 (NOTINUSE, UNSUPPORTED)
  85   87          as defined in ../stf/include/stf.shlib
  86   88          """
       89 +        global retcode
       90 +
  87   91          Result.total += 1
  88   92          m, s = divmod(time() - self.starttime, 60)
  89   93          self.runtime = '%02d:%02d' % (m, s)
  90   94          self.returncode = proc.returncode
  91   95          if killed:
  92   96              self.result = 'KILLED'
  93   97              Result.runresults['KILLED'] += 1
       98 +            retcode = 2;
  94   99          elif self.returncode is 0:
  95  100              self.result = 'PASS'
  96  101              Result.runresults['PASS'] += 1
  97  102          elif self.returncode is 3 or self.returncode is 4:
  98  103              self.result = 'SKIP'
  99  104              Result.runresults['SKIP'] += 1
 100  105          elif self.returncode is not 0:
 101  106              self.result = 'FAIL'
 102  107              Result.runresults['FAIL'] += 1
      108 +            retcode = 1;
 103  109  
 104  110  
 105  111  class Output(object):
 106  112      """
 107  113      This class is a slightly modified version of the 'Stream' class found
 108  114      here: http://goo.gl/aSGfv
 109  115      """
 110  116      def __init__(self, stream):
 111  117          self.stream = stream
 112  118          self._buf = ''
↓ open down ↓ 770 lines elided ↑ open up ↑
 883  889      elif options.cmd is 'wrconfig':
 884  890          find_tests(testrun, options)
 885  891          testrun.write(options)
 886  892          exit(0)
 887  893      else:
 888  894          fail('Unknown command specified')
 889  895  
 890  896      testrun.complete_outputdirs()
 891  897      testrun.run(options)
 892  898      testrun.summary()
 893      -    exit(0)
      899 +    exit(retcode)
 894  900  
 895  901  
 896  902  if __name__ == '__main__':
 897  903      main()
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX