Smarter way that tests handle default exceptions (unhandled errors) and also a cleanup on test exception classes.
From: rxaviers@br.ibm.com
git-svn-id: http://test.kernel.org/svn/autotest/trunk@1899 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/bin/job.py b/client/bin/job.py
index fbd5fdd..07c739f 100755
--- a/client/bin/job.py
+++ b/client/bin/job.py
@@ -252,7 +252,7 @@
os.chdir(os.path.join(self.autodir, 'deps', dep))
utils.system('./' + dep + '.py')
except Exception, e:
- raise error.UnhandledError(e)
+ raise error.UnhandledTestError(e)
def _runtest(self, url, tag, args, dargs):
@@ -260,10 +260,10 @@
l = lambda : test.runtest(self, url, tag, args, dargs)
pid = parallel.fork_start(self.resultdir, l)
parallel.fork_waitfor(self.resultdir, pid)
- except error.AutotestError:
+ except error.TestBaseException:
raise
except Exception, e:
- raise error.UnhandledError(e)
+ raise error.UnhandledTestError(e)
def run_test(self, url, *args, **dargs):
@@ -322,8 +322,7 @@
def group_func():
try:
self._runtest(url, tag, args, dargs)
- except (error.TestNAError, error.TestUnknownError, error.TestError,
- error.TestFail), detail:
+ except error.TestBaseException, detail:
self.record(detail.exit_status, subdir, testname,
str(detail))
raise
@@ -338,7 +337,7 @@
result, exc_info = self._rungroup(subdir, testname, group_func)
if container:
self.release_container()
- if exc_info and isinstance(exc_info[1], error.TestError):
+ if exc_info and isinstance(exc_info[1], error.TestBaseException):
return False
elif exc_info:
raise exc_info[0], exc_info[1], exc_info[2]
@@ -370,8 +369,7 @@
result = function(*args, **dargs)
self._decrement_group_level()
self.record('END GOOD', subdir, testname)
- except (error.TestNAError, error.TestError, error.TestFail,
- error.TestUnknownError), e:
+ except error.TestBaseException, e:
self._decrement_group_level()
self.record('END %s' % e.exit_status, subdir, testname, str(e))
except Exception, e:
diff --git a/client/bin/job_unittest.py b/client/bin/job_unittest.py
index fa23cb7..3d8abb7 100644
--- a/client/bin/job_unittest.py
+++ b/client/bin/job_unittest.py
@@ -312,7 +312,7 @@
class MyError(error.TestError):
pass
real_error = MyError("this is the real error message")
- unhandled_error = error.UnhandledError(real_error)
+ unhandled_error = error.UnhandledTestError(real_error)
# set up the recording
testname = "error_test"
@@ -346,7 +346,7 @@
class MyError(Exception):
pass
real_error = MyError("this is the real error message")
- unhandled_error = error.UnhandledError(real_error)
+ unhandled_error = error.UnhandledTestError(real_error)
reason = first_line_comparator("Unhandled MyError: %s" % real_error)
# set up the recording
diff --git a/client/bin/parallel.py b/client/bin/parallel.py
index af890a5..e8749db 100644
--- a/client/bin/parallel.py
+++ b/client/bin/parallel.py
@@ -21,7 +21,7 @@
raise
except Exception, e:
- raise error.UnhandledError(e)
+ raise error.UnhandledTestError(e)
except Exception, detail:
ename = tmp + "/debug/error-%d" % (os.getpid())