diff options
author | Matthew Newhook <matthew@zeroc.com> | 2009-10-27 09:37:20 -0230 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2009-10-27 09:37:20 -0230 |
commit | 9221fdac67f6a2164e2365460cc99342bb02fa59 (patch) | |
tree | dd875126da36eb8ae2479454169d73e2d53649f1 /scripts/TestUtil.py | |
parent | Merge branch '4332' (diff) | |
download | ice-9221fdac67f6a2164e2365460cc99342bb02fa59.tar.bz2 ice-9221fdac67f6a2164e2365460cc99342bb02fa59.tar.xz ice-9221fdac67f6a2164e2365460cc99342bb02fa59.zip |
http://bugzilla/bugzilla/show_bug.cgi?id=4333
- Fix bug with the WatchdogThread, which caused hangs if the test failed.
- Get rid of TestUtil.cleanup()
Diffstat (limited to 'scripts/TestUtil.py')
-rwxr-xr-x | scripts/TestUtil.py | 59 |
1 files changed, 20 insertions, 39 deletions
diff --git a/scripts/TestUtil.py b/scripts/TestUtil.py index e5c80aa5116..92e8cb65d65 100755 --- a/scripts/TestUtil.py +++ b/scripts/TestUtil.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import sys, os, re, errno, getopt, time, StringIO, string, copy, threading, signal +import sys, os, re, getopt, time, StringIO, string, threading # Global flags and their default values. protocol = "" # If unset, default to TCP. Valid values are "tcp" or "ssl". @@ -501,10 +501,6 @@ def phpSetup(): tmpini.write("include_path=%s\n" % incDir) tmpini.close() -def phpCleanup(): - if os.path.exists("tmp.ini"): - os.remove("tmp.ini") - def getIceVersion(): config = open(os.path.join(toplevel, "config", "Make.common.rules"), "r") return re.search("VERSION[\t\s]*= ([0-9]+\.[0-9]+(\.[0-9]+|b[0-9]*))", config.read()).group(1) @@ -1122,30 +1118,26 @@ def getTestName(): class WatchDog(threading.Thread): def __init__(self): - self._done = False self._reset = False self._cv = threading.Condition() threading.Thread.__init__(self) - # - # Setup and install signal handlers - # - if signal.__dict__.has_key('SIGHUP'): - signal.signal(signal.SIGHUP, signal.SIG_DFL) - if signal.__dict__.has_key('SIGBREAK'): - signal.signal(signal.SIGBREAK, signal.SIG_DFL) - signal.signal(signal.SIGINT, signal.SIG_DFL) - signal.signal(signal.SIGTERM, signal.SIG_DFL) + # The thread is marked as a daemon thread. This is done so that if + # an expect script runs off the end of main without kill/wait on each + # spawned process the script will not hang tring to join with the + # reader thread. Instead __del__ (below) will be called which + # terminates and joins with the thread. + self.setDaemon(True) self.start() def run(self): self._cv.acquire() - while self._done == False: + while True: self._cv.wait(180) if self._reset: self._reset = False - elif not self._done: + else: print "\a*** %s Warning: Test has been inactive for 3 minutes and may be hung", time.strftime("%x %X") self._cv.release() @@ -1155,28 +1147,17 @@ class WatchDog(threading.Thread): self._cv.notify() self._cv.release() - def destroy(self): - self._cv.acquire() - self._done = True - self._cv.notify() - self._cv.release() - - def signalHandler(self, sig, frame): - self.destroy() - self.join() - signalHandler = classmethod(signalHandler) - -def cleanup(): - # Stop watch dog thread - global watchDog - if watchDog != None: - watchDog.destroy() - watchDog.join() - watchDog = None - - lang = getDefaultMapping() - if lang == "php": - phpCleanup() +class PhpCleanup: + def __del__(self): + if os.path.exists("tmp.ini"): + os.remove("tmp.ini") + +# TODO: Perhaps this should be done when the tmp.ini file is created. +lang = getDefaultMapping() +if getDefaultMapping() == "php": + # Instantiate a PhpCleanup object. The __del__ method will + # cleanup when the scritp is done. + p = PhpCleanup() def processCmdLine(): def usage(): |