~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to tests/lib/sys_mgmt/logging_management.py

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-10-29 15:43:40 UTC
  • mfrom: (1.2.12) (2.1.19 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131029154340-2gp39el6cv8bwf2o
Tags: 1:7.2.3-2ubuntu1
* Merge from debian, remaining changes:
  - Link against boost_system because of boost_thread.
  - Add required libs to message/include.am
  - Add upstart job and adjust init script to be upstart compatible.
  - Disable -floop-parallelize-all due to gcc-4.8/4.9 compiler ICE
    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57732

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
    def __init__(self, variables):
50
50
 
51
51
        self.log_file = sys.stdout
 
52
        self.subunit_file = variables['subunitoutfile']
52
53
        self.report_fmt = '{0:<42} {1} {2:>8}'
53
54
        self.report_started = 0
54
55
        self.thick_line = '='*(80 - len("20110420-105402  "))
55
56
        self.thin_line = '-'*(80- len("20110420-105402  "))
56
57
        self.verbose_flag = variables['verbose']
57
58
        self.debug_flag = variables['debug']
 
59
        self.test_debug_flag = variables['testdebug']
58
60
 
59
61
    def _write_message(self,level, msg):
60
62
      self.log_file.write("%s %s %s\n" % (time.strftime("%Y%m%d-%H%M%S"), level, str(msg)))
82
84
    def debug(self,msg):
83
85
      if self.debug_flag:
84
86
          self._write_message("DEBUG", msg)
 
87
 
 
88
    def test_debug(self,msg):
 
89
        if self.test_debug_flag:
 
90
            self._write_message("TEST_DEBUG", msg)
85
91
 
86
92
    def debug_class(self,codeClass):
87
93
      if self.debug_flag:
123
129
    def write_thick_line(self):
124
130
        self._write_message("",self.thick_line)
125
131
 
126
 
 
127
 
 
128
 
 
 
132
    def subunit_start(self,test_name):
 
133
        """ We log a test being started for subunit output """
 
134
        with open(self.subunit_file,'a') as subunit_outfile:
 
135
            subunit_outfile.write("time: %sZ\n" %(time.strftime("%Y-%m-%d-%H:%M:%S")))
 
136
            subunit_outfile.write("test: %s\n" %(test_name))
 
137
 
 
138
    def subunit_stop(self, test_name, retcode, output):
 
139
        """ We log the return of a test appropriately:
 
140
            success, skip, failure, etc
 
141
 
 
142
        """
 
143
        result_map = {'pass':'success'
 
144
                     ,'fail':'failure'
 
145
                     }
 
146
        result = result_map[retcode]
 
147
        with open(self.subunit_file,'a') as subunit_outfile:
 
148
            subunit_outfile.write(time.strftime("time: %Y-%m-%d-%H:%M:%SZ\n"))
 
149
            if output:
 
150
                output_string = " [\n%s]\n" %(output)
 
151
            else:
 
152
                output_string = "\n" # we just want a newline if nothing here 
 
153
            subunit_outfile.write("%s: %s%s" %( result
 
154
                                              , test_name
 
155
                                              , output_string))
 
156
            
 
157