Title: [197704] trunk/Tools
- Revision
- 197704
- Author
- [email protected]
- Date
- 2016-03-07 13:40:38 -0800 (Mon, 07 Mar 2016)
Log Message
webkitpy should verify timestamp from CrashLogs while collecting all crash logs
https://bugs.webkit.org/show_bug.cgi?id=155000
<rdar://problem/24860219>
Reviewed by Alexey Proskuryakov.
* Scripts/webkitpy/common/system/crashlogs.py:
(CrashLogs._find_all_logs_darwin): Make sure that crash log timestamp is within expected
time range, because file modification time is not always accurate.
(CrashLogs.get_timestamp_from_logs): Parse the timestamp from logs.
* Scripts/webkitpy/common/system/crashlogs_unittest.py:
(CrashLogsTest.test_get_timestamp_from_logs_darwin): Testcase for above function.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (197703 => 197704)
--- trunk/Tools/ChangeLog 2016-03-07 21:39:32 UTC (rev 197703)
+++ trunk/Tools/ChangeLog 2016-03-07 21:40:38 UTC (rev 197704)
@@ -1,3 +1,18 @@
+2016-03-07 Aakash Jain <[email protected]>
+
+ webkitpy should verify timestamp from CrashLogs while collecting all crash logs
+ https://bugs.webkit.org/show_bug.cgi?id=155000
+ <rdar://problem/24860219>
+
+ Reviewed by Alexey Proskuryakov.
+
+ * Scripts/webkitpy/common/system/crashlogs.py:
+ (CrashLogs._find_all_logs_darwin): Make sure that crash log timestamp is within expected
+ time range, because file modification time is not always accurate.
+ (CrashLogs.get_timestamp_from_logs): Parse the timestamp from logs.
+ * Scripts/webkitpy/common/system/crashlogs_unittest.py:
+ (CrashLogsTest.test_get_timestamp_from_logs_darwin): Testcase for above function.
+
2016-03-06 Alexey Proskuryakov <[email protected]>
build-webkit prints an error on iOS simulator bots
Modified: trunk/Tools/Scripts/webkitpy/common/system/crashlogs.py (197703 => 197704)
--- trunk/Tools/Scripts/webkitpy/common/system/crashlogs.py 2016-03-07 21:39:32 UTC (rev 197703)
+++ trunk/Tools/Scripts/webkitpy/common/system/crashlogs.py 2016-03-07 21:40:38 UTC (rev 197704)
@@ -29,6 +29,7 @@
import codecs
import re
+import datetime
class CrashLogs(object):
@@ -139,6 +140,13 @@
result_name = "Unknown"
pid = 0
log_contents = self._host.filesystem.read_text_file(path)
+ # Verify timestamp from log contents
+ crash_time = self.get_timestamp_from_log(log_contents)
+ if crash_time is not None and newer_than is not None:
+ start_time = datetime.datetime.fromtimestamp(float(newer_than))
+ if crash_time < start_time:
+ continue
+
match = first_line_regex.match(log_contents[0:log_contents.find('\n')])
if match:
process_name = match.group('process_name')
@@ -158,3 +166,14 @@
if include_errors and errors and len(crash_logs) == 0:
return errors
return crash_logs
+
+ def get_timestamp_from_log(self, log_contents):
+ date_match = re.search('Date/Time:\s+(.+?)\n', log_contents)
+ if not date_match:
+ return None
+ try:
+ crash_time_str = ' '.join(date_match.group(1).split(" ")[0:2])
+ crash_time = datetime.datetime.strptime(crash_time_str, '%Y-%m-%d %H:%M:%S.%f')
+ except ValueError:
+ return None
+ return crash_time
Modified: trunk/Tools/Scripts/webkitpy/common/system/crashlogs_unittest.py (197703 => 197704)
--- trunk/Tools/Scripts/webkitpy/common/system/crashlogs_unittest.py 2016-03-07 21:39:32 UTC (rev 197703)
+++ trunk/Tools/Scripts/webkitpy/common/system/crashlogs_unittest.py 2016-03-07 21:40:38 UTC (rev 197704)
@@ -336,3 +336,16 @@
filesystem.read_binary_file = bad_read
log = crash_logs.find_newest_log("DumpRenderTree", 28531, include_errors=True)
self.assertIn('IOError: No such file or directory', log)
+
+ def test_get_timestamp_from_logs_darwin(self):
+ if not SystemHost().platform.is_mac():
+ return
+
+ crash_report = make_mock_crash_report_darwin('DumpRenderTree', 28528)
+ crash_logs = CrashLogs(MockSystemHost())
+ crash_timestamp = crash_logs.get_timestamp_from_log(crash_report)
+ self.assertIn('2011-12-07 13:27:34.816', str(crash_timestamp))
+
+ crash_report = crash_report.replace("Date/Time", "")
+ crash_timestamp = crash_logs.get_timestamp_from_log(crash_report)
+ self.assertIsNone(crash_timestamp)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes