summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorU. Artie Eoff <ullysses.a.eoff@intel.com>2011-02-07 18:54:58 -0800
committerChad Versace <chad.versace@intel.com>2011-02-10 13:38:24 -0800
commitb1b56d97061e561800f73b9243ecffe562f23652 (patch)
treeb162665c57e61e9475a01a3341fc550409cf2455 /framework
parent05a710bcfa3c9799d99fd53c802fd569191681f7 (diff)
Modify the Test class in core.py to use ThreadPools.
Modify Test class to use ThreadPools in its doRun method. All tests now execute in the default ThreadPool named 'base'. A Test instance can be configured to run in a different (named) ThreadPool instance by setting its poolName member variable to that name.
Diffstat (limited to 'framework')
-rw-r--r--framework/core.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/framework/core.py b/framework/core.py
index d363a342..0e0aca99 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -33,6 +33,8 @@ import time
import traceback
from log import log
from cStringIO import StringIO
+from threads import ThreadPools
+import threading
__all__ = [
'Environment',
@@ -289,13 +291,18 @@ class Test:
ignoreErrors = []
sleep = 0
- def __init__(self):
- pass
+ def __init__(self, poolName = "base"):
+ self.poolName = poolName
def run(self):
raise NotImplementedError
def doRun(self, env, path):
+ if ThreadPools().lookup(self.poolName) is None:
+ ThreadPools().create(self.poolName)
+ ThreadPools().put(self.__doRunWork, args = (env, path,), name = self.poolName)
+
+ def __doRunWork(self, env, path):
# Exclude tests that don't match the filter regexp
if len(env.filter) > 0:
if not True in map(lambda f: f.search(path) != None, env.filter):
@@ -380,6 +387,7 @@ class TestProfile:
def run(self, env):
time_start = time.time()
self.tests.doRun(env, '')
+ ThreadPools().joinAll()
time_end = time.time()
print >>env.file, "time:",(time_end-time_start)