mirror of https://github.com/ARMmbed/mbed-os.git
Refactored detection test to use new autodetection of host test
parent
d610f0b08a
commit
dcce4d7cde
|
@ -2,9 +2,14 @@
|
|||
#include "test_env.h"
|
||||
|
||||
int main() {
|
||||
TEST_TIMEOUT(10);
|
||||
TEST_HOSTTEST(detect_auto);
|
||||
TEST_DESCRIPTION(Simple detect test);
|
||||
TEST_START("DTCT_1");
|
||||
|
||||
notify_start();
|
||||
printf("MBED: Target '%s'\r\n", TEST_SUITE_TARGET_NAME);
|
||||
printf("MBED: Test ID '%s'\r\n", TEST_SUITE_TEST_ID);
|
||||
printf("MBED: UUID '%s'\r\n", TEST_SUITE_UUID);
|
||||
notify_completion(true);
|
||||
TEST_RESULT(true);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ from stdio_auto import StdioTest
|
|||
from dev_null_auto import DevNullTest
|
||||
from rtc_auto import RTCTest
|
||||
from echo import EchoTest
|
||||
from detect_auto import DetectPlatformTest
|
||||
|
||||
|
||||
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("rtc_auto", RTCTest())
|
||||
HOSTREGISTRY.register_host_test("echo", EchoTest())
|
||||
HOSTREGISTRY.register_host_test("detect_auto", DetectPlatformTest())
|
||||
|
||||
###############################################################################
|
||||
# Functional interface for test supervisor registry
|
||||
|
|
|
@ -16,44 +16,40 @@ limitations under the License.
|
|||
"""
|
||||
|
||||
import re
|
||||
from host_test import DefaultTest
|
||||
|
||||
|
||||
class DetectPlatformTest(DefaultTest):
|
||||
class DetectPlatformTest():
|
||||
PATTERN_MICRO_NAME = "Target '(\w+)'"
|
||||
re_detect_micro_name = re.compile(PATTERN_MICRO_NAME)
|
||||
|
||||
def test(self):
|
||||
def test(self, selftest):
|
||||
result = True
|
||||
|
||||
c = self.mbed.serial_readline() # {{start}} preamble
|
||||
c = selftest.mbed.serial_readline() # {{start}} preamble
|
||||
if c is None:
|
||||
return self.RESULT_IO_SERIAL
|
||||
return selftest.RESULT_IO_SERIAL
|
||||
|
||||
self.notify(c.strip())
|
||||
self.notify("HOST: Detecting target name...")
|
||||
selftest.notify(c.strip())
|
||||
selftest.notify("HOST: Detecting target name...")
|
||||
|
||||
c = self.mbed.serial_readline()
|
||||
c = selftest.mbed.serial_readline()
|
||||
if c is None:
|
||||
return self.RESULT_IO_SERIAL
|
||||
self.notify(c.strip())
|
||||
return selftest.RESULT_IO_SERIAL
|
||||
selftest.notify(c.strip())
|
||||
|
||||
# Check for target name
|
||||
m = self.re_detect_micro_name.search(c)
|
||||
if m and len(m.groups()):
|
||||
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
|
||||
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):
|
||||
c = self.mbed.serial_readline()
|
||||
c = selftest.mbed.serial_readline()
|
||||
if c is None:
|
||||
return self.RESULT_IO_SERIAL
|
||||
self.notify(c.strip())
|
||||
return selftest.RESULT_IO_SERIAL
|
||||
selftest.notify(c.strip())
|
||||
|
||||
return self.RESULT_SUCCESS if result else self.RESULT_FAILURE
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
DetectPlatformTest().run()
|
||||
return selftest.RESULT_SUCCESS if result else selftest.RESULT_FAILURE
|
||||
|
|
|
@ -906,7 +906,7 @@ TESTS = [
|
|||
"source_dir": join(TEST_DIR, "mbed", "detect"),
|
||||
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB],
|
||||
"automated": True,
|
||||
"host_test" : "detect_auto",
|
||||
#"host_test" : "detect_auto",
|
||||
},
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in New Issue