aboutsummaryrefslogtreecommitdiff
path: root/dejagnu
diff options
context:
space:
mode:
authorCaroline Tice <cmtice@google.com>2016-07-22 16:28:12 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-07-27 07:23:18 -0700
commit9099a788cd7124024559c064e425ed9caef6e0ac (patch)
tree87df663ff83ab398121cd66e9528422979a63cf6 /dejagnu
parent19e119b46c14f57988ba3504369e815d3aab0122 (diff)
downloadtoolchain-utils-9099a788cd7124024559c064e425ed9caef6e0ac.tar.gz
[crosperf] Clean up exceptions.
Found all instances of 'raise Exception' and changed them to raise something slightly more specific. Changed a few 'except Exception' statements appropriately as well. BUG=chromium:566255 TEST=None Change-Id: If2666bd55838342bc71431e5e6ab2157c2c9e125 Reviewed-on: https://chrome-internal-review.googlesource.com/270731 Commit-Ready: Caroline Tice <cmtice@google.com> Tested-by: Caroline Tice <cmtice@google.com> Reviewed-by: Yunlian Jiang <yunlian@google.com>
Diffstat (limited to 'dejagnu')
-rwxr-xr-xdejagnu/gdb_dejagnu.py24
-rwxr-xr-xdejagnu/run_dejagnu.py35
2 files changed, 30 insertions, 29 deletions
diff --git a/dejagnu/gdb_dejagnu.py b/dejagnu/gdb_dejagnu.py
index b6dcd6ac..c01d909b 100755
--- a/dejagnu/gdb_dejagnu.py
+++ b/dejagnu/gdb_dejagnu.py
@@ -63,17 +63,17 @@ def ProcessArguments(argv):
options, args = parser.parse_args(argv)
if not options.chromeos_root:
- raise Exception('Missing argument for --chromeos_root.')
+ raise SyntaxError('Missing argument for --chromeos_root.')
if not options.remote:
- raise Exception('Missing argument for --remote.')
+ raise SyntaxError('Missing argument for --remote.')
if not options.board:
- raise Exception('Missing argument for --board.')
+ raise SyntaxError('Missing argument for --board.')
if options.cleanup == 'mount' and not options.mount:
- raise Exception('--cleanup=\'mount\' not valid unless --mount is given.')
+ raise SyntaxError('--cleanup=\'mount\' not valid unless --mount is given.')
if options.cleanup and not (options.cleanup == 'mount' or
options.cleanup == 'chroot' or
options.cleanup == 'chromeos'):
- raise Exception('Invalid option value for --cleanup')
+ raise SyntaxError('Invalid option value for --cleanup')
return options
@@ -92,7 +92,7 @@ class DejagnuExecuter(object):
## Compute target from board
self._target = misc.GetCtargetFromBoard(board, chromeos_root)
if not self._target:
- raise Exception('Unsupported board "%s"' % board)
+ raise RuntimeError('Unsupported board "%s"' % board)
self._executer = command_executer.GetCommandExecuter()
self._base_dir = base_dir
self._tmp_abs = None
@@ -180,7 +180,7 @@ class DejagnuExecuter(object):
if matcher:
gdb_reversion = matcher.group(1)
else:
- raise Exception('Failed to get gdb reversion.')
+ raise RuntimeError('Failed to get gdb reversion.')
gdb_version = gdb_reversion.split('-r')[0]
gdb_portage_dir = '/var/tmp/portage/cross-%s/%s/work' % (self._target,
gdb_reversion)
@@ -190,7 +190,7 @@ class DejagnuExecuter(object):
'sudo %s ebuild $(equery w cross-%s/gdb) clean compile' % (
self._mount_flag, self._target)))
if ret:
- raise Exception('ebuild gdb failed.')
+ raise RuntimeError('ebuild gdb failed.')
def PrepareGdbserver(self):
self.PrepareGdbserverDefault()
@@ -202,7 +202,7 @@ class DejagnuExecuter(object):
cmd,
print_to_console=True)
if ret:
- raise Exception('ebuild gdbserver failed.')
+ raise RuntimeError('ebuild gdbserver failed.')
cmd = ('scp -i {0} {1} '
'/build/{2}/usr/bin/gdbserver root@{3}:/usr/local/bin/'.format(
@@ -211,7 +211,7 @@ class DejagnuExecuter(object):
cmd,
print_to_console=True)
if ret:
- raise Exception('copy gdbserver failed.')
+ raise RuntimeError('copy gdbserver failed.')
if self._mount_flag:
self.MountSource(unmount=False)
@@ -257,7 +257,7 @@ class DejagnuExecuter(object):
path.join(self._tmp, 'site.exp')))
ret = self._executer.ChrootRunCommand(self._chromeos_root, cmd)
if ret:
- raise Exception('Make check failed.')
+ raise RuntimeError('Make check failed.')
# This method ensures necessary mount points before executing chroot comamnd.
def MountSource(self, unmount=False):
@@ -272,7 +272,7 @@ class DejagnuExecuter(object):
mount))
rv = self._executer.RunCommand(cmd)
if rv:
- raise Exception('Mount source failed.')
+ raise RuntimeError('Mount source failed.')
def ResultValidate(self):
self.PrepareResult()
diff --git a/dejagnu/run_dejagnu.py b/dejagnu/run_dejagnu.py
index b0f52c1c..b4cbc8f4 100755
--- a/dejagnu/run_dejagnu.py
+++ b/dejagnu/run_dejagnu.py
@@ -89,19 +89,19 @@ def ProcessArguments(argv):
options, args = parser.parse_args(argv)
if not options.chromeos_root:
- raise Exception('Missing argument for --chromeos_root.')
+ raise SyntaxError('Missing argument for --chromeos_root.')
if not options.remote:
- raise Exception('Missing argument for --remote.')
+ raise SyntaxError('Missing argument for --remote.')
if not options.board:
- raise Exception('Missing argument for --board.')
+ raise SyntaxError('Missing argument for --board.')
if options.cleanup == 'mount' and not options.mount:
- raise Exception('--cleanup=\'mount\' not valid unless --mount is given.')
+ raise SyntaxError('--cleanup=\'mount\' not valid unless --mount is given.')
if options.cleanup and not (
options.cleanup == 'mount' or \
options.cleanup == 'chroot' or options.cleanup == 'chromeos'):
- raise Exception('Invalid option value for --cleanup')
+ raise ValueError('Invalid option value for --cleanup')
if options.cleanup and options.keep_intermediate_files:
- raise Exception('Only one of --keep and --cleanup could be given.')
+ raise SyntaxError('Only one of --keep and --cleanup could be given.')
return options
@@ -125,7 +125,7 @@ class DejagnuExecuter(object):
## Compute target from board
self._target = misc.GetCtargetFromBoard(board, chromeos_root)
if not self._target:
- raise Exception('Unsupported board "%s"' % board)
+ raise ValueError('Unsupported board "%s"' % board)
self._executer = command_executer.GetCommandExecuter()
self._flags = flags or ''
self._base_dir = base_dir
@@ -250,11 +250,11 @@ class DejagnuExecuter(object):
if not path.isdir(self._gcc_source_dir_abs) and \
self._executer.RunCommand(
'sudo mkdir -p {0}'.format(self._gcc_source_dir_abs)):
- raise Exception("Failed to create \'{0}\' inside chroot.".format(
+ raise RuntimeError("Failed to create \'{0}\' inside chroot.".format(
self._gcc_source_dir))
if not (path.isdir(self._gcc_source_dir_to_mount) and
path.isdir(path.join(self._gcc_source_dir_to_mount, 'gcc'))):
- raise Exception('{0} is not a valid gcc source tree.'.format(
+ raise RuntimeError('{0} is not a valid gcc source tree.'.format(
self._gcc_source_dir_to_mount))
# We have these build directories -
@@ -277,11 +277,11 @@ class DejagnuExecuter(object):
if not path.isdir(self._gcc_top_build_dir_abs) and \
self._executer.RunCommand(
'sudo mkdir -p {0}'.format(self._gcc_top_build_dir_abs)):
- raise Exception('Failed to create \'{0}\' inside chroot.'.format(
+ raise RuntimeError('Failed to create \'{0}\' inside chroot.'.format(
self._gcc_top_build_dir))
if not (path.isdir(self._gcc_build_dir_to_mount) and path.join(
self._gcc_build_dir_to_mount, 'gcc')):
- raise Exception('{0} is not a valid gcc build tree.'.format(
+ raise RuntimeError('{0} is not a valid gcc build tree.'.format(
self._gcc_build_dir_to_mount))
# All check passed. Now mount gcc source and build directories.
@@ -301,7 +301,7 @@ class DejagnuExecuter(object):
gccrevision = 'gcc-9999'
gccversion = 'gcc-9999'
else:
- raise Exception('Failed to get gcc version.')
+ raise RuntimeError('Failed to get gcc version.')
gcc_portage_dir = '/var/tmp/portage/cross-%s/%s/work' % (self._target,
gccrevision)
@@ -316,7 +316,7 @@ class DejagnuExecuter(object):
'ebuild $(equery w cross-%s/gcc) clean prepare compile' % (
self._target)))
if ret:
- raise Exception('ebuild gcc failed.')
+ raise RuntimeError('ebuild gcc failed.')
def MakeCheck(self):
self.MountGccSourceAndBuildDir()
@@ -351,12 +351,13 @@ class DejagnuExecuter(object):
for mp in mount_points:
if unmount:
if mp.UnMount():
- raise Exception('Failed to unmount {0}'.format(mp.mount_dir))
+ raise RuntimeError('Failed to unmount {0}'.format(mp.mount_dir))
else:
self._l.LogOutput('{0} unmounted successfully.'.format(mp.mount_dir))
elif mp.DoMount():
- raise Exception('Failed to mount {0} onto {1}'.format(mp.external_dir,
- mp.mount_dir))
+ raise RuntimeError(
+ 'Failed to mount {0} onto {1}'.format(mp.external_dir,
+ mp.mount_dir))
else:
self._l.LogOutput('{0} mounted successfully.'.format(mp.mount_dir))
@@ -374,7 +375,7 @@ def TryAcquireMachine(remotes):
logger.GetLogger().LogWarning(
'*** Failed to lock machine \'{0}\'.'.format(r))
if not available_machine:
- raise Exception("Failed to acquire one machine from \'{0}\'.".format(
+ raise RuntimeError("Failed to acquire one machine from \'{0}\'.".format(
remotes))
return available_machine