Modified test EXAMPLE_1 to fail if can't receive proper print from Mbed

pull/475/head
Przemek Wirkus 2014-09-02 14:52:24 +01:00
parent 52f929f4e0
commit b481bc4319
2 changed files with 14 additions and 5 deletions

View File

@ -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;

View File

@ -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')