From 06848611d337c45814c676f77b42a399431ab0e4 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Mon, 26 Jan 2015 12:29:48 +0000 Subject: [PATCH 01/34] Added initial 'host test auto-detection API' --- libraries/tests/mbed/env/test_env.cpp | 23 ++++++++++++++++++++ libraries/tests/mbed/env/test_env.h | 30 +++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/libraries/tests/mbed/env/test_env.cpp b/libraries/tests/mbed/env/test_env.cpp index 10ab5064a1..a7d3185e54 100644 --- a/libraries/tests/mbed/env/test_env.cpp +++ b/libraries/tests/mbed/env/test_env.cpp @@ -56,6 +56,29 @@ bool notify_completion_str(bool success, char* buffer) return result; } +// Host test auto-detection API +void notify_host_test_name(const char *host_test) { + if (host_test) { + printf("{{host_test_name;%s}}" NL, host_test); + } +} + +void notify_timeout(int timeout) { + printf("{{timeout;%d}}" NL, timeout); +} + +void notify_test_id(const char *test_id) { + if (test_id) { + printf("{{test_id;%s}}" NL, test_id); + } +} + +void notify_test_description(const char *description) { + if (description) { + printf("{{description;%s}}" NL, description); + } +} + // -DMBED_BUILD_TIMESTAMP=1406208182.13 unsigned int testenv_randseed() diff --git a/libraries/tests/mbed/env/test_env.h b/libraries/tests/mbed/env/test_env.h index 90c9b76216..296ac78b36 100644 --- a/libraries/tests/mbed/env/test_env.h +++ b/libraries/tests/mbed/env/test_env.h @@ -22,6 +22,36 @@ void notify_performance_coefficient(const char* measurement_name, const int valu void notify_performance_coefficient(const char* measurement_name, const unsigned int value); void notify_performance_coefficient(const char* measurement_name, const double value); +// Host test auto-detection API +void notify_host_test_name(const char *host_test); +void notify_timeout(int timeout); +void notify_test_id(const char *test_id); +void notify_test_description(const char *description); + +// Host test auto-detection API +#define TEST_START(TESTID) notify_start(); notify_test_id(TESTID) +#define TEST_HOSTTEST(NAME) notify_host_test_name(#NAME) +#define TEST_TIMEOUT(SECONDS) notify_timeout(SECONDS) +#define TEST_DESCRIPTION(DESC) notify_test_description(#DESC) + +/** + Test auto-detection preamble example: + main() { + TEST_START("MBED_10"); + TEST_TIMEOUT(10); + TEST_HOSTTEST( host_test ); + TEST_DESCRIPTION(Hello World); + // Proper 'host_test.py' should take over supervising of this test + + // Test code + bool result = ...; + + + notify_completion(result); + } +*/ + + // Test functionality useful during testing unsigned int testenv_randseed(); From 6903b54b9e988ef11dea8d83479a0cc56964d68e Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 27 Jan 2015 12:10:16 +0000 Subject: [PATCH 02/34] Refactored generic tests with timer host test supervision Reactored RTOS tests --- libraries/tests/mbed/env/test_env.h | 8 ++--- libraries/tests/mbed/hello/main.cpp | 7 +++- libraries/tests/mbed/ticker/main.cpp | 6 ++++ libraries/tests/mbed/ticker_2/main.cpp | 7 ++++ libraries/tests/mbed/ticker_3/main.cpp | 7 ++++ libraries/tests/mbed/time_us/main.cpp | 6 ++++ libraries/tests/mbed/timeout/main.cpp | 19 +++++----- libraries/tests/rtos/mbed/basic/main.cpp | 9 +++-- libraries/tests/rtos/mbed/file/main.cpp | 16 +++++---- libraries/tests/rtos/mbed/isr/main.cpp | 7 +++- libraries/tests/rtos/mbed/mail/main.cpp | 7 +++- libraries/tests/rtos/mbed/mutex/main.cpp | 10 ++++-- libraries/tests/rtos/mbed/queue/main.cpp | 7 +++- libraries/tests/rtos/mbed/semaphore/main.cpp | 10 ++++-- libraries/tests/rtos/mbed/signals/main.cpp | 7 +++- libraries/tests/rtos/mbed/timer/main.cpp | 6 ++++ workspace_tools/host_tests/__init__.py | 25 ++++++++++++- workspace_tools/host_tests/default_auto.py | 36 +++++++++++++++++++ workspace_tools/host_tests/hello_auto.py | 26 ++++---------- workspace_tools/host_tests/host_registry.py | 36 +++++++++++++++++++ workspace_tools/host_tests/host_test.py | 36 +++++++++++++++++-- workspace_tools/host_tests/wait_us_auto.py | 38 +++++++++----------- workspace_tools/tests.py | 22 ++++++------ 23 files changed, 272 insertions(+), 86 deletions(-) create mode 100644 workspace_tools/host_tests/default_auto.py create mode 100644 workspace_tools/host_tests/host_registry.py diff --git a/libraries/tests/mbed/env/test_env.h b/libraries/tests/mbed/env/test_env.h index 296ac78b36..4aadae15c9 100644 --- a/libraries/tests/mbed/env/test_env.h +++ b/libraries/tests/mbed/env/test_env.h @@ -29,25 +29,25 @@ void notify_test_id(const char *test_id); void notify_test_description(const char *description); // Host test auto-detection API -#define TEST_START(TESTID) notify_start(); notify_test_id(TESTID) +#define TEST_START(TESTID) notify_test_id(TESTID); notify_start() #define TEST_HOSTTEST(NAME) notify_host_test_name(#NAME) #define TEST_TIMEOUT(SECONDS) notify_timeout(SECONDS) #define TEST_DESCRIPTION(DESC) notify_test_description(#DESC) +#define TEST_RESULT(RESULT) notify_completion(RESULT) /** Test auto-detection preamble example: main() { - TEST_START("MBED_10"); TEST_TIMEOUT(10); TEST_HOSTTEST( host_test ); TEST_DESCRIPTION(Hello World); + TEST_START("MBED_10"); // Proper 'host_test.py' should take over supervising of this test // Test code bool result = ...; - - notify_completion(result); + TEST_RESULT(result); } */ diff --git a/libraries/tests/mbed/hello/main.cpp b/libraries/tests/mbed/hello/main.cpp index 28e3e4975d..ca27438393 100644 --- a/libraries/tests/mbed/hello/main.cpp +++ b/libraries/tests/mbed/hello/main.cpp @@ -2,7 +2,12 @@ int main() { - notify_start(); + TEST_TIMEOUT(10); + TEST_HOSTTEST(hello_auto); + TEST_DESCRIPTION(Hello World); + TEST_START("MBED_10"); + printf("Hello World\r\n"); + while(1); } diff --git a/libraries/tests/mbed/ticker/main.cpp b/libraries/tests/mbed/ticker/main.cpp index c75c3ea087..7a97467e31 100644 --- a/libraries/tests/mbed/ticker/main.cpp +++ b/libraries/tests/mbed/ticker/main.cpp @@ -1,4 +1,5 @@ #include "mbed.h" +#include "test_env.h" void print_char(char c = '*') { @@ -32,6 +33,11 @@ void flip_2() { } int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(wait_us_auto); + TEST_DESCRIPTION(Ticker Int); + TEST_START("MBED_11"); + led1 = 0; led2 = 0; flipper_1.attach(&flip_1, 1.0); // the address of the function to be attached (flip) and the interval (1 second) diff --git a/libraries/tests/mbed/ticker_2/main.cpp b/libraries/tests/mbed/ticker_2/main.cpp index 928889417e..fdc55a954a 100644 --- a/libraries/tests/mbed/ticker_2/main.cpp +++ b/libraries/tests/mbed/ticker_2/main.cpp @@ -1,4 +1,5 @@ #include "mbed.h" +#include "test_env.h" Ticker tick; DigitalOut led(LED1); @@ -26,6 +27,12 @@ void togglePin(void) int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(wait_us_auto); + TEST_DESCRIPTION(Ticker Int us); + TEST_START("MBED_23"); + tick.attach_us(togglePin, 1000); + while (1); } diff --git a/libraries/tests/mbed/ticker_3/main.cpp b/libraries/tests/mbed/ticker_3/main.cpp index 60055ccf21..0a016c4b1c 100644 --- a/libraries/tests/mbed/ticker_3/main.cpp +++ b/libraries/tests/mbed/ticker_3/main.cpp @@ -1,4 +1,5 @@ #include "mbed.h" +#include "test_env.h" void ticker_callback_1(void); void ticker_callback_2(void); @@ -31,6 +32,12 @@ void ticker_callback_1(void) int main(void) { + TEST_TIMEOUT(15); + TEST_HOSTTEST(wait_us_auto); + TEST_DESCRIPTION(Ticker Two callbacks); + TEST_START("MBED_34"); + ticker.attach(ticker_callback_1, 1.0); + while(1); } diff --git a/libraries/tests/mbed/time_us/main.cpp b/libraries/tests/mbed/time_us/main.cpp index 32360c2494..4c8fbda77c 100644 --- a/libraries/tests/mbed/time_us/main.cpp +++ b/libraries/tests/mbed/time_us/main.cpp @@ -1,4 +1,5 @@ #include "mbed.h" +#include "test_env.h" DigitalOut led(LED1); @@ -14,6 +15,11 @@ void print_char(char c = '*') int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(wait_us_auto); + TEST_DESCRIPTION(Time us); + TEST_START("MBED_25"); + while (true) { for (int i = 0; i < MS_INTERVALS; i++) { wait_us(1000); diff --git a/libraries/tests/mbed/timeout/main.cpp b/libraries/tests/mbed/timeout/main.cpp index c5de8f0089..693438cb25 100644 --- a/libraries/tests/mbed/timeout/main.cpp +++ b/libraries/tests/mbed/timeout/main.cpp @@ -1,4 +1,5 @@ #include "mbed.h" +#include "test_env.h" Timeout timer; DigitalOut led(LED1); @@ -7,16 +8,14 @@ namespace { const int MS_INTERVALS = 1000; } -void print_char(char c = '*') -{ +void print_char(char c = '*') { printf("%c", c); fflush(stdout); } void toggleOff(void); -void toggleOn(void) -{ +void toggleOn(void) { static int toggle_counter = 0; if (toggle_counter == MS_INTERVALS) { led = !led; @@ -27,13 +26,17 @@ void toggleOn(void) timer.attach_us(toggleOff, 500); } -void toggleOff(void) -{ +void toggleOff(void) { timer.attach_us(toggleOn, 500); } -int main() -{ +int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(wait_us_auto); + TEST_DESCRIPTION(Timeout Int us); + TEST_START("MBED_24"); + toggleOn(); + while (1); } diff --git a/libraries/tests/rtos/mbed/basic/main.cpp b/libraries/tests/rtos/mbed/basic/main.cpp index f1cf79f573..4b286cbbc3 100644 --- a/libraries/tests/rtos/mbed/basic/main.cpp +++ b/libraries/tests/rtos/mbed/basic/main.cpp @@ -1,4 +1,5 @@ #include "mbed.h" +#include "test_env.h" #include "rtos.h" /* @@ -12,8 +13,7 @@ #define STACK_SIZE DEFAULT_STACK_SIZE #endif -void print_char(char c = '*') -{ +void print_char(char c = '*') { printf("%c", c); fflush(stdout); } @@ -30,6 +30,11 @@ void led2_thread(void const *argument) { } int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(wait_us_auto); + TEST_DESCRIPTION(Basic thread); + TEST_START("RTOS_1"); + Thread thread(led2_thread, NULL, osPriorityNormal, STACK_SIZE); while (true) { diff --git a/libraries/tests/rtos/mbed/file/main.cpp b/libraries/tests/rtos/mbed/file/main.cpp index 73485517ee..5c8c0f2ecd 100644 --- a/libraries/tests/rtos/mbed/file/main.cpp +++ b/libraries/tests/rtos/mbed/file/main.cpp @@ -46,7 +46,7 @@ void sd_thread(void const *argument) } fclose(f); } else { - notify_completion(false); + TEST_RESULT(false); return; } } @@ -65,7 +65,7 @@ void sd_thread(void const *argument) } fclose(f); } else { - notify_completion(false); + TEST_RESULT(false); return; } } @@ -74,15 +74,19 @@ void sd_thread(void const *argument) // check that the data written == data read for (int i = 0; i < SIZE; i++) { if (data_written[i] != data_read[i]) { - notify_completion(false); + TEST_RESULT(false); return; } } - notify_completion(true); + TEST_RESULT(true); } -int main() -{ +int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(SD File write-read); + TEST_START("RTOS_9"); + Thread t(sd_thread, NULL, osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25)); while (true) { diff --git a/libraries/tests/rtos/mbed/isr/main.cpp b/libraries/tests/rtos/mbed/isr/main.cpp index 2855b7cede..4dc681f40f 100644 --- a/libraries/tests/rtos/mbed/isr/main.cpp +++ b/libraries/tests/rtos/mbed/isr/main.cpp @@ -36,6 +36,11 @@ void queue_thread(void const *argument) { } int main (void) { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(ISR (Queue)); + TEST_START("RTOS_8"); + Thread thread(queue_thread, NULL, osPriorityNormal, STACK_SIZE); Ticker ticker; ticker.attach(queue_isr, 1.0); @@ -59,6 +64,6 @@ int main (void) { } } - notify_completion(result); + TEST_RESULT(result); return 0; } diff --git a/libraries/tests/rtos/mbed/mail/main.cpp b/libraries/tests/rtos/mbed/mail/main.cpp index 21aaf783bc..9a0e200db7 100644 --- a/libraries/tests/rtos/mbed/mail/main.cpp +++ b/libraries/tests/rtos/mbed/mail/main.cpp @@ -40,6 +40,11 @@ void send_thread (void const *argument) { } int main (void) { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(Mail messaging); + TEST_START("RTOS_6"); + Thread thread(send_thread, NULL, osPriorityNormal, STACK_SIZE); bool result = true; int result_counter = 0; @@ -65,6 +70,6 @@ int main (void) { } } } - notify_completion(result); + TEST_RESULT(result); return 0; } diff --git a/libraries/tests/rtos/mbed/mutex/main.cpp b/libraries/tests/rtos/mbed/mutex/main.cpp index 7f8987800f..fa85e87936 100644 --- a/libraries/tests/rtos/mbed/mutex/main.cpp +++ b/libraries/tests/rtos/mbed/mutex/main.cpp @@ -16,8 +16,7 @@ #define STACK_SIZE DEFAULT_STACK_SIZE #endif -void print_char(char c = '*') -{ +void print_char(char c = '*') { printf("%c", c); fflush(stdout); } @@ -60,6 +59,11 @@ void test_thread(void const *args) { } int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default); + TEST_DESCRIPTION(Mutex resource lock); + TEST_START("RTOS_2"); + const int t1_delay = THREAD_DELAY * 1; const int t2_delay = THREAD_DELAY * 2; const int t3_delay = THREAD_DELAY * 3; @@ -78,6 +82,6 @@ int main() { } fflush(stdout); - notify_completion(!mutex_defect); + TEST_RESULT(!mutex_defect); return 0; } diff --git a/libraries/tests/rtos/mbed/queue/main.cpp b/libraries/tests/rtos/mbed/queue/main.cpp index cff0e071ff..713cff76f5 100644 --- a/libraries/tests/rtos/mbed/queue/main.cpp +++ b/libraries/tests/rtos/mbed/queue/main.cpp @@ -42,6 +42,11 @@ void send_thread (void const *argument) { } int main (void) { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(Queue messaging); + TEST_START("RTOS_5"); + Thread thread(send_thread, NULL, osPriorityNormal, STACK_SIZE); bool result = true; int result_counter = 0; @@ -67,6 +72,6 @@ int main (void) { } } } - notify_completion(result); + TEST_RESULT(result); return 0; } diff --git a/libraries/tests/rtos/mbed/semaphore/main.cpp b/libraries/tests/rtos/mbed/semaphore/main.cpp index f474367303..1021e7e97d 100644 --- a/libraries/tests/rtos/mbed/semaphore/main.cpp +++ b/libraries/tests/rtos/mbed/semaphore/main.cpp @@ -17,8 +17,7 @@ #define STACK_SIZE DEFAULT_STACK_SIZE #endif -void print_char(char c = '*') -{ +void print_char(char c = '*') { printf("%c", c); fflush(stdout); } @@ -49,6 +48,11 @@ void test_thread(void const *delay) { } int main (void) { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(Semaphore resource lock); + TEST_START("RTOS_3"); + const int t1_delay = THREAD_DELAY * 1; const int t2_delay = THREAD_DELAY * 2; const int t3_delay = THREAD_DELAY * 3; @@ -66,6 +70,6 @@ int main (void) { } fflush(stdout); - notify_completion(!sem_defect); + TEST_RESULT(!sem_defect); return 0; } diff --git a/libraries/tests/rtos/mbed/signals/main.cpp b/libraries/tests/rtos/mbed/signals/main.cpp index 38c68daa26..9b13fe71e5 100644 --- a/libraries/tests/rtos/mbed/signals/main.cpp +++ b/libraries/tests/rtos/mbed/signals/main.cpp @@ -30,6 +30,11 @@ void led_thread(void const *argument) { } int main (void) { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(Signals messaging); + TEST_START("RTOS_4"); + Thread thread(led_thread, NULL, osPriorityNormal, STACK_SIZE); bool result = true; @@ -41,6 +46,6 @@ int main (void) { break; } } - notify_completion(result); + TEST_RESULT(result); return 0; } diff --git a/libraries/tests/rtos/mbed/timer/main.cpp b/libraries/tests/rtos/mbed/timer/main.cpp index c606f993a8..98fda731cf 100644 --- a/libraries/tests/rtos/mbed/timer/main.cpp +++ b/libraries/tests/rtos/mbed/timer/main.cpp @@ -1,4 +1,5 @@ #include "mbed.h" +#include "test_env.h" #include "rtos.h" DigitalOut LEDs[4] = { @@ -22,6 +23,11 @@ void blink(void const *n) { } int main(void) { + TEST_TIMEOUT(15); + TEST_HOSTTEST(wait_us_auto); + TEST_DESCRIPTION(Timer); + TEST_START("RTOS_7"); + RtosTimer led_1_timer(blink, osTimerPeriodic, (void *)0); RtosTimer led_2_timer(blink, osTimerPeriodic, (void *)1); RtosTimer led_3_timer(blink, osTimerPeriodic, (void *)2); diff --git a/workspace_tools/host_tests/__init__.py b/workspace_tools/host_tests/__init__.py index 10e7e1d1de..31308bf098 100644 --- a/workspace_tools/host_tests/__init__.py +++ b/workspace_tools/host_tests/__init__.py @@ -13,4 +13,27 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -""" \ No newline at end of file +""" + +from host_registry import HostRegistry +from default_auto import DefaultAuto +from hello_auto import HelloTest +from wait_us_auto import WaitusTest + + +HOSTREGISTRY = HostRegistry() +HOSTREGISTRY.register_host_test("default", DefaultAuto()) +HOSTREGISTRY.register_host_test("default_auto", DefaultAuto()) +HOSTREGISTRY.register_host_test("hello_auto", HelloTest()) +HOSTREGISTRY.register_host_test("wait_us_auto", WaitusTest()) + +############################################################################### +# Functional interface for test supervisor registry +############################################################################### + + +def get_host_test(ht_name): + return HOSTREGISTRY.get_host_test(ht_name) + +def is_host_test(ht_name): + return HOSTREGISTRY.is_host_test(ht_name) diff --git a/workspace_tools/host_tests/default_auto.py b/workspace_tools/host_tests/default_auto.py new file mode 100644 index 0000000000..0883d79d53 --- /dev/null +++ b/workspace_tools/host_tests/default_auto.py @@ -0,0 +1,36 @@ +""" +mbed SDK +Copyright (c) 2011-2013 ARM Limited + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" + +from sys import stdout + +class DefaultAuto(): + """ Simple, basic host test's test runner waiting for serial port + output from MUT, no supervision over test running in MUT is executed. + """ + def test(self, selftest): + result = selftest.RESULT_SUCCESS + try: + while True: + c = selftest.mbed.serial_read(512) + if c is None: + return selftest.RESULT_IO_SERIAL + stdout.write(c) + stdout.flush() + except KeyboardInterrupt, _: + selftest.notify("\r\n[CTRL+C] exit") + result = selftest.RESULT_ERROR + return result diff --git a/workspace_tools/host_tests/hello_auto.py b/workspace_tools/host_tests/hello_auto.py index 27ea7a8530..69b39bf6bb 100644 --- a/workspace_tools/host_tests/hello_auto.py +++ b/workspace_tools/host_tests/hello_auto.py @@ -15,23 +15,15 @@ See the License for the specific language governing permissions and limitations under the License. """ -from host_test import DefaultTest - - -class HelloTest(DefaultTest): +class HelloTest(): HELLO_WORLD = "Hello World" - def test(self): - c = self.mbed.serial_readline() + def test(self, selftest): + c = selftest.mbed.serial_readline() if c is None: - return self.RESULT_IO_SERIAL - self.notify(c.strip()) - - c = self.mbed.serial_readline() - if c is None: - return self.RESULT_IO_SERIAL - self.notify("Read %d bytes:"% len(c)) - self.notify(c.strip()) + return selftest.RESULT_IO_SERIAL + selftest.notify("Read %d bytes:"% len(c)) + selftest.notify(c.strip()) result = True # Because we can have targetID here let's try to decode @@ -39,8 +31,4 @@ class HelloTest(DefaultTest): result = False else: result = self.HELLO_WORLD in c - return self.RESULT_SUCCESS if result else self.RESULT_FAILURE - - -if __name__ == '__main__': - HelloTest().run() + return selftest.RESULT_SUCCESS if result else selftest.RESULT_FAILURE diff --git a/workspace_tools/host_tests/host_registry.py b/workspace_tools/host_tests/host_registry.py new file mode 100644 index 0000000000..d52384834a --- /dev/null +++ b/workspace_tools/host_tests/host_registry.py @@ -0,0 +1,36 @@ +""" +mbed SDK +Copyright (c) 2011-2013 ARM Limited + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" + +class HostRegistry: + """ Class stores registry with host tests and objects representing them + """ + HOST_TESTS = {} # host_test_name -> host_test_ojbect + + def register_host_test(self, ht_name, ht_object): + if ht_name not in self.HOST_TESTS: + self.HOST_TESTS[ht_name] = ht_object + + def unregister_host_test(self): + if ht_name in HOST_TESTS: + self.HOST_TESTS[ht_name] = None + + def get_host_test(self, ht_name): + return self.HOST_TESTS[ht_name] if ht_name in self.HOST_TESTS else None + + def is_host_test(self, ht_name): + return ht_name in self.HOST_TESTS + \ No newline at end of file diff --git a/workspace_tools/host_tests/host_test.py b/workspace_tools/host_tests/host_test.py index ae16f6568e..7c721a114e 100644 --- a/workspace_tools/host_tests/host_test.py +++ b/workspace_tools/host_tests/host_test.py @@ -23,6 +23,8 @@ except ImportError, e: exit(-1) import os +import re +import types from sys import stdout from time import sleep, time from optparse import OptionParser @@ -254,12 +256,37 @@ class HostTestResults: self.RESULT_PASSIVE = "passive" +import workspace_tools.host_tests as host_tests + + class Test(HostTestResults): """ Base class for host test's test runner """ + # Select default host_test supervision (replaced after autodetection) + test_supervisor = host_tests.get_host_test("default") + def __init__(self): self.mbed = Mbed() + def detect_test_config(self, verbose=False): + """ Detects test case configuration + """ + result = {} + while True: + line = self.mbed.serial_readline() + if "{start}" in line: + self.notify("HOST: Start test...") + break + else: + m = re.search('{([\w_]+);([\w\d ]+)}}', line[:-1]) + if m and len(m.groups()) == 2: + result[m.group(1)] = m.group(2) + if verbose: + self.notify("HOST: Property '%s' = '%s'"% (m.group(1), m.group(2))) + else: + self.notify("HOST: Unknown property: %s"% line.strip()) + return result + def run(self): """ Test runner for host test. This function will start executing test and forward test result via serial port to test suite @@ -284,7 +311,13 @@ class Test(HostTestResults): # Run test try: - result = self.test() + CONFIG = self.detect_test_config(verbose=True) # print CONFIG + + if "host_test_name" in CONFIG: + if host_tests.is_host_test(CONFIG["host_test_name"]): + self.test_supervisor = host_tests.get_host_test(CONFIG["host_test_name"]) + result = self.test_supervisor.test(self) #result = self.test() + if result is not None: self.print_result(result) else: @@ -341,6 +374,5 @@ class Simple(DefaultTest): result = self.RESULT_ERROR return result - if __name__ == '__main__': Simple().run() diff --git a/workspace_tools/host_tests/wait_us_auto.py b/workspace_tools/host_tests/wait_us_auto.py index 8a73fd12ba..2ab66a3b51 100644 --- a/workspace_tools/host_tests/wait_us_auto.py +++ b/workspace_tools/host_tests/wait_us_auto.py @@ -16,10 +16,8 @@ limitations under the License. """ from time import time -from host_test import DefaultTest - -class WaitusTest(DefaultTest): +class WaitusTest(): """ This test is reading single characters from stdio and measures time between their occurrences. """ @@ -27,30 +25,30 @@ class WaitusTest(DefaultTest): TICK_LOOP_SUCCESSFUL_COUNTS = 10 DEVIATION = 0.10 # +/-10% - def test(self): + def test(self, selftest): test_result = True # First character to start test (to know after reset when test starts) - if self.mbed.set_serial_timeout(None) is None: - return self.RESULT_IO_SERIAL - c = self.mbed.serial_read(1) + if selftest.mbed.set_serial_timeout(None) is None: + return selftest.RESULT_IO_SERIAL + c = selftest.mbed.serial_read(1) if c is None: - return self.RESULT_IO_SERIAL + return selftest.RESULT_IO_SERIAL if c == '$': # target will printout TargetID e.g.: $$$$1040e649d5c09a09a3f6bc568adef61375c6 #Read additional 39 bytes of TargetID - if self.mbed.serial_read(39) is None: - return self.RESULT_IO_SERIAL - c = self.mbed.serial_read(1) # Re-read first 'tick' + if selftest.mbed.serial_read(39) is None: + return selftest.RESULT_IO_SERIAL + c = selftest.mbed.serial_read(1) # Re-read first 'tick' if c is None: - return self.RESULT_IO_SERIAL + return selftest.RESULT_IO_SERIAL start_serial_pool = time() start = time() success_counter = 0 for i in range(0, self.TICK_LOOP_COUNTER): - c = self.mbed.serial_read(1) + c = selftest.mbed.serial_read(1) if c is None: - return self.RESULT_IO_SERIAL + return selftest.RESULT_IO_SERIAL delta = time() - start deviation = abs(delta - 1) # Round values @@ -60,16 +58,12 @@ class WaitusTest(DefaultTest): deviation_ok = True if delta > 0 and deviation <= self.DEVIATION else False success_counter = success_counter+1 if deviation_ok else 0 msg = "OK" if deviation_ok else "FAIL" - self.notify("%s in %.2f sec (%.2f) [%s]"% (c, delta, deviation, msg)) + selftest.notify("%s in %.2f sec (%.2f) [%s]"% (c, delta, deviation, msg)) start = time() if success_counter >= self.TICK_LOOP_SUCCESSFUL_COUNTS: break measurement_time = time() - start_serial_pool - self.notify("Consecutive OK timer reads: %d"% success_counter) - self.notify("Completed in %.2f sec" % (measurement_time)) + selftest.notify("Consecutive OK timer reads: %d"% success_counter) + selftest.notify("Completed in %.2f sec" % (measurement_time)) test_result = True if success_counter >= self.TICK_LOOP_SUCCESSFUL_COUNTS else False - return self.RESULT_SUCCESS if test_result else self.RESULT_FAILURE - - -if __name__ == '__main__': - WaitusTest().run() + return selftest.RESULT_SUCCESS if test_result else selftest.RESULT_FAILURE diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index e3185b5c88..3fd6e923c6 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -375,14 +375,14 @@ TESTS = [ "source_dir": join(TEST_DIR, "mbed", "hello"), "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB], "automated": True, - "host_test": "hello_auto", + #"host_test": "hello_auto", }, { "id": "MBED_11", "description": "Ticker Int", "source_dir": join(TEST_DIR, "mbed", "ticker"), - "dependencies": [MBED_LIBRARIES], + "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB], "automated": True, - "host_test": "wait_us_auto", + #"host_test": "wait_us_auto", "duration": 20, }, { @@ -455,7 +455,7 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB], "duration": 15, "automated": True, - "host_test": "wait_us_auto" + #"host_test": "wait_us_auto" }, { "id": "MBED_24", "description": "Timeout Int us", @@ -463,7 +463,7 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB], "duration": 15, "automated": True, - "host_test": "wait_us_auto" + #"host_test": "wait_us_auto" }, { "id": "MBED_25", "description": "Time us", @@ -471,7 +471,7 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB], "duration": 15, "automated": True, - "host_test": "wait_us_auto" + #"host_test": "wait_us_auto" }, { "id": "MBED_26", "description": "Integer constant division", @@ -525,7 +525,7 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB], "duration": 15, "automated": True, - "host_test": "wait_us_auto" + #"host_test": "wait_us_auto" }, @@ -579,10 +579,10 @@ TESTS = [ { "id": "RTOS_1", "description": "Basic thread", "source_dir": join(TEST_DIR, "rtos", "mbed", "basic"), - "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES], + "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB], "duration": 15, "automated": True, - "host_test": "wait_us_auto", + #"host_test": "wait_us_auto", "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "KL25Z", "KL05Z", "K64F", "KL46Z", "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_F401VC"], }, { @@ -625,10 +625,10 @@ TESTS = [ { "id": "RTOS_7", "description": "Timer", "source_dir": join(TEST_DIR, "rtos", "mbed", "timer"), - "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES], + "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB], "duration": 15, "automated": True, - "host_test": "wait_us_auto", + #"host_test": "wait_us_auto", "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "KL25Z", "KL05Z", "K64F", "KL46Z", "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_F401VC"], }, { From a8506caa1de00e92c372f37795cc237ff0f7fcaa Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 27 Jan 2015 12:51:53 +0000 Subject: [PATCH 03/34] Refactored few more tests to support autodetection: basic, call_before_main, dev_null, rtc, stdio --- libraries/tests/mbed/basic/main.cpp | 7 ++++- .../tests/mbed/call_before_main/main.cpp | 8 ++++- libraries/tests/mbed/dev_null/main.cpp | 14 +++++---- libraries/tests/mbed/file/main.cpp | 22 +++++++------- libraries/tests/mbed/rtc/main.cpp | 6 ++++ libraries/tests/mbed/stdio/main.cpp | 14 +++++---- workspace_tools/host_tests/__init__.py | 6 ++++ workspace_tools/host_tests/dev_null_auto.py | 25 ++++++---------- workspace_tools/host_tests/host_test.py | 24 ++------------- workspace_tools/host_tests/rtc_auto.py | 20 +++++-------- workspace_tools/host_tests/stdio_auto.py | 30 ++++++++----------- workspace_tools/tests.py | 8 ++--- 12 files changed, 88 insertions(+), 96 deletions(-) diff --git a/libraries/tests/mbed/basic/main.cpp b/libraries/tests/mbed/basic/main.cpp index 7b425e5317..d7e45b682a 100644 --- a/libraries/tests/mbed/basic/main.cpp +++ b/libraries/tests/mbed/basic/main.cpp @@ -1,4 +1,9 @@ #include "test_env.h" + int main() { - notify_completion(true); + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(Basic); + TEST_START("MBED_A1"); + TEST_RESULT(true); } diff --git a/libraries/tests/mbed/call_before_main/main.cpp b/libraries/tests/mbed/call_before_main/main.cpp index fd4d1cdd0c..9ab5de4bf3 100644 --- a/libraries/tests/mbed/call_before_main/main.cpp +++ b/libraries/tests/mbed/call_before_main/main.cpp @@ -10,6 +10,12 @@ extern "C" void mbed_main() { } int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(Call function mbed_main before main); + TEST_START("MBED_A21"); + printf("MBED: main() starts now!\r\n"); - notify_completion(mbed_main_called); + + TEST_RESULT(mbed_main_called); } diff --git a/libraries/tests/mbed/dev_null/main.cpp b/libraries/tests/mbed/dev_null/main.cpp index 9131f4f42a..94c6630e62 100644 --- a/libraries/tests/mbed/dev_null/main.cpp +++ b/libraries/tests/mbed/dev_null/main.cpp @@ -1,8 +1,7 @@ #include "mbed.h" #include "test_env.h" -class DevNull : public Stream -{ +class DevNull : public Stream { public: DevNull(const char *name = NULL) : Stream(name) {} @@ -17,12 +16,15 @@ protected: DevNull null("null"); -int main() -{ +int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(dev_null_auto); + TEST_DESCRIPTION(stdout redirected to dev null); + TEST_START("EXAMPLE_1"); + printf("MBED: re-routing stdout to /null\r\n"); freopen("/null", "w", stdout); printf("MBED: printf redirected to /null\r\n"); // This shouldn't appear // If failure message can be seen test should fail :) - notify_completion(false); // This is 'false' on purpose - return 0; + TEST_RESULT(false); // This is 'false' on purpose } diff --git a/libraries/tests/mbed/file/main.cpp b/libraries/tests/mbed/file/main.cpp index 4e237a6be7..dbe7bbfb47 100644 --- a/libraries/tests/mbed/file/main.cpp +++ b/libraries/tests/mbed/file/main.cpp @@ -6,8 +6,7 @@ Serial pc(USBTX, USBRX); #define FILENAME "/local/out.txt" #define TEST_STRING "Hello World!" -FILE *test_open(const char *mode) -{ +FILE *test_open(const char *mode) { FILE *f = fopen(FILENAME, mode); if (f == NULL) { printf("Error opening file"NL); @@ -16,8 +15,7 @@ FILE *test_open(const char *mode) return f; } -void test_write(FILE *f, char *str, int str_len) -{ +void test_write(FILE *f, char *str, int str_len) { int n = fprintf(f, str); if (n != str_len) { @@ -26,8 +24,7 @@ void test_write(FILE *f, char *str, int str_len) } } -void test_read(FILE *f, char *str, int str_len) -{ +void test_read(FILE *f, char *str, int str_len) { int n = fread(str, sizeof(unsigned char), str_len, f); if (n != str_len) { @@ -36,8 +33,7 @@ void test_read(FILE *f, char *str, int str_len) } } -void test_close(FILE *f) -{ +void test_close(FILE *f) { int rc = fclose(f); if (rc != 0) { @@ -46,8 +42,12 @@ void test_close(FILE *f) } } -int main() -{ +int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(Semihost file system); + TEST_START("MBED_A2"); + pc.printf("Test the Stream class\n"); printf("connected: %s\n", (semihost_connected()) ? ("Yes") : ("No")); @@ -74,5 +74,5 @@ int main() test_close(f); // Check the two strings are equal - notify_completion((strncmp(buffer, str, str_len) == 0)); + TEST_RESULT((strncmp(buffer, str, str_len) == 0)); } diff --git a/libraries/tests/mbed/rtc/main.cpp b/libraries/tests/mbed/rtc/main.cpp index 408c8e1eb6..3e8a520d41 100644 --- a/libraries/tests/mbed/rtc/main.cpp +++ b/libraries/tests/mbed/rtc/main.cpp @@ -1,8 +1,14 @@ #include "mbed.h" +#include "test_env.h" #define CUSTOM_TIME 1256729737 int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(rtc_auto); + TEST_DESCRIPTION(RTC); + TEST_START("MBED_16"); + char buffer[32] = {0}; set_time(CUSTOM_TIME); // Set RTC time to Wed, 28 Oct 2009 11:35:37 while(1) { diff --git a/libraries/tests/mbed/stdio/main.cpp b/libraries/tests/mbed/stdio/main.cpp index 81552d8715..cb80e95d07 100644 --- a/libraries/tests/mbed/stdio/main.cpp +++ b/libraries/tests/mbed/stdio/main.cpp @@ -7,19 +7,23 @@ */ int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(stdio_auto); + TEST_DESCRIPTION(stdio); + TEST_START("MBED_2"); + DigitalOut led1(LED1); DigitalOut led2(LED2); - + union { int value_int; }; - notify_start(); + notify_start(); // Just to sync with host test supervisor const char* PRINT_PATTERN = "MBED: Your value was: %d\r\n"; - - while (true) - { + + while (true) { // SCANF PRINTF family value_int = 0; led1 = 1; diff --git a/workspace_tools/host_tests/__init__.py b/workspace_tools/host_tests/__init__.py index 31308bf098..a7899a6d34 100644 --- a/workspace_tools/host_tests/__init__.py +++ b/workspace_tools/host_tests/__init__.py @@ -19,6 +19,9 @@ from host_registry import HostRegistry from default_auto import DefaultAuto from hello_auto import HelloTest from wait_us_auto import WaitusTest +from stdio_auto import StdioTest +from dev_null_auto import DevNullTest +from rtc_auto import RTCTest HOSTREGISTRY = HostRegistry() @@ -26,6 +29,9 @@ HOSTREGISTRY.register_host_test("default", DefaultAuto()) HOSTREGISTRY.register_host_test("default_auto", DefaultAuto()) HOSTREGISTRY.register_host_test("hello_auto", HelloTest()) HOSTREGISTRY.register_host_test("wait_us_auto", WaitusTest()) +HOSTREGISTRY.register_host_test("stdio_auto", StdioTest()) +HOSTREGISTRY.register_host_test("dev_null_auto", DevNullTest()) +HOSTREGISTRY.register_host_test("rtc_auto", RTCTest()) ############################################################################### # Functional interface for test supervisor registry diff --git a/workspace_tools/host_tests/dev_null_auto.py b/workspace_tools/host_tests/dev_null_auto.py index 6962b4f46e..4538f6d79e 100644 --- a/workspace_tools/host_tests/dev_null_auto.py +++ b/workspace_tools/host_tests/dev_null_auto.py @@ -15,25 +15,22 @@ See the License for the specific language governing permissions and limitations under the License. """ -from host_test import DefaultTest +class DevNullTest(): - -class DevNullTest(DefaultTest): - - def check_readline(self, text): + def check_readline(self, selftest, text): """ Reads line from serial port and checks if text was part of read string """ result = False - c = self.mbed.serial_readline() + c = selftest.mbed.serial_readline() if c and text in c: result = True return result - def test(self): + def test(self, selftest): result = True # Test should print some text and later stop printing # 'MBED: re-routing stdout to /null' - res = self.check_readline("re-routing stdout to /null") + res = self.check_readline(selftest, "re-routing stdout to /null") if not res: # We haven't read preamble line result = False @@ -41,17 +38,13 @@ class DevNullTest(DefaultTest): # Check if there are printed characters str = '' for i in range(3): - c = self.mbed.serial_read(32) + c = selftest.mbed.serial_read(32) if c is None: - return self.RESULT_IO_SERIAL + return selftest.RESULT_IO_SERIAL else: str += c if len(str) > 0: result = False break - self.notify("Received %d bytes: %s"% (len(str), str)) - return self.RESULT_SUCCESS if result else self.RESULT_FAILURE - - -if __name__ == '__main__': - DevNullTest().run() + selftest.notify("Received %d bytes: %s"% (len(str), str)) + return selftest.RESULT_SUCCESS if result else selftest.RESULT_FAILURE diff --git a/workspace_tools/host_tests/host_test.py b/workspace_tools/host_tests/host_test.py index 7c721a114e..af8d527f0d 100644 --- a/workspace_tools/host_tests/host_test.py +++ b/workspace_tools/host_tests/host_test.py @@ -254,6 +254,7 @@ class HostTestResults: self.RESULT_NO_IMAGE = 'no_image' self.RESULT_IOERR_COPY = "ioerr_copy" self.RESULT_PASSIVE = "passive" + self.RESULT_NOT_DETECTED = "not_detected" import workspace_tools.host_tests as host_tests @@ -348,31 +349,12 @@ class Test(HostTestResults): self.notify("\n{{%s}}\n{{end}}" % result) -class DefaultTest(Test): +class DefaultTestSelector(Test): """ Test class with serial port initialization """ def __init__(self): HostTestResults.__init__(self) Test.__init__(self) - -class Simple(DefaultTest): - """ Simple, basic host test's test runner waiting for serial port - output from MUT, no supervision over test running in MUT is executed. - """ - def test(self): - result = self.RESULT_SUCCESS - try: - while True: - c = self.mbed.serial_read(512) - if c is None: - return self.RESULT_IO_SERIAL - stdout.write(c) - stdout.flush() - except KeyboardInterrupt, _: - self.notify("\r\n[CTRL+C] exit") - result = self.RESULT_ERROR - return result - if __name__ == '__main__': - Simple().run() + DefaultTestSelector().run() diff --git a/workspace_tools/host_tests/rtc_auto.py b/workspace_tools/host_tests/rtc_auto.py index 0ccdce5665..d19307daa2 100644 --- a/workspace_tools/host_tests/rtc_auto.py +++ b/workspace_tools/host_tests/rtc_auto.py @@ -16,24 +16,22 @@ limitations under the License. """ import re -from host_test import DefaultTest from time import time, strftime, gmtime - -class RTCTest(DefaultTest): +class RTCTest(): PATTERN_RTC_VALUE = "\[(\d+)\] \[(\d+-\d+-\d+ \d+:\d+:\d+ [AaPpMm]{2})\]" re_detect_rtc_value = re.compile(PATTERN_RTC_VALUE) - def test(self): + def test(self, selftest): test_result = True start = time() sec_prev = 0 for i in range(0, 5): # Timeout changed from default: we need to wait longer for some boards to start-up - c = self.mbed.serial_readline(timeout=10) + c = selftest.mbed.serial_readline(timeout=10) if c is None: - return self.RESULT_IO_SERIAL - self.notify(c.strip()) + return selftest.RESULT_IO_SERIAL + selftest.notify(c.strip()) delta = time() - start m = self.re_detect_rtc_value.search(c) if m and len(m.groups()): @@ -42,14 +40,10 @@ class RTCTest(DefaultTest): correct_time_str = strftime("%Y-%m-%d %H:%M:%S %p", gmtime(float(sec))) test_result = test_result and (time_str == correct_time_str) result_msg = "OK" if (time_str == correct_time_str and sec > 0 and sec > sec_prev) else "FAIL" - self.notify("HOST: [%s] [%s] received time %+d sec after %.2f sec... %s"% (sec, time_str, sec - sec_prev, delta, result_msg)) + selftest.notify("HOST: [%s] [%s] received time %+d sec after %.2f sec... %s"% (sec, time_str, sec - sec_prev, delta, result_msg)) sec_prev = sec else: test_result = False break start = time() - return self.RESULT_SUCCESS if test_result else self.RESULT_FAILURE - - -if __name__ == '__main__': - RTCTest().run() + return selftest.RESULT_SUCCESS if test_result else selftest.RESULT_FAILURE diff --git a/workspace_tools/host_tests/stdio_auto.py b/workspace_tools/host_tests/stdio_auto.py index 83daabc42b..1fe18906aa 100644 --- a/workspace_tools/host_tests/stdio_auto.py +++ b/workspace_tools/host_tests/stdio_auto.py @@ -18,32 +18,30 @@ limitations under the License. import re import random from time import time -from host_test import DefaultTest - -class StdioTest(DefaultTest): +class StdioTest(): PATTERN_INT_VALUE = "Your value was: (-?\d+)" re_detect_int_value = re.compile(PATTERN_INT_VALUE) - def test(self): + def test(self, selftest): test_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 - self.notify(c) + return selftest.RESULT_IO_SERIAL + selftest.notify(c) for i in range(0, 10): random_integer = random.randint(-99999, 99999) - self.notify("HOST: Generated number: " + str(random_integer)) + selftest.notify("HOST: Generated number: " + str(random_integer)) start = time() - self.mbed.serial_write(str(random_integer) + "\n") + selftest.mbed.serial_write(str(random_integer) + "\n") - serial_stdio_msg = self.mbed.serial_readline() + serial_stdio_msg = selftest.mbed.serial_readline() if serial_stdio_msg is None: - return self.RESULT_IO_SERIAL + return selftest.RESULT_IO_SERIAL delay_time = time() - start - self.notify(serial_stdio_msg.strip()) + selftest.notify(serial_stdio_msg.strip()) # Searching for reply with scanned values m = self.re_detect_int_value.search(serial_stdio_msg) @@ -51,12 +49,8 @@ class StdioTest(DefaultTest): int_value = m.groups()[0] int_value_cmp = random_integer == int(int_value) test_result = test_result and int_value_cmp - self.notify("HOST: Number %s read after %.3f sec ... [%s]"% (int_value, delay_time, "OK" if int_value_cmp else "FAIL")) + selftest.notify("HOST: Number %s read after %.3f sec ... [%s]"% (int_value, delay_time, "OK" if int_value_cmp else "FAIL")) else: test_result = False break - return self.RESULT_SUCCESS if test_result else self.RESULT_FAILURE - - -if __name__ == '__main__': - StdioTest().run() + return selftest.RESULT_SUCCESS if test_result else selftest.RESULT_FAILURE diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index 3fd6e923c6..594b69419f 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -329,7 +329,7 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB], "duration": 20, "automated": True, - "host_test": "stdio_auto" + #"host_test": "stdio_auto" }, { "id": "MBED_3", "description": "PortOut", @@ -411,9 +411,9 @@ TESTS = [ { "id": "MBED_16", "description": "RTC", "source_dir": join(TEST_DIR, "mbed", "rtc"), - "dependencies": [MBED_LIBRARIES], + "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB], "automated": True, - "host_test": "rtc_auto", + #"host_test": "rtc_auto", "duration": 15 }, { @@ -862,7 +862,7 @@ TESTS = [ "source_dir": join(TEST_DIR, "mbed", "dev_null"), "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB], "automated": True, - "host_test" : "dev_null_auto", + #"host_test" : "dev_null_auto", }, { "id": "EXAMPLE_2", "description": "FS + RTOS", From d610f0b08aa173ae1ba772c2839e38b8cf4d168b Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 27 Jan 2015 13:17:36 +0000 Subject: [PATCH 04/34] Refactored echo at 115200 test for new model of test autodetection --- libraries/tests/mbed/echo/main.cpp | 10 ++--- workspace_tools/host_tests/__init__.py | 2 + workspace_tools/host_tests/echo.py | 51 +++++++++---------------- workspace_tools/host_tests/host_test.py | 4 ++ workspace_tools/tests.py | 2 +- 5 files changed, 30 insertions(+), 39 deletions(-) diff --git a/libraries/tests/mbed/echo/main.cpp b/libraries/tests/mbed/echo/main.cpp index 4dade7f01a..bbe175b38f 100644 --- a/libraries/tests/mbed/echo/main.cpp +++ b/libraries/tests/mbed/echo/main.cpp @@ -7,18 +7,18 @@ namespace { const int BUFFER_SIZE = 48; + char buffer[BUFFER_SIZE] = {0}; } int main() { - char buffer[BUFFER_SIZE] = {0}; + TEST_TIMEOUT(20); + TEST_HOSTTEST(echo); + TEST_DESCRIPTION(Serial Echo at 115200); + TEST_START("MBED_A9"); Serial pc(TXPIN, RXPIN); pc.baud(115200); - pc.puts("{{"); - pc.puts(TEST_ENV_START); // Host test is expecting preamble - pc.puts("}}"); - while (1) { pc.gets(buffer, BUFFER_SIZE - 1); pc.printf("%s", buffer); diff --git a/workspace_tools/host_tests/__init__.py b/workspace_tools/host_tests/__init__.py index a7899a6d34..3b9f1319ea 100644 --- a/workspace_tools/host_tests/__init__.py +++ b/workspace_tools/host_tests/__init__.py @@ -22,6 +22,7 @@ from wait_us_auto import WaitusTest from stdio_auto import StdioTest from dev_null_auto import DevNullTest from rtc_auto import RTCTest +from echo import EchoTest HOSTREGISTRY = HostRegistry() @@ -32,6 +33,7 @@ HOSTREGISTRY.register_host_test("wait_us_auto", WaitusTest()) 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()) ############################################################################### # Functional interface for test supervisor registry diff --git a/workspace_tools/host_tests/echo.py b/workspace_tools/host_tests/echo.py index ea4c8c7d74..e855cb4a1c 100644 --- a/workspace_tools/host_tests/echo.py +++ b/workspace_tools/host_tests/echo.py @@ -18,50 +18,35 @@ limitations under the License. import sys import uuid from sys import stdout -from host_test import HostTestResults, Test +class EchoTest(): -class EchoTest(Test): - """ This host test will use mbed serial port with - baudrate 115200 to perform echo test on that port. - """ + # Test parameters + TEST_SERIAL_BAUDRATE = 115200 + TEST_LOOP_COUNT = 50 - def __init__(self): - # Constructors - HostTestResults.__init__(self) - Test.__init__(self) - - # Test parameters - self.TEST_SERIAL_BAUDRATE = 115200 - self.TEST_LOOP_COUNT = 50 - - # Custom initialization for echo test - self.mbed.init_serial_params(serial_baud=self.TEST_SERIAL_BAUDRATE) - - def test(self): - """ Test function, return True or False to get standard test notification on stdout + def test(self, selftest): + """ This host test will use mbed serial port with + baudrate 115200 to perform echo test on that port. """ - c = self.mbed.serial_readline() # '{{start}}' - if c is None: - return self.RESULT_IO_SERIAL + # Custom initialization for echo test + selftest.mbed.init_serial_params(serial_baud=self.TEST_SERIAL_BAUDRATE) + selftest.mbed.init_serial() - self.mbed.flush() - self.notify("HOST: Starting the ECHO test") + # Test function, return True or False to get standard test notification on stdout + selftest.mbed.flush() + selftest.notify("HOST: Starting the ECHO test") result = True for i in range(0, self.TEST_LOOP_COUNT): TEST_STRING = str(uuid.uuid4()) + "\n" - self.mbed.serial_write(TEST_STRING) - c = self.mbed.serial_readline() + selftest.mbed.serial_write(TEST_STRING) + c = selftest.mbed.serial_readline() if c is None: - return self.RESULT_IO_SERIAL + return selftest.RESULT_IO_SERIAL if c.strip() != TEST_STRING.strip(): - self.notify('HOST: "%s" != "%s"'% (c, TEST_STRING)) + selftest.notify('HOST: "%s" != "%s"'% (c, TEST_STRING)) result = False else: sys.stdout.write('.') stdout.flush() - return self.RESULT_SUCCESS if result else self.RESULT_FAILURE - - -if __name__ == '__main__': - EchoTest().run() + return selftest.RESULT_SUCCESS if result else selftest.RESULT_FAILURE diff --git a/workspace_tools/host_tests/host_test.py b/workspace_tools/host_tests/host_test.py index af8d527f0d..ff2ff697c4 100644 --- a/workspace_tools/host_tests/host_test.py +++ b/workspace_tools/host_tests/host_test.py @@ -126,6 +126,10 @@ class Mbed: serial_baud = serial_baud if serial_baud is not None else self.serial_baud serial_timeout = serial_timeout if serial_timeout is not None else self.serial_timeout + if self.serial: + self.serial.close() + self.serial = None + result = True try: self.serial = Serial(self.port, baudrate=serial_baud, timeout=serial_timeout) diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index 594b69419f..bca01247de 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -137,7 +137,7 @@ TESTS = [ "source_dir": join(TEST_DIR, "mbed", "echo"), "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB], "automated": True, - "host_test": "echo" + #"host_test": "echo" }, { "id": "MBED_A10", "description": "PortOut PortIn", From dcce4d7cded777412c79e88441ca041ae4c81ff7 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 27 Jan 2015 13:24:11 +0000 Subject: [PATCH 05/34] Refactored detection test to use new autodetection of host test --- libraries/tests/mbed/detect/main.cpp | 7 ++++- workspace_tools/host_tests/__init__.py | 2 ++ workspace_tools/host_tests/detect_auto.py | 38 ++++++++++------------- workspace_tools/tests.py | 2 +- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/libraries/tests/mbed/detect/main.cpp b/libraries/tests/mbed/detect/main.cpp index 59d0634866..d7ad0c26dd 100644 --- a/libraries/tests/mbed/detect/main.cpp +++ b/libraries/tests/mbed/detect/main.cpp @@ -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); } diff --git a/workspace_tools/host_tests/__init__.py b/workspace_tools/host_tests/__init__.py index 3b9f1319ea..28e1017867 100644 --- a/workspace_tools/host_tests/__init__.py +++ b/workspace_tools/host_tests/__init__.py @@ -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 diff --git a/workspace_tools/host_tests/detect_auto.py b/workspace_tools/host_tests/detect_auto.py index 03ff17fa9d..2999946c08 100644 --- a/workspace_tools/host_tests/detect_auto.py +++ b/workspace_tools/host_tests/detect_auto.py @@ -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 diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index bca01247de..8c6499b636 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -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", }, ] From a4bf0cf135adcccc7dd69cd2bc7908e7baaa2be8 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 27 Jan 2015 13:44:30 +0000 Subject: [PATCH 06/34] Refactored tests for SD card peripheral --- libraries/tests/mbed/sd/main.cpp | 10 ++++++--- libraries/tests/mbed/sd_perf_fatfs/main.cpp | 22 +++++++++---------- libraries/tests/mbed/sd_perf_fhandle/main.cpp | 22 +++++++++---------- libraries/tests/mbed/sd_perf_stdio/main.cpp | 22 +++++++++---------- 4 files changed, 40 insertions(+), 36 deletions(-) diff --git a/libraries/tests/mbed/sd/main.cpp b/libraries/tests/mbed/sd/main.cpp index 82d83456ae..0bac9c4aa4 100644 --- a/libraries/tests/mbed/sd/main.cpp +++ b/libraries/tests/mbed/sd/main.cpp @@ -61,8 +61,12 @@ const char *sd_file_path = "/sd/out.txt"; const int DATA_SIZE = 256; } -int main() -{ +int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(SD File System); + TEST_START("MBED_A12"); + uint8_t data_written[DATA_SIZE] = { 0 }; bool result = false; @@ -103,5 +107,5 @@ int main() } result = write_result && read_result; - notify_completion(result); + TEST_RESULT(result); } diff --git a/libraries/tests/mbed/sd_perf_fatfs/main.cpp b/libraries/tests/mbed/sd_perf_fatfs/main.cpp index beb2ef25b1..555022de61 100644 --- a/libraries/tests/mbed/sd_perf_fatfs/main.cpp +++ b/libraries/tests/mbed/sd_perf_fatfs/main.cpp @@ -55,16 +55,14 @@ SDFileSystem sd(SDMOSI, SDMISO, SDSCLK, SDSSEL, "sd"); SDFileSystem sd(p11, p12, p13, p14, "sd"); #endif -namespace -{ +namespace { char buffer[1024]; const int KIB_RW = 128; Timer timer; const char *bin_filename = "0:testfile.bin"; } -bool test_sf_file_write_fatfs(const char *filename, const int kib_rw) -{ +bool test_sf_file_write_fatfs(const char *filename, const int kib_rw) { FIL file; bool result = true; FRESULT res = f_open(&file, filename, FA_WRITE | FA_CREATE_ALWAYS); @@ -96,8 +94,7 @@ bool test_sf_file_write_fatfs(const char *filename, const int kib_rw) return result; } -bool test_sf_file_read_fatfs(const char *filename, const int kib_rw) -{ +bool test_sf_file_read_fatfs(const char *filename, const int kib_rw) { FIL file; bool result = true; FRESULT res = f_open(&file, filename, FA_READ | FA_OPEN_EXISTING); @@ -123,13 +120,16 @@ bool test_sf_file_read_fatfs(const char *filename, const int kib_rw) return result; } -char RandomChar() -{ +char RandomChar() { return rand() % 100; } -int main() -{ +int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(SD FatFS RW Speed); + TEST_START("PERF_3"); + // Test header printf("\r\n"); printf("SD Card FatFS Performance Test\r\n"); @@ -156,5 +156,5 @@ int main() } break; } - notify_completion(result); + TEST_RESULT(result); } diff --git a/libraries/tests/mbed/sd_perf_fhandle/main.cpp b/libraries/tests/mbed/sd_perf_fhandle/main.cpp index 375f29a91a..292530366f 100644 --- a/libraries/tests/mbed/sd_perf_fhandle/main.cpp +++ b/libraries/tests/mbed/sd_perf_fhandle/main.cpp @@ -55,16 +55,14 @@ SDFileSystem sd(SDMOSI, SDMISO, SDSCLK, SDSSEL, "sd"); SDFileSystem sd(p11, p12, p13, p14, "sd"); #endif -namespace -{ +namespace { char buffer[1024]; const int KIB_RW = 128; Timer timer; const char *bin_filename = "testfile.bin"; } -bool test_sf_file_write_fhandle(const char *filename, const int kib_rw) -{ +bool test_sf_file_write_fhandle(const char *filename, const int kib_rw) { bool result = true; FileHandle* file = sd.open(filename, O_WRONLY | O_CREAT | O_TRUNC); if (file != NULL) { @@ -94,8 +92,7 @@ bool test_sf_file_write_fhandle(const char *filename, const int kib_rw) return result; } -bool test_sf_file_read_fhandle(const char *filename, const int kib_rw) -{ +bool test_sf_file_read_fhandle(const char *filename, const int kib_rw) { bool result = true; FileHandle* file = sd.open(filename, O_RDONLY); if (file) { @@ -118,13 +115,16 @@ bool test_sf_file_read_fhandle(const char *filename, const int kib_rw) return result; } -char RandomChar() -{ +char RandomChar() { return rand() % 100; } -int main() -{ +int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(SD FileHandle RW Speed); + TEST_START("PERF_2"); + // Test header printf("\r\n"); printf("SD Card FileHandle Performance Test\r\n"); @@ -151,5 +151,5 @@ int main() } break; } - notify_completion(result); + TEST_RESULT(result); } diff --git a/libraries/tests/mbed/sd_perf_stdio/main.cpp b/libraries/tests/mbed/sd_perf_stdio/main.cpp index 598dba143c..05246cf83e 100644 --- a/libraries/tests/mbed/sd_perf_stdio/main.cpp +++ b/libraries/tests/mbed/sd_perf_stdio/main.cpp @@ -55,16 +55,14 @@ SDFileSystem sd(SDMOSI, SDMISO, SDSCLK, SDSSEL, "sd"); SDFileSystem sd(p11, p12, p13, p14, "sd"); #endif -namespace -{ +namespace { char buffer[1024]; const int KIB_RW = 128; Timer timer; const char *bin_filename = "/sd/testfile.bin"; } -bool test_sf_file_write_stdio(const char *filename, const int kib_rw) -{ +bool test_sf_file_write_stdio(const char *filename, const int kib_rw) { bool result = true; FILE* file = fopen(filename, "w"); if (file != NULL) { @@ -94,8 +92,7 @@ bool test_sf_file_write_stdio(const char *filename, const int kib_rw) return result; } -bool test_sf_file_read_stdio(const char *filename, const int kib_rw) -{ +bool test_sf_file_read_stdio(const char *filename, const int kib_rw) { bool result = true; FILE* file = fopen(filename, "r"); if (file) { @@ -118,13 +115,16 @@ bool test_sf_file_read_stdio(const char *filename, const int kib_rw) return result; } -char RandomChar() -{ +char RandomChar() { return rand() % 100; } -int main() -{ +int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(SD stdio RW Speed); + TEST_START("PERF_1"); + // Test header printf("\r\n"); printf("SD Card Stdio Performance Test\r\n"); @@ -151,5 +151,5 @@ int main() } break; } - notify_completion(result); + TEST_RESULT(result); } From 4d435b94bea84008c89b65a8ba15d3c20dd53d56 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 28 Jan 2015 08:54:40 +0000 Subject: [PATCH 07/34] Refactored DIV and VTAB relocation tests Ran checks for current implementation on LPC1768 --- libraries/tests/mbed/div/main.cpp | 8 ++++++-- libraries/tests/mbed/vtor_reloc/main.cpp | 13 +++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/libraries/tests/mbed/div/main.cpp b/libraries/tests/mbed/div/main.cpp index 936435d67f..fbaa46569a 100644 --- a/libraries/tests/mbed/div/main.cpp +++ b/libraries/tests/mbed/div/main.cpp @@ -17,6 +17,11 @@ const char *result_str(bool result) { } int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(Integer constant division); + TEST_START("MBED_26"); + bool result = true; { // 0xFFFFFFFF * 8 = 0x7fffffff8 @@ -35,6 +40,5 @@ int main() { printf("64bit: 0x17FFFFFFE8: expected 0x%lX got 0x%lX ... %s\r\n", values.first, test_ret, result_str(test_res)); } - notify_completion(result); - return 0; + TEST_RESULT(result); } diff --git a/libraries/tests/mbed/vtor_reloc/main.cpp b/libraries/tests/mbed/vtor_reloc/main.cpp index f5640fe50f..e3e31842e5 100644 --- a/libraries/tests/mbed/vtor_reloc/main.cpp +++ b/libraries/tests/mbed/vtor_reloc/main.cpp @@ -46,14 +46,17 @@ static bool test_once() { } int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(Interrupt vector relocation); + TEST_START("MBED_A18"); // First test, no table reallocation { printf("Starting first test (interrupts not relocated).\r\n"); bool ret = test_once(); if (ret == false) { - notify_completion(false); - return 1; + TEST_RESULT(false); } } @@ -65,11 +68,9 @@ int main() { bool ret = test_once(); if (ret == false) { - notify_completion(false); - return 1; + TEST_RESULT(false); } } - notify_completion(true); - return 0; + TEST_RESULT(true); } From c6134eb6a2467586ccf838fb451180ec47ae73d1 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 28 Jan 2015 09:08:58 +0000 Subject: [PATCH 08/34] Refactored C++ test and added '+' sign as recognized character in auto-test description --- libraries/tests/mbed/cpp/main.cpp | 8 ++++++-- workspace_tools/host_tests/host_test.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/tests/mbed/cpp/main.cpp b/libraries/tests/mbed/cpp/main.cpp index f1f1b2be99..b565cf0006 100644 --- a/libraries/tests/mbed/cpp/main.cpp +++ b/libraries/tests/mbed/cpp/main.cpp @@ -54,6 +54,11 @@ Heap::hello Heap::destroy *******************/ int main (void) { + TEST_TIMEOUT(10); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(C++); + TEST_START("MBED_12"); + bool result = true; for (;;) { @@ -77,6 +82,5 @@ int main (void) { break; } - notify_completion(result); - return 0; + TEST_RESULT(result); } diff --git a/workspace_tools/host_tests/host_test.py b/workspace_tools/host_tests/host_test.py index ff2ff697c4..e8f61ff2b0 100644 --- a/workspace_tools/host_tests/host_test.py +++ b/workspace_tools/host_tests/host_test.py @@ -283,7 +283,7 @@ class Test(HostTestResults): self.notify("HOST: Start test...") break else: - m = re.search('{([\w_]+);([\w\d ]+)}}', line[:-1]) + m = re.search('{([\w_]+);([\w\d\+ ]+)}}', line[:-1]) if m and len(m.groups()) == 2: result[m.group(1)] = m.group(2) if verbose: From b45d190b5d42a974f82c59d1032085536b1a1a05 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 28 Jan 2015 09:11:54 +0000 Subject: [PATCH 09/34] Refactored Semihost test (valid for few LPC platforms) --- libraries/tests/mbed/semihost/main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/tests/mbed/semihost/main.cpp b/libraries/tests/mbed/semihost/main.cpp index 4c8af50810..337c3b4fc6 100644 --- a/libraries/tests/mbed/semihost/main.cpp +++ b/libraries/tests/mbed/semihost/main.cpp @@ -6,6 +6,10 @@ #define MAC_VENDOR_ARM_2 0xF7 int main() { + TEST_TIMEOUT(10); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(Semihost); + TEST_START("MBED_22"); printf("Semihost connected: %s\n", (semihost_connected()) ? ("Yes") : ("No")); @@ -30,6 +34,5 @@ int main() { printf("MAC Address Prefix: 00:02:F7, Vendor: ARM\r\n"); } - notify_completion(result); - return 0; + TEST_RESULT(result); } From 812a1c3000e9257c39cce02952ba1a6942c881b1 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 28 Jan 2015 10:08:03 +0000 Subject: [PATCH 10/34] Refactored few peripheral tests like DigitalInOut, InteruptIn Checked refactoring progress on LPC11U24 --- .../tests/mbed/digitalin_digitalout/main.cpp | 14 +++++++++----- libraries/tests/mbed/digitalinout/main.cpp | 7 ++++++- libraries/tests/mbed/i2c_TMP102/main.cpp | 10 +++++++--- libraries/tests/mbed/interruptin/main.cpp | 16 ++++++++++------ libraries/tests/mbed/portinout/main.cpp | 7 ++++++- libraries/tests/mbed/portout_portin/main.cpp | 5 +++++ 6 files changed, 43 insertions(+), 16 deletions(-) diff --git a/libraries/tests/mbed/digitalin_digitalout/main.cpp b/libraries/tests/mbed/digitalin_digitalout/main.cpp index 9f683ec3fd..dd952faccc 100644 --- a/libraries/tests/mbed/digitalin_digitalout/main.cpp +++ b/libraries/tests/mbed/digitalin_digitalout/main.cpp @@ -41,20 +41,24 @@ DigitalIn in(p25); #endif -int main() -{ +int main() { + TEST_TIMEOUT(10); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(DigitalIn DigitalOut); + TEST_START("MBED_A5"); + out = 0; wait(0.1); if (in != 0) { printf("ERROR: in != 0\n"); - notify_completion(false); + TEST_RESULT(false); } out = 1; wait(0.1); if (in != 1) { printf("ERROR: in != 1\n"); - notify_completion(false); + TEST_RESULT(false); } - notify_completion(true); + TEST_RESULT(true); } diff --git a/libraries/tests/mbed/digitalinout/main.cpp b/libraries/tests/mbed/digitalinout/main.cpp index ba6a783cb5..2c762b6570 100644 --- a/libraries/tests/mbed/digitalinout/main.cpp +++ b/libraries/tests/mbed/digitalinout/main.cpp @@ -44,6 +44,11 @@ DigitalInOut d2(p25); int main() { + TEST_TIMEOUT(10); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(DigitalInOut); + TEST_START("MBED_A6"); + bool check = true; d1.output(); @@ -76,5 +81,5 @@ int main() check = false; } - notify_completion(check); + TEST_RESULT(check); } diff --git a/libraries/tests/mbed/i2c_TMP102/main.cpp b/libraries/tests/mbed/i2c_TMP102/main.cpp index 6434ff00b6..e76427b601 100644 --- a/libraries/tests/mbed/i2c_TMP102/main.cpp +++ b/libraries/tests/mbed/i2c_TMP102/main.cpp @@ -32,13 +32,17 @@ TMP102 temperature(I2C_SDA, I2C_SCL, 0x90); TMP102 temperature(p28, p27, 0x90); #endif -int main() -{ +int main() { + TEST_TIMEOUT(10); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(DigitalIn DigitalOut); + TEST_START("MBED_A4"); + float t = temperature.read(); printf("TMP102: Temperature: %f\n\r", t); // In our test environment (ARM office) we should get a temperature within // the range ]15, 30[C bool result = (t > 15.0) && (t < 30.0); - notify_completion(result); + TEST_RESULT(result); } diff --git a/libraries/tests/mbed/interruptin/main.cpp b/libraries/tests/mbed/interruptin/main.cpp index 5792c0e753..ada4cd37d5 100644 --- a/libraries/tests/mbed/interruptin/main.cpp +++ b/libraries/tests/mbed/interruptin/main.cpp @@ -87,6 +87,11 @@ void flipper() { } int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(InterruptIn); + TEST_START("MBED_A7"); + IN_OUT_CLEAR; //Test falling edges first in.rise(NULL); @@ -95,7 +100,7 @@ int main() { if(checks != 5) { printf("MBED: falling edges test failed: %d\r\n",checks); - notify_completion(false); + TEST_RESULT(false); } //Now test rising edges @@ -105,7 +110,7 @@ int main() { if (checks != 10) { printf("MBED: raising edges test failed: %d\r\n", checks); - notify_completion(false); + TEST_RESULT(false); } //Now test switch off edge detection @@ -115,7 +120,7 @@ int main() { if (checks != 10) { printf("MBED: edge detection switch off test failed: %d\r\n", checks); - notify_completion(false); + TEST_RESULT(false); } //Finally test both @@ -125,9 +130,8 @@ int main() { if (checks != 20) { printf("MBED: Simultaneous rising and falling edges failed: %d\r\n", checks); - notify_completion(false); + TEST_RESULT(false); } - notify_completion(true); - return 0; + TEST_RESULT(true); } diff --git a/libraries/tests/mbed/portinout/main.cpp b/libraries/tests/mbed/portinout/main.cpp index 7a946f9224..8f1333e305 100644 --- a/libraries/tests/mbed/portinout/main.cpp +++ b/libraries/tests/mbed/portinout/main.cpp @@ -91,6 +91,11 @@ PortInOut port1(PORT_1, MASK_1); PortInOut port2(PORT_2, MASK_2); int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(PortInOut); + TEST_START("MBED_A11"); + bool check = true; port1.output(); @@ -111,5 +116,5 @@ int main() { port2 = 0; wait(0.1); if (port1 != 0) check = false; - notify_completion(check); + TEST_RESULT(check); } diff --git a/libraries/tests/mbed/portout_portin/main.cpp b/libraries/tests/mbed/portout_portin/main.cpp index 9dcef26d93..3797faebb5 100644 --- a/libraries/tests/mbed/portout_portin/main.cpp +++ b/libraries/tests/mbed/portout_portin/main.cpp @@ -91,6 +91,11 @@ PortOut port_out(PORT_1, MASK_1); PortIn port_in (PORT_2, MASK_2); int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(PortOut PortIn); + TEST_START("MBED_A10"); + port_out = MASK_1; wait(0.1); int value = port_in.read(); From f1f2505adc8fb1762c7d635a162bde895b0a2997 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 28 Jan 2015 10:35:08 +0000 Subject: [PATCH 11/34] Refactored host_test.py script to filter for TargetIds in auto-detection flow --- workspace_tools/host_tests/host_test.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/workspace_tools/host_tests/host_test.py b/workspace_tools/host_tests/host_test.py index e8f61ff2b0..9eb62c5a8a 100644 --- a/workspace_tools/host_tests/host_test.py +++ b/workspace_tools/host_tests/host_test.py @@ -283,13 +283,23 @@ class Test(HostTestResults): self.notify("HOST: Start test...") break else: + # Detect if this is property from TEST_ENV print m = re.search('{([\w_]+);([\w\d\+ ]+)}}', line[:-1]) if m and len(m.groups()) == 2: + # This is most likely auto-detection property result[m.group(1)] = m.group(2) if verbose: self.notify("HOST: Property '%s' = '%s'"% (m.group(1), m.group(2))) else: - self.notify("HOST: Unknown property: %s"% line.strip()) + # We can check if this is TArget Id in mbed specific format + m2 = re.search('^([\$]+)([a-fA-F0-9]+)', line[:-1]) + if m2 and len(m2.groups()) == 2: + if verbose: + target_id = m2.group(1) + m2.group(2) + self.notify("HOST: TargetID '%s'"% target_id) + self.notify(line[len(target_id):-1]) + else: + self.notify("HOST: Unknown property: %s"% line.strip()) return result def run(self): From 0bafe71fed5a4ac5af724efcb835a8e93d87d7bb Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 28 Jan 2015 11:38:44 +0000 Subject: [PATCH 12/34] Refactored RTOS_1 test and did some small indent in tests.py --- libraries/tests/rtos/mbed/file/main.cpp | 38 ++++++++++++++----------- workspace_tools/tests.py | 20 ++++++++++--- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/libraries/tests/rtos/mbed/file/main.cpp b/libraries/tests/rtos/mbed/file/main.cpp index 5c8c0f2ecd..591732597e 100644 --- a/libraries/tests/rtos/mbed/file/main.cpp +++ b/libraries/tests/rtos/mbed/file/main.cpp @@ -5,11 +5,17 @@ DigitalOut led2(LED2); -#define SIZE 120 +#define SIZE 100 + +namespace { +// Allocate data buffers +uint8_t data_written[SIZE] = { 0 }; +uint8_t data_read[SIZE] = { 0 }; +} void sd_thread(void const *argument) { - const char *FILE_NAME = "/sd/out.txt"; + const char *FILE_NAME = "/sd/rtos9_test.txt"; #if defined(TARGET_KL25Z) SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd"); @@ -27,55 +33,53 @@ void sd_thread(void const *argument) SDFileSystem sd(p11, p12, p13, p14, "sd"); #endif - // Allocate data buffers - uint8_t data_written[SIZE] = { 0 }; - uint8_t data_read[SIZE] = { 0 }; - { // fill data_written buffer with random data - FILE *f = fopen(FILE_NAME, "w"); + FILE *f = fopen(FILE_NAME, "w+"); if (f) { // write these data into the file - printf("Writing %d bytes to file:\r\n", SIZE); + printf("Writing %d bytes to file:" NL, SIZE); for (int i = 0; i < SIZE; i++) { data_written[i] = rand() % 0xff; fprintf(f, "%c", data_written[i]); printf("%02X ", data_written[i]); if (i && ((i % 20) == 19)) - printf("\r\n"); + printf(NL); } fclose(f); + printf("MBED: Done" NL); } else { + printf("MBED: Can't open '%s'" NL, FILE_NAME); TEST_RESULT(false); - return; } } - printf("\r\n\r\n"); + + printf(NL); { // read back the data from the file and store them in data_read FILE *f = fopen(FILE_NAME, "r"); if (f) { - printf("Reading %d bytes from file:\r\n", SIZE); + printf("MBED: Reading %d bytes from file:" NL, SIZE); for (int i = 0; i < SIZE; i++) { data_read[i] = fgetc(f); printf("%02X ", data_read[i]); if (i && ((i % 20) == 19)) - printf("\r\n"); + printf(NL); } fclose(f); + printf("MBED: Done\r\n"); } else { + printf("MBED: Can't open '%s'" NL, FILE_NAME); TEST_RESULT(false); - return; } } - printf("\r\nDone.\r\n"); // check that the data written == data read for (int i = 0; i < SIZE; i++) { if (data_written[i] != data_read[i]) { + printf("MBED: Data index=%d: w[0x%02X] != r[0x%02X]" NL, i, data_written[i], data_read[i]); TEST_RESULT(false); - return; } } TEST_RESULT(true); @@ -84,7 +88,7 @@ void sd_thread(void const *argument) int main() { TEST_TIMEOUT(20); TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(SD File write-read); + TEST_DESCRIPTION(SD File write read); TEST_START("RTOS_9"); Thread t(sd_thread, NULL, osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25)); diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index 8c6499b636..5503dfe406 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -527,7 +527,7 @@ TESTS = [ "automated": True, #"host_test": "wait_us_auto" }, - + # CMSIS RTOS tests { @@ -629,14 +629,24 @@ TESTS = [ "duration": 15, "automated": True, #"host_test": "wait_us_auto", - "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "KL25Z", "KL05Z", "K64F", "KL46Z", "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_F401VC"], + "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", + "KL25Z", "KL05Z", "K64F", "KL46Z", + "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", + "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", + "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", + "DISCO_F401VC"], }, { "id": "RTOS_8", "description": "ISR (Queue)", "source_dir": join(TEST_DIR, "rtos", "mbed", "isr"), "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB], "automated": True, - "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "KL25Z", "KL05Z", "K64F", "KL46Z", "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_F401VC"], + "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", + "KL25Z", "KL05Z", "K64F", "KL46Z", + "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", + "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", + "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", + "DISCO_F401VC"], }, { "id": "RTOS_9", "description": "SD File write-read", @@ -644,7 +654,9 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB, FS_LIBRARY], "automated": True, "peripherals": ["SD"], - "mcu": ["LPC1768", "LPC11U24", "LPC812", "KL25Z", "KL05Z", "K64F", "KL46Z", "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE"], + "mcu": ["LPC1768", "LPC11U24", "LPC812", "KL25Z", + "KL05Z", "K64F", "KL46Z", "RZ_A1H", + "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE"], }, # Networking Tests From b877fe32f9769ce54e953b701f338dac9b0e5e23 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 28 Jan 2015 15:33:11 +0000 Subject: [PATCH 13/34] Added test case time measurement instead of whole test time measurement for 'Elapsed Time (sec)' report in singletest.py console reports --- workspace_tools/test_api.py | 39 ++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/workspace_tools/test_api.py b/workspace_tools/test_api.py index 498f155354..58315f1edd 100644 --- a/workspace_tools/test_api.py +++ b/workspace_tools/test_api.py @@ -681,18 +681,19 @@ class SingleTestRunner(object): host_test_verbose = self.opts_verbose_test_result_only or self.opts_verbose host_test_reset = self.opts_mut_reset_type if reset_type is None else reset_type - single_test_result, single_test_output = self.run_host_test(test.host_test, - image_path, disk, port, duration, - micro=target_name, - verbose=host_test_verbose, - reset=host_test_reset, - reset_tout=reset_tout, - copy_method=selected_copy_method, - program_cycle_s=target_by_mcu.program_cycle_s()) + single_test_result, single_test_output, single_testduration = self.run_host_test(test.host_test, + image_path, disk, port, duration, + micro=target_name, + verbose=host_test_verbose, + reset=host_test_reset, + reset_tout=reset_tout, + copy_method=selected_copy_method, + program_cycle_s=target_by_mcu.program_cycle_s()) # Store test result test_all_result.append(single_test_result) - elapsed_time = time() - start_host_exec_time + total_elapsed_time = time() - start_host_exec_time # Test time with copy (flashing) / reset + elapsed_time = single_testduration # TIme of single test case execution after reset detailed_test_results[test_index] = { 'single_test_result' : single_test_result, @@ -730,9 +731,14 @@ class SingleTestRunner(object): if self.db_logger: self.db_logger.disconnect() - return (self.shape_global_test_loop_result(test_all_result), target_name, toolchain_name, - test_id, test_description, round(elapsed_time, 2), - duration, self.shape_test_loop_ok_result_count(test_all_result)), detailed_test_results + return (self.shape_global_test_loop_result(test_all_result), + target_name, + toolchain_name, + test_id, + test_description, + round(elapsed_time, 2), + duration, + self.shape_test_loop_ok_result_count(test_all_result)), detailed_test_results def print_test_result(self, test_result, target_name, toolchain_name, test_id, test_description, elapsed_time, duration): @@ -825,6 +831,7 @@ class SingleTestRunner(object): proc = Popen(cmd, stdout=PIPE, cwd=HOST_TESTS) obs = ProcessObserver(proc) start_time = time() + start_time_update = False line = '' output = [] while (time() - start_time) < (2 * duration): @@ -837,11 +844,17 @@ class SingleTestRunner(object): output.append(c) # Give the mbed under test a way to communicate the end of the test if c in ['\n', '\r']: + if not start_time_update and 'HOST: Reset target...' in line: + # We will update this marker only once to prevent multiple time resets + start_time_update = True + start_time = time() if '{end}' in line: break line = '' else: line += c + end_time = time() + testcase_duration = end_time - start_time # Test case duration from reset to {end} c = get_char_from_queue(obs) @@ -857,7 +870,7 @@ class SingleTestRunner(object): obs.stop() result = get_test_result(output) - return result, "".join(output) + return result, "".join(output), testcase_duration def is_peripherals_available(self, target_mcu_name, peripherals=None): """ Checks if specified target should run specific peripheral test case From ab472195ceb4c71317a7a71039149bfd9537dc2a Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 28 Jan 2015 15:34:28 +0000 Subject: [PATCH 14/34] Refactored EEPROM and InterruptIn test cases to do auto-detection act Refactoring Tested with few Nucleo boards and Nordic board --- libraries/tests/mbed/i2c_eeprom/main.cpp | 10 +++++++--- libraries/tests/mbed/i2c_eeprom_line/main.cpp | 14 +++++++++----- libraries/tests/mbed/interruptin/main.cpp | 2 +- workspace_tools/tests.py | 1 + 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/libraries/tests/mbed/i2c_eeprom/main.cpp b/libraries/tests/mbed/i2c_eeprom/main.cpp index 97a962d217..fc7436c75b 100644 --- a/libraries/tests/mbed/i2c_eeprom/main.cpp +++ b/libraries/tests/mbed/i2c_eeprom/main.cpp @@ -70,8 +70,12 @@ const int i2c_freq_hz = 400000; const int i2c_delay_us = 0; } -int main() -{ +int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(I2C EEPROM read write test); + TEST_START("MBED_A19"); + const int EEPROM_MEM_ADDR = 0xA0; const char MARK = 0x66; int fw = 0; @@ -143,5 +147,5 @@ int main() printf("\tTotal failures: %d\r\n", fw + fr + fc); } - notify_completion(result); + TEST_RESULT(result); } diff --git a/libraries/tests/mbed/i2c_eeprom_line/main.cpp b/libraries/tests/mbed/i2c_eeprom_line/main.cpp index 1b701d469d..7d3f11cda7 100644 --- a/libraries/tests/mbed/i2c_eeprom_line/main.cpp +++ b/libraries/tests/mbed/i2c_eeprom_line/main.cpp @@ -22,13 +22,13 @@ ******************************************************************************/ // Test configuration block -namespace -{ +namespace { const int ntests = 1000; const int i2c_freq_hz = 400000; const int i2c_delay_us = 0; // const int EEPROM_24LC256_SIZE = (256 * 1024 / 8); // 256 kbit memory } + // End of test configuration block #if defined(TARGET_KL25Z) @@ -75,8 +75,12 @@ I2C i2c(p28, p27); #define PATTERN_MASK 0x66, ~0x66, 0x00, 0xFF, 0xA5, 0x5A, 0xF0, 0x0F -int main() -{ +int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(I2C EEPROM line read write test); + TEST_START("MBED_A25"); + const int EEPROM_MEM_ADDR = 0xA0; bool result = true; @@ -134,5 +138,5 @@ int main() printf("EEPROM: Pattern match errors: %d/%d ... [%s]\r\n", pattern_errors, ntests, pattern_errors ? "FAIL" : "OK"); result = write_errors == 0 && read_errors == 0; - notify_completion(result); + TEST_RESULT(result); } diff --git a/libraries/tests/mbed/interruptin/main.cpp b/libraries/tests/mbed/interruptin/main.cpp index ada4cd37d5..882c5e7f26 100644 --- a/libraries/tests/mbed/interruptin/main.cpp +++ b/libraries/tests/mbed/interruptin/main.cpp @@ -87,7 +87,7 @@ void flipper() { } int main() { - TEST_TIMEOUT(20); + TEST_TIMEOUT(15); TEST_HOSTTEST(default_auto); TEST_DESCRIPTION(InterruptIn); TEST_START("MBED_A7"); diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index 5503dfe406..2329095402 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -119,6 +119,7 @@ TESTS = [ "id": "MBED_A7", "description": "InterruptIn", "source_dir": join(TEST_DIR, "mbed", "interruptin"), "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB], + "duration": 15, "automated": True, "peripherals": ["digital_loop"] }, From 9fc02738acb547ea4e99b1208eb790708452cb22 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 28 Jan 2015 16:08:54 +0000 Subject: [PATCH 15/34] Refactored TCP and UPD client tests (with default host test instrumentation) --- libraries/tests/net/helloworld/tcpclient/main.cpp | 8 ++++++-- libraries/tests/net/helloworld/udpclient/main.cpp | 12 +++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/libraries/tests/net/helloworld/tcpclient/main.cpp b/libraries/tests/net/helloworld/tcpclient/main.cpp index 02ba6b74fd..4d1d05014f 100644 --- a/libraries/tests/net/helloworld/tcpclient/main.cpp +++ b/libraries/tests/net/helloworld/tcpclient/main.cpp @@ -24,6 +24,11 @@ bool find_substring(const char *first, const char *last, const char *s_first, co } int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(TCP client hello world); + TEST_START("NET_1"); + bool result = false; EthernetInterface eth; eth.init(); //Use DHCP @@ -76,6 +81,5 @@ int main() { sock.close(); eth.disconnect(); - notify_completion(result); - return 0; + TEST_RESULT(result); } diff --git a/libraries/tests/net/helloworld/udpclient/main.cpp b/libraries/tests/net/helloworld/udpclient/main.cpp index 843d906ca2..ecf1970e6b 100644 --- a/libraries/tests/net/helloworld/udpclient/main.cpp +++ b/libraries/tests/net/helloworld/udpclient/main.cpp @@ -10,6 +10,11 @@ namespace { int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(NIST Internet Time Service); + TEST_START("NET_2"); + bool result = false; EthernetInterface eth; eth.init(); //Use DHCP @@ -34,9 +39,11 @@ int main() { if (n > 0) { result = true; const unsigned int timeRes = ntohl(in_buffer_uint); - const float years = timeRes / 60.0 / 60.0 / 24.0 / 365; + const float years = timeRes / 60.0 / 60.0 / 24.0 / 365.0; + const float days = timeRes / 24.0 / 60.0 / 60.0; printf("UDP: Received %d bytes from server %s on port %d\r\n", n, nist.get_address(), nist.get_port()); printf("UDP: %u seconds since 01/01/1900 00:00 GMT ... %s\r\n", timeRes, timeRes > 0 ? "[OK]" : "[FAIL]"); + printf("UDP: %.2f days since 01/01/1900 00:00 GMT ... %s\r\n", days, timeRes > 0 ? "[OK]" : "[FAIL]"); printf("UDP: %.2f years since 01/01/1900 00:00 GMT ... %s\r\n", years, timeRes > YEARS_TO_PASS ? "[OK]" : "[FAIL]"); if (years < YEARS_TO_PASS) { @@ -45,6 +52,5 @@ int main() { } sock.close(); eth.disconnect(); - notify_completion(result); - return 0; + TEST_RESULT(result); } From 111b55784ecc8708772a94397cc4acb793c6cc3c Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 28 Jan 2015 16:29:36 +0000 Subject: [PATCH 16/34] Refactored TCP echo server --- libraries/tests/net/echo/tcp_server/main.cpp | 12 ++++++-- workspace_tools/host_tests/__init__.py | 2 ++ .../host_tests/tcpecho_server_auto.py | 30 ++++++++----------- workspace_tools/tests.py | 6 ++-- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/libraries/tests/net/echo/tcp_server/main.cpp b/libraries/tests/net/echo/tcp_server/main.cpp index 720f32ffb6..04fa0998c2 100644 --- a/libraries/tests/net/echo/tcp_server/main.cpp +++ b/libraries/tests/net/echo/tcp_server/main.cpp @@ -1,4 +1,5 @@ #include "mbed.h" +#include "test_env.h" #include "EthernetInterface.h" namespace { @@ -7,22 +8,27 @@ namespace { } int main (void) { + TEST_TIMEOUT(20); + TEST_HOSTTEST(tcpecho_server_auto); + TEST_DESCRIPTION(TCP echo server); + TEST_START("NET_3"); + char buffer[BUFFER_SIZE] = {0}; EthernetInterface eth; eth.init(); //Use DHCP eth.connect(); - printf("MBED: Server IP Address is %s:%d\r\n", eth.getIPAddress(), ECHO_SERVER_PORT); + printf("MBED: Server IP Address is %s:%d" NL, eth.getIPAddress(), ECHO_SERVER_PORT); TCPSocketServer server; server.bind(ECHO_SERVER_PORT); server.listen(); while (true) { - printf("MBED: Wait for new connection...\n"); + printf("MBED: Wait for new connection..." NL); TCPSocketConnection client; server.accept(client); client.set_blocking(false, 1500); // Timeout after (1.5)s - printf("MBED: Connection from: %s\r\n", client.get_address()); + printf("MBED: Connection from: %s" NL, client.get_address()); while (true) { const int n = client.receive(buffer, sizeof(buffer)); diff --git a/workspace_tools/host_tests/__init__.py b/workspace_tools/host_tests/__init__.py index 28e1017867..b184da595a 100644 --- a/workspace_tools/host_tests/__init__.py +++ b/workspace_tools/host_tests/__init__.py @@ -24,6 +24,7 @@ from dev_null_auto import DevNullTest from rtc_auto import RTCTest from echo import EchoTest from detect_auto import DetectPlatformTest +from tcpecho_server_auto import TCPEchoServerTest HOSTREGISTRY = HostRegistry() @@ -36,6 +37,7 @@ 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()) +HOSTREGISTRY.register_host_test("tcpecho_server_auto", TCPEchoServerTest()) ############################################################################### # Functional interface for test supervisor registry diff --git a/workspace_tools/host_tests/tcpecho_server_auto.py b/workspace_tools/host_tests/tcpecho_server_auto.py index a7c3d46af1..8bc0e300d7 100644 --- a/workspace_tools/host_tests/tcpecho_server_auto.py +++ b/workspace_tools/host_tests/tcpecho_server_auto.py @@ -20,10 +20,8 @@ import sys import uuid import socket from sys import stdout -from host_test import DefaultTest - -class TCPEchoServerTest(DefaultTest): +class TCPEchoServerTest(): ECHO_SERVER_ADDRESS = "" ECHO_PORT = 0 ECHO_LOOPs = 100 @@ -32,18 +30,18 @@ class TCPEchoServerTest(DefaultTest): PATTERN_SERVER_IP = "Server IP Address is (\d+).(\d+).(\d+).(\d+):(\d+)" re_detect_server_ip = re.compile(PATTERN_SERVER_IP) - def test(self): + def test(self, selftest): result = False - c = self.mbed.serial_readline() + c = selftest.mbed.serial_readline() if c is None: - return self.RESULT_IO_SERIAL - self.notify(c) + return selftest.RESULT_IO_SERIAL + selftest.notify(c) m = self.re_detect_server_ip.search(c) if m and len(m.groups()): self.ECHO_SERVER_ADDRESS = ".".join(m.groups()[:4]) self.ECHO_PORT = int(m.groups()[4]) # must be integer for socket.connect method - self.notify("HOST: TCP Server found at: " + self.ECHO_SERVER_ADDRESS + ":" + str(self.ECHO_PORT)) + selftest.notify("HOST: TCP Server found at: " + self.ECHO_SERVER_ADDRESS + ":" + str(self.ECHO_PORT)) # We assume this test fails so can't send 'error' message to server try: @@ -51,8 +49,8 @@ class TCPEchoServerTest(DefaultTest): self.s.connect((self.ECHO_SERVER_ADDRESS, self.ECHO_PORT)) except Exception, e: self.s = None - self.notify("HOST: Socket error: %s"% e) - return self.RESULT_ERROR + selftest.notify("HOST: Socket error: %s"% e) + return selftest.RESULT_ERROR print 'HOST: Sending %d echo strings...'% self.ECHO_LOOPs, for i in range(0, self.ECHO_LOOPs): @@ -62,8 +60,8 @@ class TCPEchoServerTest(DefaultTest): data = self.s.recv(128) except Exception, e: self.s = None - self.notify("HOST: Socket error: %s"% e) - return self.RESULT_ERROR + selftest.notify("HOST: Socket error: %s"% e) + return selftest.RESULT_ERROR received_str = repr(data)[1:-1] if TEST_STRING == received_str: # We need to cut not needed single quotes from the string @@ -81,10 +79,6 @@ class TCPEchoServerTest(DefaultTest): if self.s is not None: self.s.close() else: - self.notify("HOST: TCP Server not found") + selftest.notify("HOST: TCP Server not found") result = False - return self.RESULT_SUCCESS if result else self.RESULT_FAILURE - - -if __name__ == '__main__': - TCPEchoServerTest().run() + return selftest.RESULT_SUCCESS if result else selftest.RESULT_FAILURE diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index 2329095402..8ed7686141 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -680,9 +680,9 @@ TESTS = [ { "id": "NET_3", "description": "TCP echo server", "source_dir": join(TEST_DIR, "net", "echo", "tcp_server"), - "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], + "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB], "automated": True, - "host_test" : "tcpecho_server_auto", + #"host_test" : "tcpecho_server_auto", "peripherals": ["ethernet"], }, { @@ -696,7 +696,7 @@ TESTS = [ { "id": "NET_5", "description": "UDP echo server", "source_dir": join(TEST_DIR, "net", "echo", "udp_server"), - "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], + "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB], "automated": True, "host_test" : "udpecho_server_auto", "peripherals": ["ethernet"] From f81509c933f238467f8d5b5adfc8bfaf12a451ff Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 28 Jan 2015 16:43:40 +0000 Subject: [PATCH 17/34] Refactored UDP echo server --- libraries/tests/net/echo/udp_server/main.cpp | 6 +++++ workspace_tools/host_tests/__init__.py | 2 ++ .../host_tests/udpecho_server_auto.py | 24 +++++++------------ workspace_tools/tests.py | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/libraries/tests/net/echo/udp_server/main.cpp b/libraries/tests/net/echo/udp_server/main.cpp index c7745dfb12..fa7e6b2c40 100644 --- a/libraries/tests/net/echo/udp_server/main.cpp +++ b/libraries/tests/net/echo/udp_server/main.cpp @@ -1,4 +1,5 @@ #include "mbed.h" +#include "test_env.h" #include "EthernetInterface.h" namespace { @@ -7,6 +8,11 @@ namespace { } int main (void) { + TEST_TIMEOUT(20); + TEST_HOSTTEST(udpecho_server_auto); + TEST_DESCRIPTION(UDP echo server); + TEST_START("NET_5"); + EthernetInterface eth; eth.init(); //Use DHCP eth.connect(); diff --git a/workspace_tools/host_tests/__init__.py b/workspace_tools/host_tests/__init__.py index b184da595a..d8c2d528e4 100644 --- a/workspace_tools/host_tests/__init__.py +++ b/workspace_tools/host_tests/__init__.py @@ -25,6 +25,7 @@ from rtc_auto import RTCTest from echo import EchoTest from detect_auto import DetectPlatformTest from tcpecho_server_auto import TCPEchoServerTest +from udpecho_server_auto import UDPEchoServerTest HOSTREGISTRY = HostRegistry() @@ -38,6 +39,7 @@ HOSTREGISTRY.register_host_test("rtc_auto", RTCTest()) HOSTREGISTRY.register_host_test("echo", EchoTest()) HOSTREGISTRY.register_host_test("detect_auto", DetectPlatformTest()) HOSTREGISTRY.register_host_test("tcpecho_server_auto", TCPEchoServerTest()) +HOSTREGISTRY.register_host_test("udpecho_server_auto", UDPEchoServerTest()) ############################################################################### # Functional interface for test supervisor registry diff --git a/workspace_tools/host_tests/udpecho_server_auto.py b/workspace_tools/host_tests/udpecho_server_auto.py index 83829492e9..a7ee026306 100644 --- a/workspace_tools/host_tests/udpecho_server_auto.py +++ b/workspace_tools/host_tests/udpecho_server_auto.py @@ -19,11 +19,9 @@ import re import sys import uuid from sys import stdout -from host_test import DefaultTest from socket import socket, AF_INET, SOCK_DGRAM - -class UDPEchoServerTest(DefaultTest): +class UDPEchoServerTest(): ECHO_SERVER_ADDRESS = "" ECHO_PORT = 0 s = None # Socket @@ -31,26 +29,26 @@ class UDPEchoServerTest(DefaultTest): PATTERN_SERVER_IP = "Server IP Address is (\d+).(\d+).(\d+).(\d+):(\d+)" re_detect_server_ip = re.compile(PATTERN_SERVER_IP) - def test(self): + def test(self, selftest): result = True - serial_ip_msg = self.mbed.serial_readline() + serial_ip_msg = selftest.mbed.serial_readline() if serial_ip_msg is None: - return self.RESULT_IO_SERIAL - self.notify(serial_ip_msg) + return selftest.RESULT_IO_SERIAL + selftest.notify(serial_ip_msg) # Searching for IP address and port prompted by server m = self.re_detect_server_ip.search(serial_ip_msg) if m and len(m.groups()): self.ECHO_SERVER_ADDRESS = ".".join(m.groups()[:4]) self.ECHO_PORT = int(m.groups()[4]) # must be integer for socket.connect method - self.notify("HOST: UDP Server found at: " + self.ECHO_SERVER_ADDRESS + ":" + str(self.ECHO_PORT)) + selftest.notify("HOST: UDP Server found at: " + self.ECHO_SERVER_ADDRESS + ":" + str(self.ECHO_PORT)) # We assume this test fails so can't send 'error' message to server try: self.s = socket(AF_INET, SOCK_DGRAM) except Exception, e: self.s = None - self.notify("HOST: Socket error: %s"% e) - return self.RESULT_ERROR + selftest.notify("HOST: Socket error: %s"% e) + return selftest.RESULT_ERROR for i in range(0, 100): TEST_STRING = str(uuid.uuid4()) @@ -67,8 +65,4 @@ class UDPEchoServerTest(DefaultTest): if self.s is not None: self.s.close() - return self.RESULT_SUCCESS if result else self.RESULT_FAILURE - - -if __name__ == '__main__': - UDPEchoServerTest().run() + return selftest.RESULT_SUCCESS if result else selftest.RESULT_FAILURE diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index 8ed7686141..f8b3ea9cd0 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -698,7 +698,7 @@ TESTS = [ "source_dir": join(TEST_DIR, "net", "echo", "udp_server"), "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB], "automated": True, - "host_test" : "udpecho_server_auto", + #"host_test" : "udpecho_server_auto", "peripherals": ["ethernet"] }, { From bcfbc3575d3c68890d25e2a308d1380a1f4e1e2b Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Fri, 30 Jan 2015 08:38:15 +0000 Subject: [PATCH 18/34] Added -f (filter) to configuration switch --config We can now use --config -f to filter only targets we are interested in --- workspace_tools/singletest.py | 2 +- workspace_tools/test_api.py | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/workspace_tools/singletest.py b/workspace_tools/singletest.py index c2e08943d3..bd13edcf78 100644 --- a/workspace_tools/singletest.py +++ b/workspace_tools/singletest.py @@ -146,7 +146,7 @@ if __name__ == '__main__': if opts.verbose_test_configuration_only: print "MUTs configuration in %s:"% opts.muts_spec_filename if MUTs: - print print_muts_configuration_from_json(MUTs) + print print_muts_configuration_from_json(MUTs, platform_filter=opts.general_filter_regex) print print "Test specification in %s:"% opts.test_spec_filename if test_spec: diff --git a/workspace_tools/test_api.py b/workspace_tools/test_api.py index 58315f1edd..98eab246fc 100644 --- a/workspace_tools/test_api.py +++ b/workspace_tools/test_api.py @@ -989,7 +989,7 @@ def get_json_data_from_file(json_spec_filename, verbose=False): return result -def print_muts_configuration_from_json(json_data, join_delim=", "): +def print_muts_configuration_from_json(json_data, join_delim=", ", platform_filter=None): """ Prints MUTs configuration passed to test script for verboseness """ muts_info_cols = [] @@ -1010,12 +1010,17 @@ def print_muts_configuration_from_json(json_data, join_delim=", "): for k in json_data: row = [k] mut_info = json_data[k] - for col in muts_info_cols: - cell_val = mut_info[col] if col in mut_info else None - if type(cell_val) == ListType: - cell_val = join_delim.join(cell_val) - row.append(cell_val) - pt.add_row(row) + + add_row = True + if platform_filter and 'mcu' in mut_info: + add_row = re.search(platform_filter, mut_info['mcu']) is not None + if add_row: + for col in muts_info_cols: + cell_val = mut_info[col] if col in mut_info else None + if type(cell_val) == ListType: + cell_val = join_delim.join(cell_val) + row.append(cell_val) + pt.add_row(row) return pt.get_string() @@ -1052,6 +1057,7 @@ def print_test_configuration_from_json(json_data, join_delim=", "): target_name = target if target in TARGET_MAP else "%s*"% target row = [target_name] toolchains = targets[target] + for toolchain in sorted(toolchains_info_cols): # Check for conflicts: target vs toolchain conflict = False From 605ee4a0b100da5239974391638a61914738e146 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Fri, 30 Jan 2015 09:31:21 +0000 Subject: [PATCH 19/34] Added HTTP and NTP test to autodetection pool --- .../protocols/HTTPClient_HelloWorld/main.cpp | 17 +++++++++-------- .../net/protocols/NTPClient_HelloWorld/main.cpp | 14 ++++++++------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/libraries/tests/net/protocols/HTTPClient_HelloWorld/main.cpp b/libraries/tests/net/protocols/HTTPClient_HelloWorld/main.cpp index b55a616036..7e9417619d 100644 --- a/libraries/tests/net/protocols/HTTPClient_HelloWorld/main.cpp +++ b/libraries/tests/net/protocols/HTTPClient_HelloWorld/main.cpp @@ -8,8 +8,12 @@ namespace { const int BUFFER_SIZE = 512; } -int main() -{ +int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(HTTP client hello world); + TEST_START("NET_7"); + char http_request_buffer[BUFFER_SIZE + 1] = {0}; HTTPClient http; EthernetInterface eth; @@ -31,8 +35,7 @@ int main() if (result == false) { eth.disconnect(); - notify_completion(false); - exit(ret); + TEST_RESULT(false); } } @@ -56,11 +59,9 @@ int main() if (result == false) { eth.disconnect(); - notify_completion(false); - exit(ret); + TEST_RESULT(false); } } eth.disconnect(); - notify_completion(true); - return 0; + TEST_RESULT(true); } diff --git a/libraries/tests/net/protocols/NTPClient_HelloWorld/main.cpp b/libraries/tests/net/protocols/NTPClient_HelloWorld/main.cpp index ee24d34d66..c96b5145b0 100644 --- a/libraries/tests/net/protocols/NTPClient_HelloWorld/main.cpp +++ b/libraries/tests/net/protocols/NTPClient_HelloWorld/main.cpp @@ -3,8 +3,12 @@ #include "EthernetInterface.h" #include "NTPClient.h" -int main() -{ +int main() { + TEST_TIMEOUT(15); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(NTP client); + TEST_START("NET_8"); + EthernetInterface eth; NTPClient ntp; eth.init(); //Use DHCP @@ -27,11 +31,9 @@ int main() } if (result == false) { - notify_completion(false); - exit(ret); + TEST_RESULT(false); } } eth.disconnect(); - notify_completion(true); - return 0; + TEST_RESULT(true); } From 035714e4091669af360a7afa65f9a659883de43e Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Fri, 30 Jan 2015 09:57:36 +0000 Subject: [PATCH 20/34] Added NET_4, NET_6 and NET_13 tests to autodetection pool --- libraries/tests/net/echo/tcp_client/main.cpp | 17 +++-- .../tests/net/echo/tcp_client_loop/main.cpp | 9 ++- libraries/tests/net/echo/udp_client/main.cpp | 12 ++-- workspace_tools/host_tests/__init__.py | 5 +- .../host_tests/tcpecho_client_auto.py | 69 ++++++++----------- .../host_tests/udpecho_client_auto.py | 60 +++++++--------- workspace_tools/tests.py | 6 +- 7 files changed, 81 insertions(+), 97 deletions(-) diff --git a/libraries/tests/net/echo/tcp_client/main.cpp b/libraries/tests/net/echo/tcp_client/main.cpp index 5d58a95f4d..d9fc72d29c 100644 --- a/libraries/tests/net/echo/tcp_client/main.cpp +++ b/libraries/tests/net/echo/tcp_client/main.cpp @@ -1,8 +1,8 @@ #include "mbed.h" +#include "test_env.h" #include "EthernetInterface.h" -struct s_ip_address -{ +struct s_ip_address { int ip_1; int ip_2; int ip_3; @@ -10,6 +10,11 @@ struct s_ip_address }; int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(tcpecho_client_auto); + TEST_DESCRIPTION(TCP echo client); + TEST_START("NET_4"); + char buffer[256] = {0}; char out_buffer[] = "Hello World\n"; char out_success[] = "{{success}}\n{{end}}\n"; @@ -17,20 +22,20 @@ int main() { s_ip_address ip_addr = {0, 0, 0, 0}; int port = 0; - printf("TCPCllient waiting for server IP and port...\r\n"); + printf("TCPCllient waiting for server IP and port..." NL); scanf("%d.%d.%d.%d:%d", &ip_addr.ip_1, &ip_addr.ip_2, &ip_addr.ip_3, &ip_addr.ip_4, &port); - printf("Address received:%d.%d.%d.%d:%d\r\n", ip_addr.ip_1, ip_addr.ip_2, ip_addr.ip_3, ip_addr.ip_4, port); + printf("Address received:%d.%d.%d.%d:%d" NL, ip_addr.ip_1, ip_addr.ip_2, ip_addr.ip_3, ip_addr.ip_4, port); EthernetInterface eth; eth.init(); //Use DHCP eth.connect(); - printf("TCPClient IP Address is %s\r\n", eth.getIPAddress()); + printf("TCPClient IP Address is %s" NL, eth.getIPAddress()); sprintf(buffer, "%d.%d.%d.%d", ip_addr.ip_1, ip_addr.ip_2, ip_addr.ip_3, ip_addr.ip_4); TCPSocketConnection socket; while (socket.connect(buffer, port) < 0) { - printf("TCPCllient unable to connect to %s:%d\r\n", buffer, port); + printf("TCPCllient unable to connect to %s:%d" NL, buffer, port); wait(1); } diff --git a/libraries/tests/net/echo/tcp_client_loop/main.cpp b/libraries/tests/net/echo/tcp_client_loop/main.cpp index 7005f25fbd..6fe95bff5f 100644 --- a/libraries/tests/net/echo/tcp_client_loop/main.cpp +++ b/libraries/tests/net/echo/tcp_client_loop/main.cpp @@ -21,8 +21,12 @@ char char_rand() { return (rand() % ASCII_MAX) + ' '; } - int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(tcpecho_client_auto); + TEST_DESCRIPTION(TCP client echo loop); + TEST_START("NET_13"); + char buffer[BUFFER_SIZE] = {0}; char out_buffer[BUFFER_SIZE] = {0}; s_ip_address ip_addr = {0, 0, 0, 0}; @@ -70,6 +74,5 @@ int main() { } socket.close(); eth.disconnect(); - notify_completion(result); - return 0; + TEST_RESULT(result); } diff --git a/libraries/tests/net/echo/udp_client/main.cpp b/libraries/tests/net/echo/udp_client/main.cpp index df1983a50c..65e2e17896 100644 --- a/libraries/tests/net/echo/udp_client/main.cpp +++ b/libraries/tests/net/echo/udp_client/main.cpp @@ -11,8 +11,7 @@ namespace { const int MAX_ECHO_LOOPS = 100; const char ASCII_MAX = '~' - ' '; - struct s_ip_address - { + struct s_ip_address { int ip_1; int ip_2; int ip_3; @@ -24,8 +23,12 @@ char char_rand() { return (rand() % ASCII_MAX) + ' '; } - int main() { + TEST_TIMEOUT(20); + TEST_HOSTTEST(udpecho_client_auto); + TEST_DESCRIPTION(UDP echo client); + TEST_START("NET_6"); + char buffer[BUFFER_SIZE] = {0}; char out_buffer[BUFFER_SIZE] = {0}; s_ip_address ip_addr = {0, 0, 0, 0}; @@ -75,6 +78,5 @@ int main() { socket.close(); eth.disconnect(); - notify_completion(result); - return 0; + TEST_RESULT(result); } diff --git a/workspace_tools/host_tests/__init__.py b/workspace_tools/host_tests/__init__.py index d8c2d528e4..03c28e7e5c 100644 --- a/workspace_tools/host_tests/__init__.py +++ b/workspace_tools/host_tests/__init__.py @@ -26,7 +26,8 @@ from echo import EchoTest from detect_auto import DetectPlatformTest from tcpecho_server_auto import TCPEchoServerTest from udpecho_server_auto import UDPEchoServerTest - +from tcpecho_client_auto import TCPEchoClientTest +from udpecho_client_auto import UDPEchoClientTest HOSTREGISTRY = HostRegistry() HOSTREGISTRY.register_host_test("default", DefaultAuto()) @@ -40,6 +41,8 @@ HOSTREGISTRY.register_host_test("echo", EchoTest()) HOSTREGISTRY.register_host_test("detect_auto", DetectPlatformTest()) HOSTREGISTRY.register_host_test("tcpecho_server_auto", TCPEchoServerTest()) HOSTREGISTRY.register_host_test("udpecho_server_auto", UDPEchoServerTest()) +HOSTREGISTRY.register_host_test("tcpecho_client_auto", TCPEchoClientTest()) +HOSTREGISTRY.register_host_test("udpecho_client_auto", UDPEchoClientTest()) ############################################################################### # Functional interface for test supervisor registry diff --git a/workspace_tools/host_tests/tcpecho_client_auto.py b/workspace_tools/host_tests/tcpecho_client_auto.py index 2ef44b3a17..85d76c92c6 100644 --- a/workspace_tools/host_tests/tcpecho_client_auto.py +++ b/workspace_tools/host_tests/tcpecho_client_auto.py @@ -18,47 +18,11 @@ limitations under the License. import sys import socket from sys import stdout -from host_test import HostTestResults, Test from SocketServer import BaseRequestHandler, TCPServer - SERVER_IP = str(socket.gethostbyname(socket.getfqdn())) SERVER_PORT = 7 - -class TCPEchoClientTest(Test): - def __init__(self): - HostTestResults.__init__(self) - Test.__init__(self) - - def send_server_ip_port(self, ip_address, port_no): - """ Set up network host. Reset target and and send server IP via serial to Mbed - """ - c = self.mbed.serial_readline() # 'TCPCllient waiting for server IP and port...' - if c is None: - self.print_result(self.RESULT_IO_SERIAL) - return - - self.notify(c.strip()) - self.notify("HOST: Sending server IP Address to target...") - - connection_str = ip_address + ":" + str(port_no) + "\n" - self.mbed.serial_write(connection_str) - self.notify(connection_str) - - # Two more strings about connection should be sent by MBED - for i in range(0, 2): - c = self.mbed.serial_readline() - if c is None: - self.print_result(self.RESULT_IO_SERIAL) - return - self.notify(c.strip()) - - def test(self): - # Returning none will suppress host test from printing success code - return None - - class TCPEchoClient_Handler(BaseRequestHandler): def handle(self): """ One handle per connection @@ -78,12 +42,33 @@ class TCPEchoClient_Handler(BaseRequestHandler): count += 1 stdout.flush() +class TCPEchoClientTest(): + def send_server_ip_port(self, selftest, ip_address, port_no): + """ Set up network host. Reset target and and send server IP via serial to Mbed + """ + c = selftest.mbed.serial_readline() # 'TCPCllient waiting for server IP and port...' + if c is None: + self.print_result(selftest.RESULT_IO_SERIAL) + return -server = TCPServer((SERVER_IP, SERVER_PORT), TCPEchoClient_Handler) -print "HOST: Listening for TCP connections: " + SERVER_IP + ":" + str(SERVER_PORT) + selftest.notify(c.strip()) + selftest.notify("HOST: Sending server IP Address to target...") -mbed_test = TCPEchoClientTest(); -mbed_test.run() -mbed_test.send_server_ip_port(SERVER_IP, SERVER_PORT) + connection_str = ip_address + ":" + str(port_no) + "\n" + selftest.mbed.serial_write(connection_str) + selftest.notify(connection_str) -server.serve_forever() + # Two more strings about connection should be sent by MBED + for i in range(0, 2): + c = selftest.mbed.serial_readline() + if c is None: + selftest.print_result(self.RESULT_IO_SERIAL) + return + selftest.notify(c.strip()) + + def test(self, selftest): + # Returning none will suppress host test from printing success code + server = TCPServer((SERVER_IP, SERVER_PORT), TCPEchoClient_Handler) + print "HOST: Listening for TCP connections: " + SERVER_IP + ":" + str(SERVER_PORT) + self.send_server_ip_port(selftest, SERVER_IP, SERVER_PORT) + server.serve_forever() diff --git a/workspace_tools/host_tests/udpecho_client_auto.py b/workspace_tools/host_tests/udpecho_client_auto.py index 8686f6a6e3..cb61ebb6f6 100644 --- a/workspace_tools/host_tests/udpecho_client_auto.py +++ b/workspace_tools/host_tests/udpecho_client_auto.py @@ -18,42 +18,11 @@ limitations under the License. import sys import socket from sys import stdout -from host_test import HostTestResults, Test from SocketServer import BaseRequestHandler, UDPServer - SERVER_IP = str(socket.gethostbyname(socket.getfqdn())) SERVER_PORT = 7 - -class UDPEchoClientTest(Test): - def __init__(self): - HostTestResults.__init__(self) - Test.__init__(self) - - def send_server_ip_port(self, ip_address, port_no): - c = self.mbed.serial_readline() # 'UDPCllient waiting for server IP and port...' - if c is None: - self.print_result(self.RESULT_IO_SERIAL) - return - self.notify(c.strip()) - - self.notify("HOST: Sending server IP Address to target...") - connection_str = ip_address + ":" + str(port_no) + "\n" - self.mbed.serial_write(connection_str) - - c = self.mbed.serial_readline() # 'UDPCllient waiting for server IP and port...' - if c is None: - self.print_result(self.RESULT_IO_SERIAL) - return - self.notify(c.strip()) - return self.RESULT_PASSIVE - - def test(self): - # Returning none will suppress host test from printing success code - return None - - class UDPEchoClient_Handler(BaseRequestHandler): def handle(self): """ One handle per connection @@ -67,12 +36,29 @@ class UDPEchoClient_Handler(BaseRequestHandler): sys.stdout.write('.') stdout.flush() +class UDPEchoClientTest(): -server = UDPServer((SERVER_IP, SERVER_PORT), UDPEchoClient_Handler) -print "HOST: Listening for UDP connections..." + def send_server_ip_port(self, selftest, ip_address, port_no): + c = selftest.mbed.serial_readline() # 'UDPCllient waiting for server IP and port...' + if c is None: + selftest.print_result(selftest.RESULT_IO_SERIAL) + return + selftest.notify(c.strip()) -mbed_test = UDPEchoClientTest(); -mbed_test.run() -mbed_test.send_server_ip_port(SERVER_IP, SERVER_PORT) + selftest.notify("HOST: Sending server IP Address to target...") + connection_str = ip_address + ":" + str(port_no) + "\n" + selftest.mbed.serial_write(connection_str) -server.serve_forever() + c = selftest.mbed.serial_readline() # 'UDPCllient waiting for server IP and port...' + if c is None: + self.print_result(selftest.RESULT_IO_SERIAL) + return + selftest.notify(c.strip()) + return selftest.RESULT_PASSIVE + + def test(self, selftest): + # Returning none will suppress host test from printing success code + server = UDPServer((SERVER_IP, SERVER_PORT), UDPEchoClient_Handler) + print "HOST: Listening for UDP connections..." + self.send_server_ip_port(selftest, SERVER_IP, SERVER_PORT) + server.serve_forever() diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index f8b3ea9cd0..71e821a039 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -690,7 +690,7 @@ TESTS = [ "source_dir": join(TEST_DIR, "net", "echo", "tcp_client"), "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB], "automated": True, - "host_test": "tcpecho_client_auto", + #"host_test": "tcpecho_client_auto", "peripherals": ["ethernet"] }, { @@ -706,7 +706,7 @@ TESTS = [ "source_dir": join(TEST_DIR, "net", "echo", "udp_client"), "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB], "automated": True, - "host_test" : "udpecho_client_auto", + #"host_test" : "udpecho_client_auto", "peripherals": ["ethernet"], }, { @@ -754,7 +754,7 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB], "automated": True, "duration": 15, - "host_test": "tcpecho_client_auto", + #"host_test": "tcpecho_client_auto", "peripherals": ["ethernet"], }, { From 2a07aea5abe612a5195bc1553beb5f390f55a86e Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Fri, 30 Jan 2015 10:32:53 +0000 Subject: [PATCH 21/34] Autodetection: Added support for Unit Tests (CppUTest test runner) --- libraries/tests/utest/testrunner/testrunner.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/tests/utest/testrunner/testrunner.cpp b/libraries/tests/utest/testrunner/testrunner.cpp index 930d90f360..92154bed49 100644 --- a/libraries/tests/utest/testrunner/testrunner.cpp +++ b/libraries/tests/utest/testrunner/testrunner.cpp @@ -10,8 +10,12 @@ It is declared in \cpputest\src\Platforms\armcc\UtestPlatform.cpp */ Serial mbed_cpputest_console(STDIO_UART_TX, STDIO_UART_RX); -int main(int ac, char** av) -{ +int main(int ac, char** av) { + TEST_TIMEOUT(20); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(Unit test); + TEST_START("UT"); + unsigned failureCount = 0; { // Some compilers may not pass ac, av so we need to supply them ourselves @@ -20,6 +24,6 @@ int main(int ac, char** av) failureCount = CommandLineTestRunner::RunAllTests(ac, av); } - notify_completion(failureCount == 0); + TEST_RESULT(failureCount == 0); return failureCount; } From 34b55c81eb194f807c91035e0ab0a102bebc114f Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Fri, 30 Jan 2015 10:35:58 +0000 Subject: [PATCH 22/34] Simple indent inside Python module init --- workspace_tools/host_tests/__init__.py | 29 ++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/workspace_tools/host_tests/__init__.py b/workspace_tools/host_tests/__init__.py index 03c28e7e5c..cae0e20908 100644 --- a/workspace_tools/host_tests/__init__.py +++ b/workspace_tools/host_tests/__init__.py @@ -16,29 +16,32 @@ limitations under the License. """ from host_registry import HostRegistry -from default_auto import DefaultAuto -from hello_auto import HelloTest -from wait_us_auto import WaitusTest -from stdio_auto import StdioTest -from dev_null_auto import DevNullTest -from rtc_auto import RTCTest + +# Host test supervisors from echo import EchoTest +from rtc_auto import RTCTest +from stdio_auto import StdioTest +from hello_auto import HelloTest from detect_auto import DetectPlatformTest +from default_auto import DefaultAuto +from dev_null_auto import DevNullTest +from wait_us_auto import WaitusTest from tcpecho_server_auto import TCPEchoServerTest from udpecho_server_auto import UDPEchoServerTest from tcpecho_client_auto import TCPEchoClientTest from udpecho_client_auto import UDPEchoClientTest +# Populate registry with supervising objects HOSTREGISTRY = HostRegistry() -HOSTREGISTRY.register_host_test("default", DefaultAuto()) -HOSTREGISTRY.register_host_test("default_auto", DefaultAuto()) -HOSTREGISTRY.register_host_test("hello_auto", HelloTest()) -HOSTREGISTRY.register_host_test("wait_us_auto", WaitusTest()) -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("default", DefaultAuto()) +HOSTREGISTRY.register_host_test("rtc_auto", RTCTest()) +HOSTREGISTRY.register_host_test("hello_auto", HelloTest()) +HOSTREGISTRY.register_host_test("stdio_auto", StdioTest()) HOSTREGISTRY.register_host_test("detect_auto", DetectPlatformTest()) +HOSTREGISTRY.register_host_test("default_auto", DefaultAuto()) +HOSTREGISTRY.register_host_test("wait_us_auto", WaitusTest()) +HOSTREGISTRY.register_host_test("dev_null_auto", DevNullTest()) HOSTREGISTRY.register_host_test("tcpecho_server_auto", TCPEchoServerTest()) HOSTREGISTRY.register_host_test("udpecho_server_auto", UDPEchoServerTest()) HOSTREGISTRY.register_host_test("tcpecho_client_auto", TCPEchoClientTest()) From f40ec7a294ceb5d08c70fd6c8c4d5c10811ebafa Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Fri, 30 Jan 2015 13:51:41 +0000 Subject: [PATCH 23/34] Added autodetection fior tests including MMA8451Q accelerometer --- libraries/tests/mbed/i2c_MMA8451Q/main.cpp | 7 +++- workspace_tools/host_tests/host_test.py | 2 +- workspace_tools/tests.py | 44 ++++++++++++++++++---- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/libraries/tests/mbed/i2c_MMA8451Q/main.cpp b/libraries/tests/mbed/i2c_MMA8451Q/main.cpp index 5d7761e6b8..54abe0ac5e 100644 --- a/libraries/tests/mbed/i2c_MMA8451Q/main.cpp +++ b/libraries/tests/mbed/i2c_MMA8451Q/main.cpp @@ -29,6 +29,11 @@ float calc_3d_vector_len(float x, float y, float z) { #define MEASURE_DEVIATION_TOLERANCE 0.025 // 2.5% int main(void) { + TEST_TIMEOUT(15); + TEST_HOSTTEST(default_auto); + TEST_DESCRIPTION(MMA8451Q accelerometer); + TEST_START("KL25Z_5"); + DigitalOut led(LED_GREEN); MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS); bool result = true; @@ -47,5 +52,5 @@ int main(void) { wait(0.5); led = !led; } - notify_completion(result); + TEST_RESULT(result); } diff --git a/workspace_tools/host_tests/host_test.py b/workspace_tools/host_tests/host_test.py index 9eb62c5a8a..245b86ab32 100644 --- a/workspace_tools/host_tests/host_test.py +++ b/workspace_tools/host_tests/host_test.py @@ -360,7 +360,7 @@ class Test(HostTestResults): def print_result(self, result): """ Test result unified printing function """ - self.notify("\n{{%s}}\n{{end}}" % result) + self.notify("\r\n{{%s}}\r\n{{end}}" % result) class DefaultTestSelector(Test): diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index 71e821a039..6adb486978 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -584,7 +584,12 @@ TESTS = [ "duration": 15, "automated": True, #"host_test": "wait_us_auto", - "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "KL25Z", "KL05Z", "K64F", "KL46Z", "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_F401VC"], + "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", + "KL25Z", "KL05Z", "K64F", "KL46Z", + "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", + "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", + "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", + "DISCO_F401VC"], }, { "id": "RTOS_2", "description": "Mutex resource lock", @@ -592,7 +597,12 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB], "duration": 20, "automated": True, - "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "KL25Z", "KL05Z", "K64F", "KL46Z", "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_F401VC"], + "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", + "KL25Z", "KL05Z", "K64F", "KL46Z", + "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", + "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", + "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", + "DISCO_F401VC"], }, { "id": "RTOS_3", "description": "Semaphore resource lock", @@ -600,28 +610,48 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB], "duration": 20, "automated": True, - "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "KL25Z", "KL05Z", "K64F", "KL46Z", "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_F401VC"], + "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", + "KL25Z", "KL05Z", "K64F", "KL46Z", + "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", + "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", + "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", + "DISCO_F401VC"], }, { "id": "RTOS_4", "description": "Signals messaging", "source_dir": join(TEST_DIR, "rtos", "mbed", "signals"), "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB], "automated": True, - "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "KL25Z", "KL05Z", "K64F", "KL46Z", "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_F401VC"], + "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", + "KL25Z", "KL05Z", "K64F", "KL46Z", + "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", + "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", + "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", + "DISCO_F401VC"], }, { "id": "RTOS_5", "description": "Queue messaging", "source_dir": join(TEST_DIR, "rtos", "mbed", "queue"), "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB], "automated": True, - "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "KL25Z", "KL05Z", "K64F", "KL46Z", "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_F401VC"], + "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", + "KL25Z", "KL05Z", "K64F", "KL46Z", + "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", + "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", + "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", + "DISCO_F401VC"], }, { "id": "RTOS_6", "description": "Mail messaging", "source_dir": join(TEST_DIR, "rtos", "mbed", "mail"), "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB], "automated": True, - "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "KL25Z", "KL05Z", "K64F", "KL46Z", "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_F401VC"], + "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", + "KL25Z", "KL05Z", "K64F", "KL46Z", + "RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", + "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", + "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_F072RB", "NUCLEO_F091RC", + "DISCO_F401VC"], }, { "id": "RTOS_7", "description": "Timer", @@ -863,7 +893,7 @@ TESTS = [ { "id": "KL25Z_5", "description": "MMA8451Q accelerometer", "source_dir": join(TEST_DIR, "mbed", "i2c_MMA8451Q"), - "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB, join(PERIPHERALS, 'MMA8451Q')], + "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB, join(PERIPHERALS, 'MMA8451Q'), TEST_MBED_LIB], "mcu": ["KL25Z", "KL05Z", "KL46Z", "K20D50M"], "automated": True, "duration": 15, From 35c034c911b6080b627b47c582fb124fc2eb0b1f Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 10 Feb 2015 09:15:46 +0000 Subject: [PATCH 24/34] Added timeout detection from aut-detection MUT printout Timeout is captured by application supervising host_test and duration is modiffied Added functionality preventing MUT printouts to reset device's timeout value or script execution timer counter --- libraries/tests/mbed/hello/main.cpp | 2 +- workspace_tools/test_api.py | 60 ++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/libraries/tests/mbed/hello/main.cpp b/libraries/tests/mbed/hello/main.cpp index ca27438393..67f7139e65 100644 --- a/libraries/tests/mbed/hello/main.cpp +++ b/libraries/tests/mbed/hello/main.cpp @@ -2,7 +2,7 @@ int main() { - TEST_TIMEOUT(10); + TEST_TIMEOUT(5); TEST_HOSTTEST(hello_auto); TEST_DESCRIPTION(Hello World); TEST_START("MBED_10"); diff --git a/workspace_tools/test_api.py b/workspace_tools/test_api.py index 98eab246fc..374633d272 100644 --- a/workspace_tools/test_api.py +++ b/workspace_tools/test_api.py @@ -681,14 +681,15 @@ class SingleTestRunner(object): host_test_verbose = self.opts_verbose_test_result_only or self.opts_verbose host_test_reset = self.opts_mut_reset_type if reset_type is None else reset_type - single_test_result, single_test_output, single_testduration = self.run_host_test(test.host_test, - image_path, disk, port, duration, - micro=target_name, - verbose=host_test_verbose, - reset=host_test_reset, - reset_tout=reset_tout, - copy_method=selected_copy_method, - program_cycle_s=target_by_mcu.program_cycle_s()) + host_test_result = self.run_host_test(test.host_test, + image_path, disk, port, duration, + micro=target_name, + verbose=host_test_verbose, + reset=host_test_reset, + reset_tout=reset_tout, + copy_method=selected_copy_method, + program_cycle_s=target_by_mcu.program_cycle_s()) + single_test_result, single_test_output, single_testduration, single_timeout = host_test_result # Store test result test_all_result.append(single_test_result) @@ -703,12 +704,12 @@ class SingleTestRunner(object): 'test_id' : test_id, 'test_description' : test_description, 'elapsed_time' : round(elapsed_time, 2), - 'duration' : duration, + 'duration' : single_timeout, 'copy_method' : _copy_method, } print self.print_test_result(single_test_result, target_name, toolchain_name, - test_id, test_description, elapsed_time, duration) + test_id, test_description, elapsed_time, single_timeout) # Update database entries for ongoing test if self.db_logger and self.db_logger.is_connected(): @@ -721,7 +722,7 @@ class SingleTestRunner(object): single_test_result, single_test_output, elapsed_time, - duration, + single_timeout, test_index) # If we perform waterfall test we test until we get OK and we stop testing @@ -737,7 +738,7 @@ class SingleTestRunner(object): test_id, test_description, round(elapsed_time, 2), - duration, + single_timeout, self.shape_test_loop_ok_result_count(test_all_result)), detailed_test_results def print_test_result(self, test_result, target_name, toolchain_name, @@ -805,6 +806,17 @@ class SingleTestRunner(object): break return result + def get_auto_property_value(property_name, line): + """ Scans auto detection line from MUT and returns scanned parameter 'property_name' + Returns string + """ + result = None + if re.search("HOST: Property '%s'"% property_name, line) is not None: + property = re.search("HOST: Property '%s' = '([\w\d _]+)'"% property_name, line) + if property is not None and len(property.groups()) == 1: + result = property.groups()[0] + return result + # print "{%s} port:%s disk:%s" % (name, port, disk), cmd = ["python", '%s.py'% name, @@ -830,13 +842,12 @@ class SingleTestRunner(object): proc = Popen(cmd, stdout=PIPE, cwd=HOST_TESTS) obs = ProcessObserver(proc) - start_time = time() - start_time_update = False + update_once_flag = {} # Stores flags checking if some auto-parameter was already set line = '' output = [] - while (time() - start_time) < (2 * duration): + start_time = time() + while (time() - start_time) < (duration + 5): # Extra 5 seconds for flashing c = get_char_from_queue(obs) - if c: if verbose: sys.stdout.write(c) @@ -844,10 +855,21 @@ class SingleTestRunner(object): output.append(c) # Give the mbed under test a way to communicate the end of the test if c in ['\n', '\r']: - if not start_time_update and 'HOST: Reset target...' in line: + + # Checking for auto-detection information from the test about MUT reset moment + if 'reset_target' not in update_once_flag and "HOST: Reset target..." in line: # We will update this marker only once to prevent multiple time resets - start_time_update = True + update_once_flag['reset_target'] = True start_time = time() + + # Checking for auto-detection information from the test about timeout + auto_timeout_val = get_auto_property_value('timeout', line) + if 'timeout' not in update_once_flag and auto_timeout_val is not None: + # We will update this marker only once to prevent multiple time resets + update_once_flag['timeout'] = True + duration = int(auto_timeout_val) + + # Check for test end if '{end}' in line: break line = '' @@ -870,7 +892,7 @@ class SingleTestRunner(object): obs.stop() result = get_test_result(output) - return result, "".join(output), testcase_duration + return (result, "".join(output), testcase_duration, duration) def is_peripherals_available(self, target_mcu_name, peripherals=None): """ Checks if specified target should run specific peripheral test case From f38a53ba21a6c3df58e27562d220413937369ed8 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 10 Feb 2015 21:18:17 +0000 Subject: [PATCH 25/34] Added new switch --auto to force autodetection with mbed_lstools Added switch --tc to force certain toolchains. Switch --auto and -tc works well with switch --config so do not hesitate to check your configuration before running your test suite. --- workspace_tools/singletest.py | 55 +++++++++++++++++------ workspace_tools/test_api.py | 84 ++++++++++++++++++++++++++++++++++- 2 files changed, 124 insertions(+), 15 deletions(-) diff --git a/workspace_tools/singletest.py b/workspace_tools/singletest.py index bd13edcf78..caa0e1a811 100644 --- a/workspace_tools/singletest.py +++ b/workspace_tools/singletest.py @@ -71,7 +71,15 @@ from workspace_tools.test_api import get_avail_tests_summary_table from workspace_tools.test_api import get_default_test_options_parser from workspace_tools.test_api import print_muts_configuration_from_json from workspace_tools.test_api import print_test_configuration_from_json +from workspace_tools.test_api import get_autodetected_MUTS +from workspace_tools.test_api import get_autodetected_TEST_SPEC +from workspace_tools.test_api import get_module_avail +# Importing extra modules which can be not installed but if available they can extend test suite functionality +try: + import mbed_lstools +except: + pass def get_version(): """ Returns test script version @@ -126,22 +134,41 @@ if __name__ == '__main__': print mcu_toolchain_matrix(platform_filter=opts.general_filter_regex) exit(0) - # Open file with test specification - # test_spec_filename tells script which targets and their toolchain(s) - # should be covered by the test scenario - test_spec = get_json_data_from_file(opts.test_spec_filename) if opts.test_spec_filename else None - if test_spec is None: - if not opts.test_spec_filename: - parser.print_help() - exit(-1) + test_spec = None + MUTs = None - # Get extra MUTs if applicable - MUTs = get_json_data_from_file(opts.muts_spec_filename) if opts.muts_spec_filename else None + if opts.auto_detect: + print "Detecting connected mbed-enabled devices.." - if MUTs is None: - if not opts.muts_spec_filename: - parser.print_help() - exit(-1) + if get_module_avail('mbed_lstools'): + mbeds = mbed_lstools.create() + muts_list = mbeds.list_mbeds() + + use_default_toolchain = 'default' in opts.toolchains_filter.split(',') if opts.toolchains_filter is not None else True + use_supported_toolchains = 'all' in opts.toolchains_filter.split(',') if opts.toolchains_filter is not None else True + toolchain_filter = opts.toolchains_filter + test_spec = get_autodetected_TEST_SPEC(muts_list, + use_default_toolchain=use_default_toolchain, + use_supported_toolchains=use_supported_toolchains, + toolchain_filter=toolchain_filter) + MUTs = get_autodetected_MUTS(muts_list) + else: + # Open file with test specification + # test_spec_filename tells script which targets and their toolchain(s) + # should be covered by the test scenario + test_spec = get_json_data_from_file(opts.test_spec_filename) if opts.test_spec_filename else None + if test_spec is None: + if not opts.test_spec_filename: + parser.print_help() + exit(-1) + + # Get extra MUTs if applicable + MUTs = get_json_data_from_file(opts.muts_spec_filename) if opts.muts_spec_filename else None + + if MUTs is None: + if not opts.muts_spec_filename: + parser.print_help() + exit(-1) if opts.verbose_test_configuration_only: print "MUTs configuration in %s:"% opts.muts_spec_filename diff --git a/workspace_tools/test_api.py b/workspace_tools/test_api.py index 374633d272..53a856713d 100644 --- a/workspace_tools/test_api.py +++ b/workspace_tools/test_api.py @@ -54,6 +54,11 @@ from workspace_tools.test_exporters import ReportExporter, ResultExporterType import workspace_tools.host_tests.host_tests_plugins as host_tests_plugins +try: + import mbed_lstools +except: + pass + class ProcessObserver(Thread): def __init__(self, proc): @@ -1374,8 +1379,72 @@ def detect_database_verbose(db_url): print "Parse error: '%s' - DB Url error"% (db_url) +def get_module_avail(module_name): + """ This function returns True if module_name is already impored module + """ + return module_name in sys.modules.keys() + + +def get_autodetected_MUTS(mbeds_list): + """ Function detects all connected to host mbed-enabled devices and generates artificial MUTS file. + If function fails to auto-detect devices it will return empty dictionary. + + if get_module_avail('mbed_lstools'): + mbeds = mbed_lstools.create() + mbeds_list = mbeds.list_mbeds() + """ + result = {} # Should be in muts_all.json format + # Align mbeds_list from mbed_lstools to MUT file format (JSON dictionary with muts) + # mbeds_list = [{'platform_name': 'NUCLEO_F302R8', 'mount_point': 'E:', 'target_id': '07050200623B61125D5EF72A', 'serial_port': u'COM34'}] + index = 1 + for mut in mbeds_list: + m = {'mcu' : mut['platform_name'], + 'port' : mut['serial_port'], + 'disk' : mut['mount_point'], + 'peripherals' : [] # No peripheral detection + } + if index not in result: + result[index] = {} + result[index] = m + index += 1 + return result + + +def get_autodetected_TEST_SPEC(mbeds_list, use_default_toolchain=True, use_supported_toolchains=False, toolchain_filter=None): + """ Function detects all connected to host mbed-enabled devices and generates artificial test_spec file. + If function fails to auto-detect devices it will return empty 'targets' test_spec description. + + use_default_toolchain - if True add default toolchain to test_spec + use_supported_toolchains - if True add all supported toolchains to test_spec + toolchain_filter - if [...list of toolchains...] add from all toolchains only those in filter to test_spec + """ + result = {'targets': {} + } + + for mut in mbeds_list: + mcu = mut['platform_name'] + if mcu in TARGET_MAP: + default_toolchain = TARGET_MAP[mcu].default_toolchain + supported_toolchains = TARGET_MAP[mcu].supported_toolchains + + toolchains = [] + if use_default_toolchain: + toolchains.append(default_toolchain) + if use_supported_toolchains: + toolchains += supported_toolchains + + if toolchain_filter is not None: + all_toolchains = supported_toolchains + [default_toolchain] + for toolchain in toolchain_filter: + if toolchain in all_toolchains: + toolchains.append(toolchain) + + result['targets'][mcu] = list(set(toolchains)) + return result + + def get_default_test_options_parser(): - """ Get common test script options used by CLI, webservices etc. + """ Get common test script options used by CLI, web services etc. """ parser = optparse.OptionParser() parser.add_option('-i', '--tests', @@ -1394,6 +1463,19 @@ def get_default_test_options_parser(): type="int", help="Define number of compilation jobs. Default value is 1") + if get_module_avail('mbed_lstools'): + # Additional features available when mbed_lstools is installed on host and imported + # mbed_lstools allow users to detect connected to host mbed-enabled devices + parser.add_option('', '--auto', + dest='auto_detect', + metavar=False, + action="store_true", + help='Use mbed-ls module to detect all connected mbed devices') + + parser.add_option('', '--tc', + dest='toolchains_filter', + help="Toolchain filter for --auto option. Use toolcahins names separated by comma, 'default' or 'all' to select toolchains") + parser.add_option('', '--clean', dest='clean', metavar=False, From 8910d95ae6ce40f65cd0463287f4361797e9488e Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 10 Feb 2015 21:29:11 +0000 Subject: [PATCH 26/34] Fixed bug in --tc switch --- workspace_tools/test_api.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/workspace_tools/test_api.py b/workspace_tools/test_api.py index 53a856713d..98905239a5 100644 --- a/workspace_tools/test_api.py +++ b/workspace_tools/test_api.py @@ -1418,8 +1418,7 @@ def get_autodetected_TEST_SPEC(mbeds_list, use_default_toolchain=True, use_suppo use_supported_toolchains - if True add all supported toolchains to test_spec toolchain_filter - if [...list of toolchains...] add from all toolchains only those in filter to test_spec """ - result = {'targets': {} - } + result = {'targets': {} } for mut in mbeds_list: mcu = mut['platform_name'] @@ -1427,15 +1426,15 @@ def get_autodetected_TEST_SPEC(mbeds_list, use_default_toolchain=True, use_suppo default_toolchain = TARGET_MAP[mcu].default_toolchain supported_toolchains = TARGET_MAP[mcu].supported_toolchains + # Decide which toolchains should be added to test specification toolchain pool for each target toolchains = [] if use_default_toolchain: toolchains.append(default_toolchain) if use_supported_toolchains: toolchains += supported_toolchains - if toolchain_filter is not None: all_toolchains = supported_toolchains + [default_toolchain] - for toolchain in toolchain_filter: + for toolchain in toolchain_filter.split(','): if toolchain in all_toolchains: toolchains.append(toolchain) From 2882c4e961b0d1a565fe4777dd139541c251c2fa Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 10 Feb 2015 21:50:56 +0000 Subject: [PATCH 27/34] Fixed bug in --config and --auto switches --- workspace_tools/singletest.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/workspace_tools/singletest.py b/workspace_tools/singletest.py index caa0e1a811..0f44337c89 100644 --- a/workspace_tools/singletest.py +++ b/workspace_tools/singletest.py @@ -138,19 +138,26 @@ if __name__ == '__main__': MUTs = None if opts.auto_detect: - print "Detecting connected mbed-enabled devices.." + print "MBEDLS: Detecting connected mbed-enabled devices... " if get_module_avail('mbed_lstools'): mbeds = mbed_lstools.create() muts_list = mbeds.list_mbeds() + for mut in muts_list: + print "MBEDLS: Detected %s, port: %s, mounted: %s"% (mut['platform_name'], + mut['serial_port'], + mut['mount_point']) + # Set up parameters for test specification filter function (we need to set toolchains per target here) use_default_toolchain = 'default' in opts.toolchains_filter.split(',') if opts.toolchains_filter is not None else True - use_supported_toolchains = 'all' in opts.toolchains_filter.split(',') if opts.toolchains_filter is not None else True + use_supported_toolchains = 'all' in opts.toolchains_filter.split(',') if opts.toolchains_filter is not None else False toolchain_filter = opts.toolchains_filter + # Test specification with information about each target and associated toolchain test_spec = get_autodetected_TEST_SPEC(muts_list, use_default_toolchain=use_default_toolchain, use_supported_toolchains=use_supported_toolchains, toolchain_filter=toolchain_filter) + # MUTs configuration auto-detection MUTs = get_autodetected_MUTS(muts_list) else: # Open file with test specification @@ -171,11 +178,11 @@ if __name__ == '__main__': exit(-1) if opts.verbose_test_configuration_only: - print "MUTs configuration in %s:"% opts.muts_spec_filename + print "MUTs configuration in %s:"% ('auto-detected' if opts.auto_detect else opts.muts_spec_filename) if MUTs: print print_muts_configuration_from_json(MUTs, platform_filter=opts.general_filter_regex) print - print "Test specification in %s:"% opts.test_spec_filename + print "Test specification in %s:"% ('auto-detected' if opts.auto_detect else opts.test_spec_filename) if test_spec: print print_test_configuration_from_json(test_spec) exit(0) From 7ca2cab34689003672203b72fcca52a3f8da1ab5 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 10 Feb 2015 22:19:17 +0000 Subject: [PATCH 28/34] Removed extra dependency to TEST_LIB - GCC_ARM linking bug fix --- workspace_tools/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index 6adb486978..cc68f89b31 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -893,7 +893,7 @@ TESTS = [ { "id": "KL25Z_5", "description": "MMA8451Q accelerometer", "source_dir": join(TEST_DIR, "mbed", "i2c_MMA8451Q"), - "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB, join(PERIPHERALS, 'MMA8451Q'), TEST_MBED_LIB], + "dependencies": [MBED_LIBRARIES, TEST_MBED_LIB, join(PERIPHERALS, 'MMA8451Q')], "mcu": ["KL25Z", "KL05Z", "KL46Z", "K20D50M"], "automated": True, "duration": 15, From cff6bc44ea4e2ef830a098a209746f3f789e498f Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 10 Feb 2015 22:41:39 +0000 Subject: [PATCH 29/34] Added coloram module import Minor code indents --- setup.py | 8 ++++---- workspace_tools/build_api.py | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index f1636aee21..adbee4d9cf 100644 --- a/setup.py +++ b/setup.py @@ -3,11 +3,11 @@ This module defines the attributes of the PyPI package for the Mbed SDK """ -from distutils.core import setup -from setuptools import find_packages +from shutil import copyfileobj from os.path import isfile, join from tempfile import TemporaryFile -from shutil import copyfileobj +from setuptools import find_packages +from distutils.core import setup LICENSE = open('LICENSE').read() DESCRIPTION = """A set of Python scripts that can be used to compile programs written on top of the `mbed framework`_. It can also be used to export mbed projects to other build systems and IDEs (uVision, IAR, makefiles). @@ -40,7 +40,7 @@ setup(name='mbed-tools', url='https://github.com/mbedmicro/mbed', packages=find_packages(), license=LICENSE, - install_requires=["PrettyTable>=0.7.2", "PySerial>=2.7", "IntelHex>=1.3"]) + install_requires=["PrettyTable>=0.7.2", "PySerial>=2.7", "IntelHex>=1.3", "colorama>=0.3.3"]) # Restore previous private_settings if needed if backup: diff --git a/workspace_tools/build_api.py b/workspace_tools/build_api.py index 2bfaff0d81..39f5c24d22 100644 --- a/workspace_tools/build_api.py +++ b/workspace_tools/build_api.py @@ -17,6 +17,8 @@ limitations under the License. import re import tempfile +import colorama + from types import ListType from shutil import rmtree From f2f0f51d163b75926bd16d658a230247ccafeb8a Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 10 Feb 2015 23:38:01 +0000 Subject: [PATCH 30/34] Added colorama to toolchain notification function and basic test suite prompts --- workspace_tools/test_api.py | 10 +++++++--- workspace_tools/toolchains/__init__.py | 22 +++++++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/workspace_tools/test_api.py b/workspace_tools/test_api.py index 98905239a5..e88c729e02 100644 --- a/workspace_tools/test_api.py +++ b/workspace_tools/test_api.py @@ -28,6 +28,7 @@ import optparse import datetime import threading from types import ListType +from colorama import Fore, Back, Style from prettytable import PrettyTable from time import sleep, time @@ -172,6 +173,9 @@ class SingleTestRunner(object): _opts_extend_test_timeout=None): """ Let's try hard to init this object """ + from colorama import init + init() + PATTERN = "\\{(" + "|".join(self.TEST_RESULT_MAPPING.keys()) + ")\\}" self.RE_DETECT_TESTCASE_RESULT = re.compile(PATTERN) # Settings related to test loops counters @@ -759,7 +763,7 @@ class SingleTestRunner(object): separator = "::" time_info = " in %.2f of %d sec" % (round(elapsed_time, 2), duration) result = separator.join(tokens) + " [" + test_result +"]" + time_info - return result + return Fore.MAGENTA + result + Fore.RESET def shape_test_loop_ok_result_count(self, test_all_result): """ Reformats list of results to simple string @@ -842,7 +846,7 @@ class SingleTestRunner(object): cmd += ["-R", str(reset_tout)] if verbose: - print "Executing '" + " ".join(cmd) + "'" + print Fore.MAGENTA + "Executing '" + " ".join(cmd) + "'" + Fore.RESET print "Test::Output::Start" proc = Popen(cmd, stdout=PIPE, cwd=HOST_TESTS) @@ -851,7 +855,7 @@ class SingleTestRunner(object): line = '' output = [] start_time = time() - while (time() - start_time) < (duration + 5): # Extra 5 seconds for flashing + while (time() - start_time) < (duration): c = get_char_from_queue(obs) if c: if verbose: diff --git a/workspace_tools/toolchains/__init__.py b/workspace_tools/toolchains/__init__.py index dd1a02a72d..b42b2f5317 100644 --- a/workspace_tools/toolchains/__init__.py +++ b/workspace_tools/toolchains/__init__.py @@ -17,6 +17,7 @@ limitations under the License. import re import sys +import colorama from os import stat, walk from copy import copy from time import time, sleep @@ -49,6 +50,23 @@ def print_notify(event, silent=False): if not silent: print '%s: %s' % (event['action'].title(), basename(event['file'])) +def print_notify_color(event, silent=False): + """ Default command line notification with colors + """ + from colorama import Fore, Back, Style + + if event['type'] in ['info', 'debug']: + print Fore.GREEN + event['message'] + Fore.RESET + + elif event['type'] == 'cc': + event['severity'] = event['severity'].title() + event['file'] = basename(event['file']) + print Fore.YELLOW + '[%(severity)s] %(file)s@%(line)s: %(message)s'% event + Fore.RESET + + elif event['type'] == 'progress': + if not silent: + print '%s: %s' % (event['action'].title(), basename(event['file'])) + def print_notify_verbose(event, silent=False): """ Default command line notification with more verbose mode """ @@ -215,7 +233,7 @@ class mbedToolchain: self.legacy_ignore_dirs = LEGACY_IGNORE_DIRS - set([target.name, LEGACY_TOOLCHAIN_NAMES[self.name]]) - self.notify_fun = notify if notify is not None else print_notify + self.notify_fun = notify if notify is not None else print_notify_color self.options = options if options is not None else [] self.macros = macros or [] @@ -704,6 +722,8 @@ class mbedToolchain: def var(self, key, value): self.notify({'type': 'var', 'key': key, 'val': value}) +from colorama import init +init() from workspace_tools.settings import ARM_BIN from workspace_tools.settings import GCC_ARM_PATH, GCC_CR_PATH, GCC_CS_PATH, CW_EWL_PATH, CW_GCC_PATH From cc57394f52413aef037379695923e7c4016e0be9 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 11 Feb 2015 00:36:18 +0000 Subject: [PATCH 31/34] Added to .travis.yml colorama and prettytable python packages --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 37ad3c41e5..351f6e0cd3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,6 @@ install: "sudo $TRAVIS_BUILD_DIR/travis/install_dependencies.sh > /dev/null" python: - "2.7" script: "python workspace_tools/build_travis.py" +install: + - pip install colorama + - pip install prettytable \ No newline at end of file From 94ad3f33550447fe6daaa26aea0aa411cf85f15c Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 11 Feb 2015 00:41:11 +0000 Subject: [PATCH 32/34] Added to .travis.yml colorama and prettytable python packages --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 351f6e0cd3..442c63acd2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,5 +4,5 @@ python: - "2.7" script: "python workspace_tools/build_travis.py" install: - - pip install colorama - - pip install prettytable \ No newline at end of file + - sudo pip install colorama + - sudo pip install prettytable \ No newline at end of file From 6ecf8da1c6bfb1f10cac2e5f72b1c733aa92d8a7 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 11 Feb 2015 00:48:13 +0000 Subject: [PATCH 33/34] Added to .travis.yml colorama and prettytable python packages --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 442c63acd2..4f4d70d811 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ --- -install: "sudo $TRAVIS_BUILD_DIR/travis/install_dependencies.sh > /dev/null" python: - "2.7" script: "python workspace_tools/build_travis.py" install: + - "sudo $TRAVIS_BUILD_DIR/travis/install_dependencies.sh > /dev/null" - sudo pip install colorama - sudo pip install prettytable \ No newline at end of file From 09c48e4081b2c1ef7ac2cc27e067ae1cfc7b5f7e Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 11 Feb 2015 10:37:03 +0000 Subject: [PATCH 34/34] Refactored names for MBED_HOSTTEST macros used in test case auto-detection --- libraries/tests/mbed/basic/main.cpp | 10 +++++----- .../tests/mbed/call_before_main/main.cpp | 10 +++++----- libraries/tests/mbed/cpp/main.cpp | 10 +++++----- libraries/tests/mbed/detect/main.cpp | 10 +++++----- libraries/tests/mbed/dev_null/main.cpp | 10 +++++----- .../tests/mbed/digitalin_digitalout/main.cpp | 14 ++++++------- libraries/tests/mbed/digitalinout/main.cpp | 10 +++++----- libraries/tests/mbed/div/main.cpp | 10 +++++----- libraries/tests/mbed/echo/main.cpp | 8 ++++---- libraries/tests/mbed/env/test_env.h | 20 +++++++++---------- libraries/tests/mbed/file/main.cpp | 10 +++++----- libraries/tests/mbed/hello/main.cpp | 8 ++++---- libraries/tests/mbed/i2c_MMA8451Q/main.cpp | 10 +++++----- libraries/tests/mbed/i2c_TMP102/main.cpp | 10 +++++----- libraries/tests/mbed/i2c_eeprom/main.cpp | 10 +++++----- libraries/tests/mbed/i2c_eeprom_line/main.cpp | 10 +++++----- libraries/tests/mbed/interruptin/main.cpp | 18 ++++++++--------- libraries/tests/mbed/portinout/main.cpp | 10 +++++----- libraries/tests/mbed/portout_portin/main.cpp | 8 ++++---- libraries/tests/mbed/rtc/main.cpp | 8 ++++---- libraries/tests/mbed/sd/main.cpp | 10 +++++----- libraries/tests/mbed/sd_perf_fatfs/main.cpp | 10 +++++----- libraries/tests/mbed/sd_perf_fhandle/main.cpp | 10 +++++----- libraries/tests/mbed/sd_perf_stdio/main.cpp | 10 +++++----- libraries/tests/mbed/semihost/main.cpp | 10 +++++----- libraries/tests/mbed/stdio/main.cpp | 8 ++++---- libraries/tests/mbed/ticker/main.cpp | 8 ++++---- libraries/tests/mbed/ticker_2/main.cpp | 8 ++++---- libraries/tests/mbed/ticker_3/main.cpp | 8 ++++---- libraries/tests/mbed/time_us/main.cpp | 8 ++++---- libraries/tests/mbed/timeout/main.cpp | 8 ++++---- libraries/tests/mbed/vtor_reloc/main.cpp | 14 ++++++------- libraries/tests/net/echo/tcp_client/main.cpp | 8 ++++---- .../tests/net/echo/tcp_client_loop/main.cpp | 10 +++++----- libraries/tests/net/echo/tcp_server/main.cpp | 8 ++++---- libraries/tests/net/echo/udp_client/main.cpp | 10 +++++----- libraries/tests/net/echo/udp_server/main.cpp | 8 ++++---- .../tests/net/helloworld/tcpclient/main.cpp | 10 +++++----- .../tests/net/helloworld/udpclient/main.cpp | 10 +++++----- .../protocols/HTTPClient_HelloWorld/main.cpp | 14 ++++++------- .../protocols/NTPClient_HelloWorld/main.cpp | 12 +++++------ libraries/tests/rtos/mbed/basic/main.cpp | 8 ++++---- libraries/tests/rtos/mbed/file/main.cpp | 16 +++++++-------- libraries/tests/rtos/mbed/isr/main.cpp | 10 +++++----- libraries/tests/rtos/mbed/mail/main.cpp | 10 +++++----- libraries/tests/rtos/mbed/mutex/main.cpp | 10 +++++----- libraries/tests/rtos/mbed/queue/main.cpp | 10 +++++----- libraries/tests/rtos/mbed/semaphore/main.cpp | 10 +++++----- libraries/tests/rtos/mbed/signals/main.cpp | 10 +++++----- libraries/tests/rtos/mbed/timer/main.cpp | 8 ++++---- .../tests/utest/testrunner/testrunner.cpp | 10 +++++----- 51 files changed, 259 insertions(+), 259 deletions(-) diff --git a/libraries/tests/mbed/basic/main.cpp b/libraries/tests/mbed/basic/main.cpp index d7e45b682a..c4a50988bf 100644 --- a/libraries/tests/mbed/basic/main.cpp +++ b/libraries/tests/mbed/basic/main.cpp @@ -1,9 +1,9 @@ #include "test_env.h" int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(Basic); - TEST_START("MBED_A1"); - TEST_RESULT(true); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(Basic); + MBED_HOSTTEST_START("MBED_A1"); + MBED_HOSTTEST_RESULT(true); } diff --git a/libraries/tests/mbed/call_before_main/main.cpp b/libraries/tests/mbed/call_before_main/main.cpp index 9ab5de4bf3..7b3bac203f 100644 --- a/libraries/tests/mbed/call_before_main/main.cpp +++ b/libraries/tests/mbed/call_before_main/main.cpp @@ -10,12 +10,12 @@ extern "C" void mbed_main() { } int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(Call function mbed_main before main); - TEST_START("MBED_A21"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(Call function mbed_main before main); + MBED_HOSTTEST_START("MBED_A21"); printf("MBED: main() starts now!\r\n"); - TEST_RESULT(mbed_main_called); + MBED_HOSTTEST_RESULT(mbed_main_called); } diff --git a/libraries/tests/mbed/cpp/main.cpp b/libraries/tests/mbed/cpp/main.cpp index b565cf0006..48254315a6 100644 --- a/libraries/tests/mbed/cpp/main.cpp +++ b/libraries/tests/mbed/cpp/main.cpp @@ -54,10 +54,10 @@ Heap::hello Heap::destroy *******************/ int main (void) { - TEST_TIMEOUT(10); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(C++); - TEST_START("MBED_12"); + MBED_HOSTTEST_TIMEOUT(10); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(C++); + MBED_HOSTTEST_START("MBED_12"); bool result = true; for (;;) @@ -82,5 +82,5 @@ int main (void) { break; } - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } diff --git a/libraries/tests/mbed/detect/main.cpp b/libraries/tests/mbed/detect/main.cpp index d7ad0c26dd..1508a13cbf 100644 --- a/libraries/tests/mbed/detect/main.cpp +++ b/libraries/tests/mbed/detect/main.cpp @@ -2,14 +2,14 @@ #include "test_env.h" int main() { - TEST_TIMEOUT(10); - TEST_HOSTTEST(detect_auto); - TEST_DESCRIPTION(Simple detect test); - TEST_START("DTCT_1"); + MBED_HOSTTEST_TIMEOUT(10); + MBED_HOSTTEST_SELECT(detect_auto); + MBED_HOSTTEST_DESCRIPTION(Simple detect test); + MBED_HOSTTEST_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); - TEST_RESULT(true); + MBED_HOSTTEST_RESULT(true); } diff --git a/libraries/tests/mbed/dev_null/main.cpp b/libraries/tests/mbed/dev_null/main.cpp index 94c6630e62..adde6b8d22 100644 --- a/libraries/tests/mbed/dev_null/main.cpp +++ b/libraries/tests/mbed/dev_null/main.cpp @@ -17,14 +17,14 @@ protected: DevNull null("null"); int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(dev_null_auto); - TEST_DESCRIPTION(stdout redirected to dev null); - TEST_START("EXAMPLE_1"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(dev_null_auto); + MBED_HOSTTEST_DESCRIPTION(stdout redirected to dev null); + MBED_HOSTTEST_START("EXAMPLE_1"); printf("MBED: re-routing stdout to /null\r\n"); freopen("/null", "w", stdout); printf("MBED: printf redirected to /null\r\n"); // This shouldn't appear // If failure message can be seen test should fail :) - TEST_RESULT(false); // This is 'false' on purpose + MBED_HOSTTEST_RESULT(false); // This is 'false' on purpose } diff --git a/libraries/tests/mbed/digitalin_digitalout/main.cpp b/libraries/tests/mbed/digitalin_digitalout/main.cpp index dd952faccc..ceb2ae4983 100644 --- a/libraries/tests/mbed/digitalin_digitalout/main.cpp +++ b/libraries/tests/mbed/digitalin_digitalout/main.cpp @@ -42,23 +42,23 @@ DigitalIn in(p25); #endif int main() { - TEST_TIMEOUT(10); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(DigitalIn DigitalOut); - TEST_START("MBED_A5"); + MBED_HOSTTEST_TIMEOUT(10); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(DigitalIn DigitalOut); + MBED_HOSTTEST_START("MBED_A5"); out = 0; wait(0.1); if (in != 0) { printf("ERROR: in != 0\n"); - TEST_RESULT(false); + MBED_HOSTTEST_RESULT(false); } out = 1; wait(0.1); if (in != 1) { printf("ERROR: in != 1\n"); - TEST_RESULT(false); + MBED_HOSTTEST_RESULT(false); } - TEST_RESULT(true); + MBED_HOSTTEST_RESULT(true); } diff --git a/libraries/tests/mbed/digitalinout/main.cpp b/libraries/tests/mbed/digitalinout/main.cpp index 2c762b6570..0e6ec9efe3 100644 --- a/libraries/tests/mbed/digitalinout/main.cpp +++ b/libraries/tests/mbed/digitalinout/main.cpp @@ -44,10 +44,10 @@ DigitalInOut d2(p25); int main() { - TEST_TIMEOUT(10); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(DigitalInOut); - TEST_START("MBED_A6"); + MBED_HOSTTEST_TIMEOUT(10); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(DigitalInOut); + MBED_HOSTTEST_START("MBED_A6"); bool check = true; @@ -81,5 +81,5 @@ int main() check = false; } - TEST_RESULT(check); + MBED_HOSTTEST_RESULT(check); } diff --git a/libraries/tests/mbed/div/main.cpp b/libraries/tests/mbed/div/main.cpp index fbaa46569a..951e5ab8c5 100644 --- a/libraries/tests/mbed/div/main.cpp +++ b/libraries/tests/mbed/div/main.cpp @@ -17,10 +17,10 @@ const char *result_str(bool result) { } int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(Integer constant division); - TEST_START("MBED_26"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(Integer constant division); + MBED_HOSTTEST_START("MBED_26"); bool result = true; @@ -40,5 +40,5 @@ int main() { printf("64bit: 0x17FFFFFFE8: expected 0x%lX got 0x%lX ... %s\r\n", values.first, test_ret, result_str(test_res)); } - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } diff --git a/libraries/tests/mbed/echo/main.cpp b/libraries/tests/mbed/echo/main.cpp index bbe175b38f..ccd882560c 100644 --- a/libraries/tests/mbed/echo/main.cpp +++ b/libraries/tests/mbed/echo/main.cpp @@ -11,10 +11,10 @@ namespace { } int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(echo); - TEST_DESCRIPTION(Serial Echo at 115200); - TEST_START("MBED_A9"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(echo); + MBED_HOSTTEST_DESCRIPTION(Serial Echo at 115200); + MBED_HOSTTEST_START("MBED_A9"); Serial pc(TXPIN, RXPIN); pc.baud(115200); diff --git a/libraries/tests/mbed/env/test_env.h b/libraries/tests/mbed/env/test_env.h index 4aadae15c9..bfb2c44d2d 100644 --- a/libraries/tests/mbed/env/test_env.h +++ b/libraries/tests/mbed/env/test_env.h @@ -29,25 +29,25 @@ void notify_test_id(const char *test_id); void notify_test_description(const char *description); // Host test auto-detection API -#define TEST_START(TESTID) notify_test_id(TESTID); notify_start() -#define TEST_HOSTTEST(NAME) notify_host_test_name(#NAME) -#define TEST_TIMEOUT(SECONDS) notify_timeout(SECONDS) -#define TEST_DESCRIPTION(DESC) notify_test_description(#DESC) -#define TEST_RESULT(RESULT) notify_completion(RESULT) +#define MBED_HOSTTEST_START(TESTID) notify_test_id(TESTID); notify_start() +#define MBED_HOSTTEST_SELECT(NAME) notify_host_test_name(#NAME) +#define MBED_HOSTTEST_TIMEOUT(SECONDS) notify_timeout(SECONDS) +#define MBED_HOSTTEST_DESCRIPTION(DESC) notify_test_description(#DESC) +#define MBED_HOSTTEST_RESULT(RESULT) notify_completion(RESULT) /** Test auto-detection preamble example: main() { - TEST_TIMEOUT(10); - TEST_HOSTTEST( host_test ); - TEST_DESCRIPTION(Hello World); - TEST_START("MBED_10"); + MBED_HOSTTEST_TIMEOUT(10); + MBED_HOSTTEST_SELECT( host_test ); + MBED_HOSTTEST_DESCRIPTION(Hello World); + MBED_HOSTTEST_START("MBED_10"); // Proper 'host_test.py' should take over supervising of this test // Test code bool result = ...; - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } */ diff --git a/libraries/tests/mbed/file/main.cpp b/libraries/tests/mbed/file/main.cpp index dbe7bbfb47..8f573f4e30 100644 --- a/libraries/tests/mbed/file/main.cpp +++ b/libraries/tests/mbed/file/main.cpp @@ -43,10 +43,10 @@ void test_close(FILE *f) { } int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(Semihost file system); - TEST_START("MBED_A2"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(Semihost file system); + MBED_HOSTTEST_START("MBED_A2"); pc.printf("Test the Stream class\n"); @@ -74,5 +74,5 @@ int main() { test_close(f); // Check the two strings are equal - TEST_RESULT((strncmp(buffer, str, str_len) == 0)); + MBED_HOSTTEST_RESULT((strncmp(buffer, str, str_len) == 0)); } diff --git a/libraries/tests/mbed/hello/main.cpp b/libraries/tests/mbed/hello/main.cpp index 67f7139e65..9e1e195e9a 100644 --- a/libraries/tests/mbed/hello/main.cpp +++ b/libraries/tests/mbed/hello/main.cpp @@ -2,10 +2,10 @@ int main() { - TEST_TIMEOUT(5); - TEST_HOSTTEST(hello_auto); - TEST_DESCRIPTION(Hello World); - TEST_START("MBED_10"); + MBED_HOSTTEST_TIMEOUT(5); + MBED_HOSTTEST_SELECT(hello_auto); + MBED_HOSTTEST_DESCRIPTION(Hello World); + MBED_HOSTTEST_START("MBED_10"); printf("Hello World\r\n"); diff --git a/libraries/tests/mbed/i2c_MMA8451Q/main.cpp b/libraries/tests/mbed/i2c_MMA8451Q/main.cpp index 54abe0ac5e..2e17aea5a4 100644 --- a/libraries/tests/mbed/i2c_MMA8451Q/main.cpp +++ b/libraries/tests/mbed/i2c_MMA8451Q/main.cpp @@ -29,10 +29,10 @@ float calc_3d_vector_len(float x, float y, float z) { #define MEASURE_DEVIATION_TOLERANCE 0.025 // 2.5% int main(void) { - TEST_TIMEOUT(15); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(MMA8451Q accelerometer); - TEST_START("KL25Z_5"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(MMA8451Q accelerometer); + MBED_HOSTTEST_START("KL25Z_5"); DigitalOut led(LED_GREEN); MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS); @@ -52,5 +52,5 @@ int main(void) { wait(0.5); led = !led; } - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } diff --git a/libraries/tests/mbed/i2c_TMP102/main.cpp b/libraries/tests/mbed/i2c_TMP102/main.cpp index e76427b601..067dfb7473 100644 --- a/libraries/tests/mbed/i2c_TMP102/main.cpp +++ b/libraries/tests/mbed/i2c_TMP102/main.cpp @@ -33,10 +33,10 @@ TMP102 temperature(p28, p27, 0x90); #endif int main() { - TEST_TIMEOUT(10); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(DigitalIn DigitalOut); - TEST_START("MBED_A4"); + MBED_HOSTTEST_TIMEOUT(10); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(DigitalIn DigitalOut); + MBED_HOSTTEST_START("MBED_A4"); float t = temperature.read(); @@ -44,5 +44,5 @@ int main() { // In our test environment (ARM office) we should get a temperature within // the range ]15, 30[C bool result = (t > 15.0) && (t < 30.0); - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } diff --git a/libraries/tests/mbed/i2c_eeprom/main.cpp b/libraries/tests/mbed/i2c_eeprom/main.cpp index fc7436c75b..b6825f96ac 100644 --- a/libraries/tests/mbed/i2c_eeprom/main.cpp +++ b/libraries/tests/mbed/i2c_eeprom/main.cpp @@ -71,10 +71,10 @@ const int i2c_delay_us = 0; } int main() { - TEST_TIMEOUT(15); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(I2C EEPROM read write test); - TEST_START("MBED_A19"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(I2C EEPROM read write test); + MBED_HOSTTEST_START("MBED_A19"); const int EEPROM_MEM_ADDR = 0xA0; const char MARK = 0x66; @@ -147,5 +147,5 @@ int main() { printf("\tTotal failures: %d\r\n", fw + fr + fc); } - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } diff --git a/libraries/tests/mbed/i2c_eeprom_line/main.cpp b/libraries/tests/mbed/i2c_eeprom_line/main.cpp index 7d3f11cda7..389bfdbcd5 100644 --- a/libraries/tests/mbed/i2c_eeprom_line/main.cpp +++ b/libraries/tests/mbed/i2c_eeprom_line/main.cpp @@ -76,10 +76,10 @@ I2C i2c(p28, p27); #define PATTERN_MASK 0x66, ~0x66, 0x00, 0xFF, 0xA5, 0x5A, 0xF0, 0x0F int main() { - TEST_TIMEOUT(15); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(I2C EEPROM line read write test); - TEST_START("MBED_A25"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(I2C EEPROM line read write test); + MBED_HOSTTEST_START("MBED_A25"); const int EEPROM_MEM_ADDR = 0xA0; bool result = true; @@ -138,5 +138,5 @@ int main() { printf("EEPROM: Pattern match errors: %d/%d ... [%s]\r\n", pattern_errors, ntests, pattern_errors ? "FAIL" : "OK"); result = write_errors == 0 && read_errors == 0; - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } diff --git a/libraries/tests/mbed/interruptin/main.cpp b/libraries/tests/mbed/interruptin/main.cpp index 882c5e7f26..c446b238e7 100644 --- a/libraries/tests/mbed/interruptin/main.cpp +++ b/libraries/tests/mbed/interruptin/main.cpp @@ -87,10 +87,10 @@ void flipper() { } int main() { - TEST_TIMEOUT(15); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(InterruptIn); - TEST_START("MBED_A7"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(InterruptIn); + MBED_HOSTTEST_START("MBED_A7"); IN_OUT_CLEAR; //Test falling edges first @@ -100,7 +100,7 @@ int main() { if(checks != 5) { printf("MBED: falling edges test failed: %d\r\n",checks); - TEST_RESULT(false); + MBED_HOSTTEST_RESULT(false); } //Now test rising edges @@ -110,7 +110,7 @@ int main() { if (checks != 10) { printf("MBED: raising edges test failed: %d\r\n", checks); - TEST_RESULT(false); + MBED_HOSTTEST_RESULT(false); } //Now test switch off edge detection @@ -120,7 +120,7 @@ int main() { if (checks != 10) { printf("MBED: edge detection switch off test failed: %d\r\n", checks); - TEST_RESULT(false); + MBED_HOSTTEST_RESULT(false); } //Finally test both @@ -130,8 +130,8 @@ int main() { if (checks != 20) { printf("MBED: Simultaneous rising and falling edges failed: %d\r\n", checks); - TEST_RESULT(false); + MBED_HOSTTEST_RESULT(false); } - TEST_RESULT(true); + MBED_HOSTTEST_RESULT(true); } diff --git a/libraries/tests/mbed/portinout/main.cpp b/libraries/tests/mbed/portinout/main.cpp index 8f1333e305..c7d64c985e 100644 --- a/libraries/tests/mbed/portinout/main.cpp +++ b/libraries/tests/mbed/portinout/main.cpp @@ -91,10 +91,10 @@ PortInOut port1(PORT_1, MASK_1); PortInOut port2(PORT_2, MASK_2); int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(PortInOut); - TEST_START("MBED_A11"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(PortInOut); + MBED_HOSTTEST_START("MBED_A11"); bool check = true; @@ -116,5 +116,5 @@ int main() { port2 = 0; wait(0.1); if (port1 != 0) check = false; - TEST_RESULT(check); + MBED_HOSTTEST_RESULT(check); } diff --git a/libraries/tests/mbed/portout_portin/main.cpp b/libraries/tests/mbed/portout_portin/main.cpp index 3797faebb5..7a0a370e0b 100644 --- a/libraries/tests/mbed/portout_portin/main.cpp +++ b/libraries/tests/mbed/portout_portin/main.cpp @@ -91,10 +91,10 @@ PortOut port_out(PORT_1, MASK_1); PortIn port_in (PORT_2, MASK_2); int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(PortOut PortIn); - TEST_START("MBED_A10"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(PortOut PortIn); + MBED_HOSTTEST_START("MBED_A10"); port_out = MASK_1; wait(0.1); diff --git a/libraries/tests/mbed/rtc/main.cpp b/libraries/tests/mbed/rtc/main.cpp index 3e8a520d41..505e70b5af 100644 --- a/libraries/tests/mbed/rtc/main.cpp +++ b/libraries/tests/mbed/rtc/main.cpp @@ -4,10 +4,10 @@ #define CUSTOM_TIME 1256729737 int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(rtc_auto); - TEST_DESCRIPTION(RTC); - TEST_START("MBED_16"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(rtc_auto); + MBED_HOSTTEST_DESCRIPTION(RTC); + MBED_HOSTTEST_START("MBED_16"); char buffer[32] = {0}; set_time(CUSTOM_TIME); // Set RTC time to Wed, 28 Oct 2009 11:35:37 diff --git a/libraries/tests/mbed/sd/main.cpp b/libraries/tests/mbed/sd/main.cpp index 0bac9c4aa4..296760957b 100644 --- a/libraries/tests/mbed/sd/main.cpp +++ b/libraries/tests/mbed/sd/main.cpp @@ -62,10 +62,10 @@ const int DATA_SIZE = 256; } int main() { - TEST_TIMEOUT(15); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(SD File System); - TEST_START("MBED_A12"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(SD File System); + MBED_HOSTTEST_START("MBED_A12"); uint8_t data_written[DATA_SIZE] = { 0 }; bool result = false; @@ -107,5 +107,5 @@ int main() { } result = write_result && read_result; - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } diff --git a/libraries/tests/mbed/sd_perf_fatfs/main.cpp b/libraries/tests/mbed/sd_perf_fatfs/main.cpp index 555022de61..df24762e81 100644 --- a/libraries/tests/mbed/sd_perf_fatfs/main.cpp +++ b/libraries/tests/mbed/sd_perf_fatfs/main.cpp @@ -125,10 +125,10 @@ char RandomChar() { } int main() { - TEST_TIMEOUT(15); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(SD FatFS RW Speed); - TEST_START("PERF_3"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(SD FatFS RW Speed); + MBED_HOSTTEST_START("PERF_3"); // Test header printf("\r\n"); @@ -156,5 +156,5 @@ int main() { } break; } - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } diff --git a/libraries/tests/mbed/sd_perf_fhandle/main.cpp b/libraries/tests/mbed/sd_perf_fhandle/main.cpp index 292530366f..835dad9b9d 100644 --- a/libraries/tests/mbed/sd_perf_fhandle/main.cpp +++ b/libraries/tests/mbed/sd_perf_fhandle/main.cpp @@ -120,10 +120,10 @@ char RandomChar() { } int main() { - TEST_TIMEOUT(15); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(SD FileHandle RW Speed); - TEST_START("PERF_2"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(SD FileHandle RW Speed); + MBED_HOSTTEST_START("PERF_2"); // Test header printf("\r\n"); @@ -151,5 +151,5 @@ int main() { } break; } - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } diff --git a/libraries/tests/mbed/sd_perf_stdio/main.cpp b/libraries/tests/mbed/sd_perf_stdio/main.cpp index 05246cf83e..6da688743a 100644 --- a/libraries/tests/mbed/sd_perf_stdio/main.cpp +++ b/libraries/tests/mbed/sd_perf_stdio/main.cpp @@ -120,10 +120,10 @@ char RandomChar() { } int main() { - TEST_TIMEOUT(15); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(SD stdio RW Speed); - TEST_START("PERF_1"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(SD stdio RW Speed); + MBED_HOSTTEST_START("PERF_1"); // Test header printf("\r\n"); @@ -151,5 +151,5 @@ int main() { } break; } - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } diff --git a/libraries/tests/mbed/semihost/main.cpp b/libraries/tests/mbed/semihost/main.cpp index 337c3b4fc6..2ef91d12a4 100644 --- a/libraries/tests/mbed/semihost/main.cpp +++ b/libraries/tests/mbed/semihost/main.cpp @@ -6,10 +6,10 @@ #define MAC_VENDOR_ARM_2 0xF7 int main() { - TEST_TIMEOUT(10); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(Semihost); - TEST_START("MBED_22"); + MBED_HOSTTEST_TIMEOUT(10); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(Semihost); + MBED_HOSTTEST_START("MBED_22"); printf("Semihost connected: %s\n", (semihost_connected()) ? ("Yes") : ("No")); @@ -34,5 +34,5 @@ int main() { printf("MAC Address Prefix: 00:02:F7, Vendor: ARM\r\n"); } - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } diff --git a/libraries/tests/mbed/stdio/main.cpp b/libraries/tests/mbed/stdio/main.cpp index cb80e95d07..0b2445de9b 100644 --- a/libraries/tests/mbed/stdio/main.cpp +++ b/libraries/tests/mbed/stdio/main.cpp @@ -7,10 +7,10 @@ */ int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(stdio_auto); - TEST_DESCRIPTION(stdio); - TEST_START("MBED_2"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(stdio_auto); + MBED_HOSTTEST_DESCRIPTION(stdio); + MBED_HOSTTEST_START("MBED_2"); DigitalOut led1(LED1); DigitalOut led2(LED2); diff --git a/libraries/tests/mbed/ticker/main.cpp b/libraries/tests/mbed/ticker/main.cpp index 7a97467e31..fc1ed9ca30 100644 --- a/libraries/tests/mbed/ticker/main.cpp +++ b/libraries/tests/mbed/ticker/main.cpp @@ -33,10 +33,10 @@ void flip_2() { } int main() { - TEST_TIMEOUT(15); - TEST_HOSTTEST(wait_us_auto); - TEST_DESCRIPTION(Ticker Int); - TEST_START("MBED_11"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(wait_us_auto); + MBED_HOSTTEST_DESCRIPTION(Ticker Int); + MBED_HOSTTEST_START("MBED_11"); led1 = 0; led2 = 0; diff --git a/libraries/tests/mbed/ticker_2/main.cpp b/libraries/tests/mbed/ticker_2/main.cpp index fdc55a954a..2509f4e4db 100644 --- a/libraries/tests/mbed/ticker_2/main.cpp +++ b/libraries/tests/mbed/ticker_2/main.cpp @@ -27,10 +27,10 @@ void togglePin(void) int main() { - TEST_TIMEOUT(15); - TEST_HOSTTEST(wait_us_auto); - TEST_DESCRIPTION(Ticker Int us); - TEST_START("MBED_23"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(wait_us_auto); + MBED_HOSTTEST_DESCRIPTION(Ticker Int us); + MBED_HOSTTEST_START("MBED_23"); tick.attach_us(togglePin, 1000); diff --git a/libraries/tests/mbed/ticker_3/main.cpp b/libraries/tests/mbed/ticker_3/main.cpp index 0a016c4b1c..a24078eb69 100644 --- a/libraries/tests/mbed/ticker_3/main.cpp +++ b/libraries/tests/mbed/ticker_3/main.cpp @@ -32,10 +32,10 @@ void ticker_callback_1(void) int main(void) { - TEST_TIMEOUT(15); - TEST_HOSTTEST(wait_us_auto); - TEST_DESCRIPTION(Ticker Two callbacks); - TEST_START("MBED_34"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(wait_us_auto); + MBED_HOSTTEST_DESCRIPTION(Ticker Two callbacks); + MBED_HOSTTEST_START("MBED_34"); ticker.attach(ticker_callback_1, 1.0); diff --git a/libraries/tests/mbed/time_us/main.cpp b/libraries/tests/mbed/time_us/main.cpp index 4c8fbda77c..18452c8f47 100644 --- a/libraries/tests/mbed/time_us/main.cpp +++ b/libraries/tests/mbed/time_us/main.cpp @@ -15,10 +15,10 @@ void print_char(char c = '*') int main() { - TEST_TIMEOUT(15); - TEST_HOSTTEST(wait_us_auto); - TEST_DESCRIPTION(Time us); - TEST_START("MBED_25"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(wait_us_auto); + MBED_HOSTTEST_DESCRIPTION(Time us); + MBED_HOSTTEST_START("MBED_25"); while (true) { for (int i = 0; i < MS_INTERVALS; i++) { diff --git a/libraries/tests/mbed/timeout/main.cpp b/libraries/tests/mbed/timeout/main.cpp index 693438cb25..0dc7ee1ce4 100644 --- a/libraries/tests/mbed/timeout/main.cpp +++ b/libraries/tests/mbed/timeout/main.cpp @@ -31,10 +31,10 @@ void toggleOff(void) { } int main() { - TEST_TIMEOUT(15); - TEST_HOSTTEST(wait_us_auto); - TEST_DESCRIPTION(Timeout Int us); - TEST_START("MBED_24"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(wait_us_auto); + MBED_HOSTTEST_DESCRIPTION(Timeout Int us); + MBED_HOSTTEST_START("MBED_24"); toggleOn(); diff --git a/libraries/tests/mbed/vtor_reloc/main.cpp b/libraries/tests/mbed/vtor_reloc/main.cpp index e3e31842e5..e43c179c7a 100644 --- a/libraries/tests/mbed/vtor_reloc/main.cpp +++ b/libraries/tests/mbed/vtor_reloc/main.cpp @@ -46,17 +46,17 @@ static bool test_once() { } int main() { - TEST_TIMEOUT(15); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(Interrupt vector relocation); - TEST_START("MBED_A18"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(Interrupt vector relocation); + MBED_HOSTTEST_START("MBED_A18"); // First test, no table reallocation { printf("Starting first test (interrupts not relocated).\r\n"); bool ret = test_once(); if (ret == false) { - TEST_RESULT(false); + MBED_HOSTTEST_RESULT(false); } } @@ -68,9 +68,9 @@ int main() { bool ret = test_once(); if (ret == false) { - TEST_RESULT(false); + MBED_HOSTTEST_RESULT(false); } } - TEST_RESULT(true); + MBED_HOSTTEST_RESULT(true); } diff --git a/libraries/tests/net/echo/tcp_client/main.cpp b/libraries/tests/net/echo/tcp_client/main.cpp index d9fc72d29c..17193f08d0 100644 --- a/libraries/tests/net/echo/tcp_client/main.cpp +++ b/libraries/tests/net/echo/tcp_client/main.cpp @@ -10,10 +10,10 @@ struct s_ip_address { }; int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(tcpecho_client_auto); - TEST_DESCRIPTION(TCP echo client); - TEST_START("NET_4"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(tcpecho_client_auto); + MBED_HOSTTEST_DESCRIPTION(TCP echo client); + MBED_HOSTTEST_START("NET_4"); char buffer[256] = {0}; char out_buffer[] = "Hello World\n"; diff --git a/libraries/tests/net/echo/tcp_client_loop/main.cpp b/libraries/tests/net/echo/tcp_client_loop/main.cpp index 6fe95bff5f..6c797e7443 100644 --- a/libraries/tests/net/echo/tcp_client_loop/main.cpp +++ b/libraries/tests/net/echo/tcp_client_loop/main.cpp @@ -22,10 +22,10 @@ char char_rand() { } int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(tcpecho_client_auto); - TEST_DESCRIPTION(TCP client echo loop); - TEST_START("NET_13"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(tcpecho_client_auto); + MBED_HOSTTEST_DESCRIPTION(TCP client echo loop); + MBED_HOSTTEST_START("NET_13"); char buffer[BUFFER_SIZE] = {0}; char out_buffer[BUFFER_SIZE] = {0}; @@ -74,5 +74,5 @@ int main() { } socket.close(); eth.disconnect(); - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } diff --git a/libraries/tests/net/echo/tcp_server/main.cpp b/libraries/tests/net/echo/tcp_server/main.cpp index 04fa0998c2..421fb0dbec 100644 --- a/libraries/tests/net/echo/tcp_server/main.cpp +++ b/libraries/tests/net/echo/tcp_server/main.cpp @@ -8,10 +8,10 @@ namespace { } int main (void) { - TEST_TIMEOUT(20); - TEST_HOSTTEST(tcpecho_server_auto); - TEST_DESCRIPTION(TCP echo server); - TEST_START("NET_3"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(tcpecho_server_auto); + MBED_HOSTTEST_DESCRIPTION(TCP echo server); + MBED_HOSTTEST_START("NET_3"); char buffer[BUFFER_SIZE] = {0}; EthernetInterface eth; diff --git a/libraries/tests/net/echo/udp_client/main.cpp b/libraries/tests/net/echo/udp_client/main.cpp index 65e2e17896..97f6050508 100644 --- a/libraries/tests/net/echo/udp_client/main.cpp +++ b/libraries/tests/net/echo/udp_client/main.cpp @@ -24,10 +24,10 @@ char char_rand() { } int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(udpecho_client_auto); - TEST_DESCRIPTION(UDP echo client); - TEST_START("NET_6"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(udpecho_client_auto); + MBED_HOSTTEST_DESCRIPTION(UDP echo client); + MBED_HOSTTEST_START("NET_6"); char buffer[BUFFER_SIZE] = {0}; char out_buffer[BUFFER_SIZE] = {0}; @@ -78,5 +78,5 @@ int main() { socket.close(); eth.disconnect(); - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } diff --git a/libraries/tests/net/echo/udp_server/main.cpp b/libraries/tests/net/echo/udp_server/main.cpp index fa7e6b2c40..ea90ff7d4a 100644 --- a/libraries/tests/net/echo/udp_server/main.cpp +++ b/libraries/tests/net/echo/udp_server/main.cpp @@ -8,10 +8,10 @@ namespace { } int main (void) { - TEST_TIMEOUT(20); - TEST_HOSTTEST(udpecho_server_auto); - TEST_DESCRIPTION(UDP echo server); - TEST_START("NET_5"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(udpecho_server_auto); + MBED_HOSTTEST_DESCRIPTION(UDP echo server); + MBED_HOSTTEST_START("NET_5"); EthernetInterface eth; eth.init(); //Use DHCP diff --git a/libraries/tests/net/helloworld/tcpclient/main.cpp b/libraries/tests/net/helloworld/tcpclient/main.cpp index 4d1d05014f..303f547aa1 100644 --- a/libraries/tests/net/helloworld/tcpclient/main.cpp +++ b/libraries/tests/net/helloworld/tcpclient/main.cpp @@ -24,10 +24,10 @@ bool find_substring(const char *first, const char *last, const char *s_first, co } int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(TCP client hello world); - TEST_START("NET_1"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(TCP client hello world); + MBED_HOSTTEST_START("NET_1"); bool result = false; EthernetInterface eth; @@ -81,5 +81,5 @@ int main() { sock.close(); eth.disconnect(); - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } diff --git a/libraries/tests/net/helloworld/udpclient/main.cpp b/libraries/tests/net/helloworld/udpclient/main.cpp index ecf1970e6b..59dad6db6f 100644 --- a/libraries/tests/net/helloworld/udpclient/main.cpp +++ b/libraries/tests/net/helloworld/udpclient/main.cpp @@ -10,10 +10,10 @@ namespace { int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(NIST Internet Time Service); - TEST_START("NET_2"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(NIST Internet Time Service); + MBED_HOSTTEST_START("NET_2"); bool result = false; EthernetInterface eth; @@ -52,5 +52,5 @@ int main() { } sock.close(); eth.disconnect(); - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); } diff --git a/libraries/tests/net/protocols/HTTPClient_HelloWorld/main.cpp b/libraries/tests/net/protocols/HTTPClient_HelloWorld/main.cpp index 7e9417619d..5ab616ea95 100644 --- a/libraries/tests/net/protocols/HTTPClient_HelloWorld/main.cpp +++ b/libraries/tests/net/protocols/HTTPClient_HelloWorld/main.cpp @@ -9,10 +9,10 @@ namespace { } int main() { - TEST_TIMEOUT(15); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(HTTP client hello world); - TEST_START("NET_7"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(HTTP client hello world); + MBED_HOSTTEST_START("NET_7"); char http_request_buffer[BUFFER_SIZE + 1] = {0}; HTTPClient http; @@ -35,7 +35,7 @@ int main() { if (result == false) { eth.disconnect(); - TEST_RESULT(false); + MBED_HOSTTEST_RESULT(false); } } @@ -59,9 +59,9 @@ int main() { if (result == false) { eth.disconnect(); - TEST_RESULT(false); + MBED_HOSTTEST_RESULT(false); } } eth.disconnect(); - TEST_RESULT(true); + MBED_HOSTTEST_RESULT(true); } diff --git a/libraries/tests/net/protocols/NTPClient_HelloWorld/main.cpp b/libraries/tests/net/protocols/NTPClient_HelloWorld/main.cpp index c96b5145b0..fa71656b01 100644 --- a/libraries/tests/net/protocols/NTPClient_HelloWorld/main.cpp +++ b/libraries/tests/net/protocols/NTPClient_HelloWorld/main.cpp @@ -4,10 +4,10 @@ #include "NTPClient.h" int main() { - TEST_TIMEOUT(15); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(NTP client); - TEST_START("NET_8"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(NTP client); + MBED_HOSTTEST_START("NET_8"); EthernetInterface eth; NTPClient ntp; @@ -31,9 +31,9 @@ int main() { } if (result == false) { - TEST_RESULT(false); + MBED_HOSTTEST_RESULT(false); } } eth.disconnect(); - TEST_RESULT(true); + MBED_HOSTTEST_RESULT(true); } diff --git a/libraries/tests/rtos/mbed/basic/main.cpp b/libraries/tests/rtos/mbed/basic/main.cpp index 4b286cbbc3..541436786c 100644 --- a/libraries/tests/rtos/mbed/basic/main.cpp +++ b/libraries/tests/rtos/mbed/basic/main.cpp @@ -30,10 +30,10 @@ void led2_thread(void const *argument) { } int main() { - TEST_TIMEOUT(15); - TEST_HOSTTEST(wait_us_auto); - TEST_DESCRIPTION(Basic thread); - TEST_START("RTOS_1"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(wait_us_auto); + MBED_HOSTTEST_DESCRIPTION(Basic thread); + MBED_HOSTTEST_START("RTOS_1"); Thread thread(led2_thread, NULL, osPriorityNormal, STACK_SIZE); diff --git a/libraries/tests/rtos/mbed/file/main.cpp b/libraries/tests/rtos/mbed/file/main.cpp index 591732597e..af32f668d6 100644 --- a/libraries/tests/rtos/mbed/file/main.cpp +++ b/libraries/tests/rtos/mbed/file/main.cpp @@ -50,7 +50,7 @@ void sd_thread(void const *argument) printf("MBED: Done" NL); } else { printf("MBED: Can't open '%s'" NL, FILE_NAME); - TEST_RESULT(false); + MBED_HOSTTEST_RESULT(false); } } @@ -71,7 +71,7 @@ void sd_thread(void const *argument) printf("MBED: Done\r\n"); } else { printf("MBED: Can't open '%s'" NL, FILE_NAME); - TEST_RESULT(false); + MBED_HOSTTEST_RESULT(false); } } @@ -79,17 +79,17 @@ void sd_thread(void const *argument) for (int i = 0; i < SIZE; i++) { if (data_written[i] != data_read[i]) { printf("MBED: Data index=%d: w[0x%02X] != r[0x%02X]" NL, i, data_written[i], data_read[i]); - TEST_RESULT(false); + MBED_HOSTTEST_RESULT(false); } } - TEST_RESULT(true); + MBED_HOSTTEST_RESULT(true); } int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(SD File write read); - TEST_START("RTOS_9"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(SD File write read); + MBED_HOSTTEST_START("RTOS_9"); Thread t(sd_thread, NULL, osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25)); diff --git a/libraries/tests/rtos/mbed/isr/main.cpp b/libraries/tests/rtos/mbed/isr/main.cpp index 4dc681f40f..7168564fa9 100644 --- a/libraries/tests/rtos/mbed/isr/main.cpp +++ b/libraries/tests/rtos/mbed/isr/main.cpp @@ -36,10 +36,10 @@ void queue_thread(void const *argument) { } int main (void) { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(ISR (Queue)); - TEST_START("RTOS_8"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(ISR (Queue)); + MBED_HOSTTEST_START("RTOS_8"); Thread thread(queue_thread, NULL, osPriorityNormal, STACK_SIZE); Ticker ticker; @@ -64,6 +64,6 @@ int main (void) { } } - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); return 0; } diff --git a/libraries/tests/rtos/mbed/mail/main.cpp b/libraries/tests/rtos/mbed/mail/main.cpp index 9a0e200db7..105d3eafbf 100644 --- a/libraries/tests/rtos/mbed/mail/main.cpp +++ b/libraries/tests/rtos/mbed/mail/main.cpp @@ -40,10 +40,10 @@ void send_thread (void const *argument) { } int main (void) { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(Mail messaging); - TEST_START("RTOS_6"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(Mail messaging); + MBED_HOSTTEST_START("RTOS_6"); Thread thread(send_thread, NULL, osPriorityNormal, STACK_SIZE); bool result = true; @@ -70,6 +70,6 @@ int main (void) { } } } - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); return 0; } diff --git a/libraries/tests/rtos/mbed/mutex/main.cpp b/libraries/tests/rtos/mbed/mutex/main.cpp index fa85e87936..80d49a189c 100644 --- a/libraries/tests/rtos/mbed/mutex/main.cpp +++ b/libraries/tests/rtos/mbed/mutex/main.cpp @@ -59,10 +59,10 @@ void test_thread(void const *args) { } int main() { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default); - TEST_DESCRIPTION(Mutex resource lock); - TEST_START("RTOS_2"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default); + MBED_HOSTTEST_DESCRIPTION(Mutex resource lock); + MBED_HOSTTEST_START("RTOS_2"); const int t1_delay = THREAD_DELAY * 1; const int t2_delay = THREAD_DELAY * 2; @@ -82,6 +82,6 @@ int main() { } fflush(stdout); - TEST_RESULT(!mutex_defect); + MBED_HOSTTEST_RESULT(!mutex_defect); return 0; } diff --git a/libraries/tests/rtos/mbed/queue/main.cpp b/libraries/tests/rtos/mbed/queue/main.cpp index 713cff76f5..4f794bc4b8 100644 --- a/libraries/tests/rtos/mbed/queue/main.cpp +++ b/libraries/tests/rtos/mbed/queue/main.cpp @@ -42,10 +42,10 @@ void send_thread (void const *argument) { } int main (void) { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(Queue messaging); - TEST_START("RTOS_5"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(Queue messaging); + MBED_HOSTTEST_START("RTOS_5"); Thread thread(send_thread, NULL, osPriorityNormal, STACK_SIZE); bool result = true; @@ -72,6 +72,6 @@ int main (void) { } } } - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); return 0; } diff --git a/libraries/tests/rtos/mbed/semaphore/main.cpp b/libraries/tests/rtos/mbed/semaphore/main.cpp index 1021e7e97d..1f35e9f473 100644 --- a/libraries/tests/rtos/mbed/semaphore/main.cpp +++ b/libraries/tests/rtos/mbed/semaphore/main.cpp @@ -48,10 +48,10 @@ void test_thread(void const *delay) { } int main (void) { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(Semaphore resource lock); - TEST_START("RTOS_3"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(Semaphore resource lock); + MBED_HOSTTEST_START("RTOS_3"); const int t1_delay = THREAD_DELAY * 1; const int t2_delay = THREAD_DELAY * 2; @@ -70,6 +70,6 @@ int main (void) { } fflush(stdout); - TEST_RESULT(!sem_defect); + MBED_HOSTTEST_RESULT(!sem_defect); return 0; } diff --git a/libraries/tests/rtos/mbed/signals/main.cpp b/libraries/tests/rtos/mbed/signals/main.cpp index 9b13fe71e5..aefe72f93d 100644 --- a/libraries/tests/rtos/mbed/signals/main.cpp +++ b/libraries/tests/rtos/mbed/signals/main.cpp @@ -30,10 +30,10 @@ void led_thread(void const *argument) { } int main (void) { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(Signals messaging); - TEST_START("RTOS_4"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(Signals messaging); + MBED_HOSTTEST_START("RTOS_4"); Thread thread(led_thread, NULL, osPriorityNormal, STACK_SIZE); bool result = true; @@ -46,6 +46,6 @@ int main (void) { break; } } - TEST_RESULT(result); + MBED_HOSTTEST_RESULT(result); return 0; } diff --git a/libraries/tests/rtos/mbed/timer/main.cpp b/libraries/tests/rtos/mbed/timer/main.cpp index 98fda731cf..3c33551b0a 100644 --- a/libraries/tests/rtos/mbed/timer/main.cpp +++ b/libraries/tests/rtos/mbed/timer/main.cpp @@ -23,10 +23,10 @@ void blink(void const *n) { } int main(void) { - TEST_TIMEOUT(15); - TEST_HOSTTEST(wait_us_auto); - TEST_DESCRIPTION(Timer); - TEST_START("RTOS_7"); + MBED_HOSTTEST_TIMEOUT(15); + MBED_HOSTTEST_SELECT(wait_us_auto); + MBED_HOSTTEST_DESCRIPTION(Timer); + MBED_HOSTTEST_START("RTOS_7"); RtosTimer led_1_timer(blink, osTimerPeriodic, (void *)0); RtosTimer led_2_timer(blink, osTimerPeriodic, (void *)1); diff --git a/libraries/tests/utest/testrunner/testrunner.cpp b/libraries/tests/utest/testrunner/testrunner.cpp index 92154bed49..2c1969ce07 100644 --- a/libraries/tests/utest/testrunner/testrunner.cpp +++ b/libraries/tests/utest/testrunner/testrunner.cpp @@ -11,10 +11,10 @@ It is declared in \cpputest\src\Platforms\armcc\UtestPlatform.cpp Serial mbed_cpputest_console(STDIO_UART_TX, STDIO_UART_RX); int main(int ac, char** av) { - TEST_TIMEOUT(20); - TEST_HOSTTEST(default_auto); - TEST_DESCRIPTION(Unit test); - TEST_START("UT"); + MBED_HOSTTEST_TIMEOUT(20); + MBED_HOSTTEST_SELECT(default_auto); + MBED_HOSTTEST_DESCRIPTION(Unit test); + MBED_HOSTTEST_START("UT"); unsigned failureCount = 0; { @@ -24,6 +24,6 @@ int main(int ac, char** av) { failureCount = CommandLineTestRunner::RunAllTests(ac, av); } - TEST_RESULT(failureCount == 0); + MBED_HOSTTEST_RESULT(failureCount == 0); return failureCount; }