mirror of https://github.com/ARMmbed/mbed-os.git
Modified test EXAMPLE_1 to fail if can't receive proper print from Mbed
parent
52f929f4e0
commit
b481bc4319
|
@ -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;
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue