Merge remote branch 'cros/upstream' into autotest-rebase
Merged to upstream trunk@5066, from trunk@4749.
There is no way I could enlist each individual CL from the upstream here since it will blow up the changelist description field.
BUG=
TEST=
Had patched this CL into a fresh cut client to avoid any side effect.
run_remote_test bvt from both emerged location and third_party/autotest/file.
Both test passed!
We should also keep any eye on this to see how it gets propagated into cautotest server.
TBR=dalecurtis
Change-Id: I72f2bc7a9de530178484aea1bfb5ace68bcad029
diff --git a/client/common_lib/base_job.py b/client/common_lib/base_job.py
index 3c77d38..4a2271c 100644
--- a/client/common_lib/base_job.py
+++ b/client/common_lib/base_job.py
@@ -422,6 +422,9 @@
TIMESTAMP_FIELD = 'timestamp'
LOCALTIME_FIELD = 'localtime'
+ # non-space whitespace is forbidden in any fields
+ BAD_CHAR_REGEX = re.compile(r'[\t\n\r\v\f]')
+
def __init__(self, status_code, subdir, operation, message, fields,
timestamp=None):
"""Construct a status.log entry.
@@ -439,18 +442,16 @@
@raise ValueError: if any of the parameters are invalid
"""
- # non-space whitespace is forbidden in any fields
- bad_char_regex = r'[\t\n\r\v\f]'
if not log.is_valid_status(status_code):
raise ValueError('status code %r is not valid' % status_code)
self.status_code = status_code
- if subdir and re.search(bad_char_regex, subdir):
+ if subdir and self.BAD_CHAR_REGEX.search(subdir):
raise ValueError('Invalid character in subdir string')
self.subdir = subdir
- if operation and re.search(bad_char_regex, operation):
+ if operation and self.BAD_CHAR_REGEX.search(operation):
raise ValueError('Invalid character in operation string')
self.operation = operation
@@ -460,7 +461,7 @@
message_lines = message.split('\n')
self.message = message_lines[0].replace('\t', ' ' * 8)
self.extra_message_lines = message_lines[1:]
- if re.search(bad_char_regex, self.message):
+ if self.BAD_CHAR_REGEX.search(self.message):
raise ValueError('Invalid character in message %r' % self.message)
if not fields:
@@ -468,7 +469,7 @@
else:
self.fields = fields.copy()
for key, value in self.fields.iteritems():
- if re.search(bad_char_regex, key + value):
+ if self.BAD_CHAR_REGEX.search(key + value):
raise ValueError('Invalid character in %r=%r field'
% (key, value))