3 Copyright (c) 2011-2013 ARM Limited
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
19 from time
import time, strftime, gmtime
20 from mbed_host_tests
import BaseHostTest
23 PATTERN_RTC_VALUE =
"\[(\d+)\] \[(\d+-\d+-\d+ \d+:\d+:\d+ [AaPpMm]{2})\]"
24 re_detect_rtc_value = re.compile(PATTERN_RTC_VALUE)
30 def _callback_timestamp(self, key, value, timestamp):
33 def _callback_rtc(self, key, value, timestamp):
34 self.
rtc_readsrtc_reads.append((key, value, timestamp))
36 def _callback_end(self, key, value, timestamp):
37 self.notify_complete()
41 self.register_callback(
'rtc', self.
_callback_rtc_callback_rtc)
42 self.register_callback(
'end', self.
_callback_end_callback_end)
45 def check_strftimes_format(t):
47 if m
and len(m.groups()):
48 sec, time_str = int(m.groups()[0]), m.groups()[1]
49 correct_time_str = strftime(
"%Y-%m-%d %H:%M:%S", gmtime(float(sec)))
50 return time_str == correct_time_str
53 ts = [t
for _, t, _
in self.
rtc_readsrtc_reads]
54 self.
__result__result = all(filter(check_strftimes_format, ts))
def _callback_timestamp(self, key, value, timestamp)
def _callback_end(self, key, value, timestamp)
def _callback_rtc(self, key, value, timestamp)