2
# -*- mode: python; indent-tabs-mode: nil; -*-
3
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5
# Copyright (C) 2010 Patrick Crews
8
# This program is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 2 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program; if not, write to the Free Software
20
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
""" dtr_test_execution:
23
code related to the execution of dtr test cases
25
We are provided access to a testManager with
26
dtr-specific testCases. We contact teh executionManager
27
to produce the system and server configurations we need
38
import lib.test_mgmt.test_execution as test_execution
40
class testExecutor(test_execution.testExecutor):
41
""" dtr-specific testExecutor
42
We currently execute by sending test-case
43
data to client/drizzletest...for now
47
def execute_testCase (self):
48
""" Execute a dtr testCase via calls to drizzletest (boo)
49
Eventually, we will replace drizzletest with pythonic
50
goodness, but we have these classes stored here for the moment
53
test_execution.testExecutor.execute_testCase(self)
56
# generate command line
57
drizzletest_cmd = self.generate_drizzletest_call()
60
self.execute_drizzletest(drizzletest_cmd)
63
self.current_test_status = self.process_drizzletest_output()
64
self.set_server_status(self.current_test_status)
67
def generate_drizzletest_call(self):
68
""" Produce the command line we use to call drizzletest
69
We have a healthy number of values, so we put this in a
74
drizzletest_arguments = [ '--no-defaults'
76
, '--tmpdir=%s' %(self.master_server.tmpdir)
77
, '--logdir=%s' %(self.master_server.logdir)
78
, '--port=%d' %(self.master_server.master_port)
82
#, '--testdir=%s' %(self.test_manager.testdir)
83
, '--test-file=%s' %(self.current_testcase.testpath)
85
, '--timer-file=%s' %(self.master_server.timer_file)
86
, '--result-file=%s' %(self.current_testcase.resultpath)
89
# We want to record a new result
90
drizzletest_arguments.append('--record')
91
drizzletest_cmd = "%s %s %s" %( self.cmd_prefix
92
, self.master_server.code_tree.drizzletest
93
, " ".join(drizzletest_arguments))
94
return drizzletest_cmd
96
def execute_drizzletest(self, drizzletest_cmd):
97
""" Execute the commandline and return the result.
98
We use subprocess as we can pass os.environ dicts and whatnot
101
testcase_name = self.current_testcase.fullname
102
self.time_manager.start(testcase_name,'test')
103
#retcode, output = self.system_manager.execute_cmd( drizzletest_cmd
105
drizzletest_outfile = os.path.join(self.logdir,'drizzletest.out')
106
drizzletest_output = open(drizzletest_outfile,'w')
107
drizzletest_subproc = subprocess.Popen( drizzletest_cmd
109
, cwd=self.system_manager.testdir
110
, env=self.working_environment
111
, stdout = drizzletest_output
112
, stderr = subprocess.STDOUT
114
drizzletest_subproc.wait()
115
retcode = drizzletest_subproc.returncode
116
execution_time = int(self.time_manager.stop(testcase_name)*1000) # millisec
118
drizzletest_output.close()
119
drizzletest_file = open(drizzletest_outfile,'r')
120
output = ''.join(drizzletest_file.readlines())
121
drizzletest_file.close()
123
self.logging.debug("drizzletest_retcode: %d" %(retcode))
124
self.current_test_retcode = retcode
125
self.current_test_output = output
126
self.current_test_exec_time = execution_time
128
def process_drizzletest_output(self):
129
""" Drizzletest has run, we now check out what we have """
130
retcode = self.current_test_retcode
133
elif retcode == 62 or retcode == 15872:
135
elif retcode == 63 or retcode == 1: