Skip to content

Commit

Permalink
Modified test EXAMPLE_1 to fail if can't receive proper print from Mbed
Browse files Browse the repository at this point in the history
  • Loading branch information
PrzemekWirkus committed Sep 2, 2014
1 parent 52f929f commit b481bc4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions libraries/tests/mbed/dev_null/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 12 additions & 3 deletions workspace_tools/host_tests/dev_null_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,22 @@

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')
Expand Down

0 comments on commit b481bc4

Please sign in to comment.