]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/workspace_tools/host_tests/detect_auto.py
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / workspace_tools / host_tests / detect_auto.py
1 """
2 mbed SDK
3 Copyright (c) 2011-2013 ARM Limited
4
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
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
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.
16 """
17
18 import re
19
20 class DetectPlatformTest():
21 PATTERN_MICRO_NAME = "Target '(\w+)'"
22 re_detect_micro_name = re.compile(PATTERN_MICRO_NAME)
23
24 def test(self, selftest):
25 result = True
26
27 c = selftest.mbed.serial_readline() # {{start}} preamble
28 if c is None:
29 return selftest.RESULT_IO_SERIAL
30
31 selftest.notify(c.strip())
32 selftest.notify("HOST: Detecting target name...")
33
34 c = selftest.mbed.serial_readline()
35 if c is None:
36 return selftest.RESULT_IO_SERIAL
37 selftest.notify(c.strip())
38
39 # Check for target name
40 m = self.re_detect_micro_name.search(c)
41 if m and len(m.groups()):
42 micro_name = m.groups()[0]
43 micro_cmp = selftest.mbed.options.micro == micro_name
44 result = result and micro_cmp
45 selftest.notify("HOST: MUT Target name '%s', expected '%s'... [%s]"% (micro_name,
46 selftest.mbed.options.micro,
47 "OK" if micro_cmp else "FAIL"))
48
49 for i in range(0, 2):
50 c = selftest.mbed.serial_readline()
51 if c is None:
52 return selftest.RESULT_IO_SERIAL
53 selftest.notify(c.strip())
54
55 return selftest.RESULT_SUCCESS if result else selftest.RESULT_FAILURE
Imprint / Impressum