diff --git a/libraries/tests/rtos/mbed/mutex/main.cpp b/libraries/tests/rtos/mbed/mutex/main.cpp index 6353d8cbb3..9983c4228c 100644 --- a/libraries/tests/rtos/mbed/mutex/main.cpp +++ b/libraries/tests/rtos/mbed/mutex/main.cpp @@ -16,16 +16,17 @@ DigitalOut led(LED1); volatile int change_counter = 0; volatile bool changing_counter = false; +volatile bool mutex_defect = false; bool manipulate_protected_zone(const int thread_delay) { bool result = true; stdio_mutex.lock(); // LOCK if (changing_counter == true) { - print_char('e'); // if changing_counter is true access is not exclusively + // 'e' stands for error. If changing_counter is true access is not exclusively + print_char('e'); result = false; - notify_completion(false); - exit(1); + mutex_defect = true; } changing_counter = true; @@ -53,17 +54,19 @@ int main() { const int t3_delay = THREAD_DELAY * 3; Thread t2(test_thread, (void *)t2_delay); Thread t3(test_thread, (void *)t3_delay); - bool result = true; while (true) { // Thread 1 action Thread::wait(t1_delay); manipulate_protected_zone(t1_delay); - if (change_counter >= SIGNALS_TO_EMIT) { + if (change_counter >= SIGNALS_TO_EMIT or mutex_defect == true) { + t2.terminate(); + t3.terminate(); break; } } - notify_completion(result); + fflush(stdout); + notify_completion(!mutex_defect); return 0; } diff --git a/libraries/tests/rtos/mbed/semaphore/main.cpp b/libraries/tests/rtos/mbed/semaphore/main.cpp index 3cd97ebb43..15cb8ce793 100644 --- a/libraries/tests/rtos/mbed/semaphore/main.cpp +++ b/libraries/tests/rtos/mbed/semaphore/main.cpp @@ -2,7 +2,7 @@ #include "test_env.h" #include "rtos.h" -#define THREAD_DELAY 100 +#define THREAD_DELAY 75 #define SEMAPHORE_SLOTS 2 #define SEM_CHANGES 100 @@ -16,6 +16,7 @@ Semaphore two_slots(SEMAPHORE_SLOTS); volatile int change_counter = 0; volatile int sem_counter = 0; +volatile bool sem_defect = false; void test_thread(void const *delay) { const int thread_delay = int(delay); @@ -26,8 +27,7 @@ void test_thread(void const *delay) { const char msg = sem_lock_failed ? 'e' : sem_counter + '0'; print_char(msg); if (sem_lock_failed) { - notify_completion(false); - exit(1); + sem_defect = true; } Thread::wait(thread_delay); print_char('.'); @@ -46,10 +46,15 @@ int main (void) { Thread t3(test_thread, (void *)t3_delay); while (true) { - if (change_counter >= SEM_CHANGES) { - notify_completion(true); + if (change_counter >= SEM_CHANGES or sem_defect == true) { + t1.terminate(); + t2.terminate(); + t3.terminate(); break; } } + + fflush(stdout); + notify_completion(!sem_defect); return 0; } diff --git a/workspace_tools/build_api.py b/workspace_tools/build_api.py index f8862984dc..d1266fe595 100644 --- a/workspace_tools/build_api.py +++ b/workspace_tools/build_api.py @@ -15,17 +15,18 @@ See the License for the specific language governing permissions and limitations under the License. """ -import tempfile import re -from os.path import join, exists, basename -from shutil import rmtree +import tempfile + from types import ListType +from shutil import rmtree +from os.path import join, exists, basename from workspace_tools.utils import mkdir, run_cmd, run_cmd_ext -from workspace_tools.toolchains import TOOLCHAIN_CLASSES from workspace_tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, MBED_HAL, MBED_COMMON -from workspace_tools.libraries import Library from workspace_tools.targets import TARGET_NAMES, TARGET_MAP +from workspace_tools.libraries import Library +from workspace_tools.toolchains import TOOLCHAIN_CLASSES def build_project(src_path, build_path, target, toolchain_name, diff --git a/workspace_tools/host_tests/hello_auto.py b/workspace_tools/host_tests/hello_auto.py index 4c33942e03..e69b740c5d 100644 --- a/workspace_tools/host_tests/hello_auto.py +++ b/workspace_tools/host_tests/hello_auto.py @@ -22,12 +22,27 @@ class HelloTest(DefaultTest): HELLO_WORLD = "Hello World\n" def run(self): - c = self.mbed.serial_read(len(self.HELLO_WORLD)) + c = self.mbed.serial_read(1) + if c is None: + self.print_result("ioerr_serial") + return + data_to_read = len(self.HELLO_WORLD) + read_buffer = '' + if c == '$': # target will printout TargetID e.g.: $$$$1040e649d5c09a09a3f6bc568adef61375c6 + #Read additional 39 bytes of TargetID + if self.mbed.serial_read(39) is None: + self.print_result("ioerr_serial") + return + else: + data_to_read -= 1 + read_buffer += c + c = self.mbed.serial_read(data_to_read) + read_buffer += c if c is None: self.print_result("ioerr_serial") return - stdout.write(c) - if c == self.HELLO_WORLD: # Hello World received + stdout.write(read_buffer) + if read_buffer == self.HELLO_WORLD: # Hello World received self.print_result('success') else: self.print_result('failure') diff --git a/workspace_tools/host_tests/stdio_auto.py b/workspace_tools/host_tests/stdio_auto.py index b262e065ba..9ebf05c075 100644 --- a/workspace_tools/host_tests/stdio_auto.py +++ b/workspace_tools/host_tests/stdio_auto.py @@ -22,7 +22,7 @@ from time import time from sys import stdout class StdioTest(DefaultTest): - PATTERN_INT_VALUE = "^Your value was: (-?\d+)" + PATTERN_INT_VALUE = "Your value was: (-?\d+)" re_detect_int_value = re.compile(PATTERN_INT_VALUE) def run(self): diff --git a/workspace_tools/host_tests/wait_us_auto.py b/workspace_tools/host_tests/wait_us_auto.py index 9171bdb2e8..a794cff442 100644 --- a/workspace_tools/host_tests/wait_us_auto.py +++ b/workspace_tools/host_tests/wait_us_auto.py @@ -32,7 +32,7 @@ class WaitusTest(DefaultTest): return if c == '$': # target will printout TargetID e.g.: $$$$1040e649d5c09a09a3f6bc568adef61375c6 #Read additional 39 bytes of TargetID - if not self.mbed.serial_read(39): + if self.mbed.serial_read(39) is None: self.print_result("ioerr_serial") return c = self.mbed.serial_read(1) # Re-read first 'tick'