Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 9 months ago.
How to write mbed tests (greentea etc) that require keyboard input
1. I am new to writing tests on the mbed. I am using an mbed LPC1768 and mbed-cli on Ubuntu 16.04. I may like to use one mbed LPC1768 as the device under test, and another as a test fixture; or I may want the mbed under test to be connected to hardware in a robotics project for hardware in the loop testing.
2. I'd like to write tests in which I run the test, the mbed does something to connected hardware, I observe it worked right or not. It should then ask me if it worked, and I enter in the test result that way. For example, I ask the mbed to pair a receiver (requires an external transmitter) - I verify when it tries to pair the light goes blinky and the transmitter sees the receiver as visible and in the correct mode, I enter "y" at a prompt, and mbed asserts true / test passed.
3. I do not see a convenient way to prompt a user on a tty in such a way. I see utest_printf() to get messages injected into the -vv output; and I see a way to block and await a key value pair from the Python script but I don't see a simple way to do a scanf()?
4. Use cases: a. Pairing a receiver (writing tests within a library) - observe blinky lights etc and prompt user if it worked b. Testing actuators - send an actuator command and observe that actuator moves right and prompt user if it worked c. Test communications - have fixture send messages over CAN or Serial or whatever, and check that mbed under test properly received. d. Have test fixture mbed connected to a simulator, and have mbed under test control it while monitoriing for proper responses.
5. Am I using the Greentea unity utest framework correctly? Or would such things rather just be their own main.cpp test program with no use of Greentea etc.