Refactored detection test to use new autodetection of host test

pull/900/head
Przemek Wirkus 2015-01-27 13:24:11 +00:00
parent d610f0b08a
commit dcce4d7cde
4 changed files with 26 additions and 23 deletions

View File

@ -2,9 +2,14 @@
#include "test_env.h" #include "test_env.h"
int main() { int main() {
TEST_TIMEOUT(10);
TEST_HOSTTEST(detect_auto);
TEST_DESCRIPTION(Simple detect test);
TEST_START("DTCT_1");
notify_start(); notify_start();
printf("MBED: Target '%s'\r\n", TEST_SUITE_TARGET_NAME); printf("MBED: Target '%s'\r\n", TEST_SUITE_TARGET_NAME);
printf("MBED: Test ID '%s'\r\n", TEST_SUITE_TEST_ID); printf("MBED: Test ID '%s'\r\n", TEST_SUITE_TEST_ID);
printf("MBED: UUID '%s'\r\n", TEST_SUITE_UUID); printf("MBED: UUID '%s'\r\n", TEST_SUITE_UUID);
notify_completion(true); TEST_RESULT(true);
} }

View File

@ -23,6 +23,7 @@ from stdio_auto import StdioTest
from dev_null_auto import DevNullTest from dev_null_auto import DevNullTest
from rtc_auto import RTCTest from rtc_auto import RTCTest
from echo import EchoTest from echo import EchoTest
from detect_auto import DetectPlatformTest
HOSTREGISTRY = HostRegistry() HOSTREGISTRY = HostRegistry()
@ -34,6 +35,7 @@ HOSTREGISTRY.register_host_test("stdio_auto", StdioTest())
HOSTREGISTRY.register_host_test("dev_null_auto", DevNullTest()) HOSTREGISTRY.register_host_test("dev_null_auto", DevNullTest())
HOSTREGISTRY.register_host_test("rtc_auto", RTCTest()) HOSTREGISTRY.register_host_test("rtc_auto", RTCTest())
HOSTREGISTRY.register_host_test("echo", EchoTest()) HOSTREGISTRY.register_host_test("echo", EchoTest())
HOSTREGISTRY.register_host_test("detect_auto", DetectPlatformTest())
############################################################################### ###############################################################################
# Functional interface for test supervisor registry # Functional interface for test supervisor registry

View File

@ -16,44 +16,40 @@ limitations under the License.
""" """
import re import re
from host_test import DefaultTest
class DetectPlatformTest():
class DetectPlatformTest(DefaultTest):
PATTERN_MICRO_NAME = "Target '(\w+)'" PATTERN_MICRO_NAME = "Target '(\w+)'"
re_detect_micro_name = re.compile(PATTERN_MICRO_NAME) re_detect_micro_name = re.compile(PATTERN_MICRO_NAME)
def test(self): def test(self, selftest):
result = True result = True
c = self.mbed.serial_readline() # {{start}} preamble c = selftest.mbed.serial_readline() # {{start}} preamble
if c is None: if c is None:
return self.RESULT_IO_SERIAL return selftest.RESULT_IO_SERIAL
self.notify(c.strip()) selftest.notify(c.strip())
self.notify("HOST: Detecting target name...") selftest.notify("HOST: Detecting target name...")
c = self.mbed.serial_readline() c = selftest.mbed.serial_readline()
if c is None: if c is None:
return self.RESULT_IO_SERIAL return selftest.RESULT_IO_SERIAL
self.notify(c.strip()) selftest.notify(c.strip())
# Check for target name # Check for target name
m = self.re_detect_micro_name.search(c) m = self.re_detect_micro_name.search(c)
if m and len(m.groups()): if m and len(m.groups()):
micro_name = m.groups()[0] micro_name = m.groups()[0]
micro_cmp = self.mbed.options.micro == micro_name micro_cmp = selftest.mbed.options.micro == micro_name
result = result and micro_cmp result = result and micro_cmp
self.notify("HOST: MUT Target name '%s', expected '%s'... [%s]"% (micro_name, self.mbed.options.micro, "OK" if micro_cmp else "FAIL")) selftest.notify("HOST: MUT Target name '%s', expected '%s'... [%s]"% (micro_name,
selftest.mbed.options.micro,
"OK" if micro_cmp else "FAIL"))
for i in range(0, 2): for i in range(0, 2):
c = self.mbed.serial_readline() c = selftest.mbed.serial_readline()
if c is None: if c is None:
return self.RESULT_IO_SERIAL return selftest.RESULT_IO_SERIAL
self.notify(c.strip()) selftest.notify(c.strip())
return self.RESULT_SUCCESS if result else self.RESULT_FAILURE return selftest.RESULT_SUCCESS if result else selftest.RESULT_FAILURE
if __name__ == '__main__':
DetectPlatformTest().run()

View File

@ -906,7 +906,7 @@ TESTS = [
"source_dir": join(TEST_DIR, "mbed", "detect"), "source_dir": join(TEST_DIR, "mbed", "detect"),
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB], "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB],
"automated": True, "automated": True,
"host_test" : "detect_auto", #"host_test" : "detect_auto",
}, },
] ]