Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Unified Diff: client/site_tests/power_Resume/power_Resume.py

Issue 3417014: retry log parsing for suspend/resume event messages (Closed) Base URL: http://git.chromium.org/git/autotest.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/site_tests/power_Resume/power_Resume.py
diff --git a/client/site_tests/power_Resume/power_Resume.py b/client/site_tests/power_Resume/power_Resume.py
index 30cb2ae6ebf545c8eefef4cd9f67ed71179ba301..fe74b15cfbb726bc8281293ce83a06cf23f7709c 100644
--- a/client/site_tests/power_Resume/power_Resume.py
+++ b/client/site_tests/power_Resume/power_Resume.py
@@ -12,11 +12,25 @@ class power_Resume(test.test):
def _get_last_msg_time(self, msg):
- data = commands.getoutput(
- "grep -a '%s' /var/log/messages | tail -n 1" % msg)
+ cmd = "grep -a '%s' /var/log/messages | tail -n 1" % msg
+ # The order in which processes are un-frozen is indeterminate
+ # and therfore this test may get resumed before the system has gotten
+ # a chance to finalize writes to logfile. Sleep a bit to take care of
+ # this race.
+ count = 0
+ data = commands.getoutput(cmd)
+ while len(data) == 0 and count < 5:
+ count +=1
+ time.sleep(1)
+ data = commands.getoutput(cmd)
+
+ if count == 5:
+ raise error.TestError("Failed to find log message: " + msg)
+
match = re.search(r' \[\s*([0-9.]+)\] ', data)
if match is None:
- raise error.TestError('Failed to find log message: ' + msg)
+ raise error.TestError('Failed to find timestamp for log message: '
+ + msg)
msg_time = float(match.group(1))
logging.debug("Last message '%s' time = %f" % (msg, msg_time))
@@ -98,19 +112,6 @@ class power_Resume(test.test):
end_suspend_time = self._get_end_suspend_time()
end_resume_time = self._get_end_resume_time()
- # The order in which processes are un-frozen is indeterminate
- # and therfore this test may get resumed before the system has gotten
- # a chance to write the end resume message. Sleep for a short time
- # to take care of this race.
- count = 0
- while end_resume_time < start_suspend_time and count < 5:
- count += 1
- time.sleep(1)
- end_resume_time = self._get_end_resume_time()
-
- if count == 5:
- raise error.TestError('Failed to find end resume time')
-
# Calculate the suspend/resume times
total_resume_time = self._get_hwclock_seconds() - alarm_time
suspend_time = end_suspend_time - start_suspend_time
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698