From b481bc43193c84381071b95b687e6ff8c48f1c23 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Tue, 2 Sep 2014 14:52:24 +0100 Subject: [PATCH] Modified test EXAMPLE_1 to fail if can't receive proper print from Mbed --- libraries/tests/mbed/dev_null/main.cpp | 4 ++-- workspace_tools/host_tests/dev_null_auto.py | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libraries/tests/mbed/dev_null/main.cpp b/libraries/tests/mbed/dev_null/main.cpp index e0cd811a2d..9131f4f42a 100644 --- a/libraries/tests/mbed/dev_null/main.cpp +++ b/libraries/tests/mbed/dev_null/main.cpp @@ -19,9 +19,9 @@ DevNull null("null"); int main() { - printf("MBED: re-routing stdout to /null\n"); + printf("MBED: re-routing stdout to /null\r\n"); freopen("/null", "w", stdout); - printf("MBED: printf redirected to /null\n"); // This shouldn't appear + 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; diff --git a/workspace_tools/host_tests/dev_null_auto.py b/workspace_tools/host_tests/dev_null_auto.py index 615d7e28a0..58efa1ae8e 100644 --- a/workspace_tools/host_tests/dev_null_auto.py +++ b/workspace_tools/host_tests/dev_null_auto.py @@ -20,13 +20,22 @@ from sys import stdout class DevNullTest(DefaultTest): def run(self): - c = self.mbed.serial_read(512) + c = self.mbed.serial_read(128) if c is None: self.print_result("ioerr_serial") return # Data from serial received correctly - print "Received %d bytes" % len(c) - if "{failure}" not in c: + print "Received %d bytes:"% len(c) + print c + # Check for expected and unexpected prints in Mbed output + result = True + if "re-routing stdout to /null" not in c: + result = False + if "printf redirected to /null" in c: + result = False + if "{failure}" in c: + result = False + if result: self.print_result('success') else: self.print_result('failure')