From 22b4c558cd9c5c922ca84d7781e058d53d47bc9c Mon Sep 17 00:00:00 2001 From: maniacbug Date: Wed, 13 Jul 2011 15:02:03 -0700 Subject: [PATCH] Added a test script to control the test, using python. --- tests/README | 8 ++++++++ tests/pingpair_test/pingpair_test.pde | 4 ++-- tests/pingpair_test/runtest.py | 20 ++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100755 tests/pingpair_test/runtest.py diff --git a/tests/README b/tests/README index 02f01c8..5730385 100644 --- a/tests/README +++ b/tests/README @@ -1,2 +1,10 @@ The sketches in this directory are intended to be checkin tests. No code should be pushed to github without these tests passing. + +The way I run each test is from within the sketch dir, doing this: +jam p4 p6 && ./runtest.py /dev/tty.usbserial-A40081RP + +runtest.py will exit with code 0 on pass code 1 on fail + +Note that this requires python and py-serial + diff --git a/tests/pingpair_test/pingpair_test.pde b/tests/pingpair_test/pingpair_test.pde index 5e1d90e..f3e9ffa 100644 --- a/tests/pingpair_test/pingpair_test.pde +++ b/tests/pingpair_test/pingpair_test.pde @@ -239,9 +239,9 @@ void loop(void) detachInterrupt(0); printf("\n\r+OK "); if ( passed ) - printf("PASS\n\r"); + printf("PASS\n\r\n\r"); else - printf("FAIL\n\r"); + printf("FAIL\n\r\n\r"); // Wait here while(1) {} diff --git a/tests/pingpair_test/runtest.py b/tests/pingpair_test/runtest.py new file mode 100755 index 0000000..8941db0 --- /dev/null +++ b/tests/pingpair_test/runtest.py @@ -0,0 +1,20 @@ +#!/opt/local/bin/python + +import sys,serial + +def read_until(token): + while 1: + line = ser.readline(None,"\r") + sys.stdout.write(line) + + if (line.startswith("+OK")): + break + return line + + +ser = serial.Serial(sys.argv[1], 57600, timeout=5) +line = read_until("+OK") +if (line.find("PASS") != -1): + sys.exit(0) +else: + sys.exit(1)