How to: Simulating keystroke inputs in shell to an app running in an embedded target
I am writing an automation script that runs on an embedded linux target.
A part of the script involves running an app on the target and obtaining some data from the stdout. Stdout here is the ssh terminal connection I have to the target.
However, this data is available on the stdout only if certain keys are pressed and the key press has to be done on the keyboard connected to the embedded target and not on the host system from which I have ssh'd into the target. Is there any way to simulate this?
Edit: Elaborating on what I need -
I have an OpenGL app that I run on the embedded linux (works like regular linux) target. This displays some graphics on the embedded system's display device. Pressing f on the keyboard connected to the target outputs the fps data onto the ssh terminal from which I control the target.
Since I am automating the process of running this OpenGL app and obtaining the fps scores, I can't expect a keyboard to be connected to the target let alone expect a user to input a keystroke on the embedded target keyboard. How do I go about this?
Edit 2: Expect doesn't work since expect can issue strokes only to the ssh terminal. The keystroke I need to send to the app has to come from the keyboard connected to the target (this is the part that needs simulation without actually having a keyboard connected to it).
I'm not at home right now (so no linux at hand), so can't actually try it out. But you should be able to emulate keystrokes if you echo the desired keypresses (possibly the keyboard codes) to the keyboard node located under /dev on your target. This could be done through your ssh.
The quickest way to achieve the OpenGL automation you're after, while learning as little of Expect as necessary, is likely by way of autoexpect.
A solution which would satisfy both QA and manufacturing test is to build a piece of hardware which looks like a keyboard to the embedded device and has external control. Depending on how complex your input needs to be this could be anything from a store-bought keyboard with the spacebar taped down to a microcontroller talking PS/2 or USB on the keyboard side and something else (serial, USB, ethernet) on the control side.
With the LUFA library it is remarkably easy to make a USB keyboard with AT90USB series parts. Some of them even have 2 USB ports and could be automated by USB connected to another system (or if you want to get cheeky you could have it enumerate both as a keyboard and the control device and loop the keyboard input through the embedded system).
i am not familiar with embedded linux, but my first guess would be to echo the character sequence through a pipe to the running program. However, if you explain the details, maybe you can bypass the need to press a key before the stdout of the ssh terminal can be read.
How about echo "f" > /dev/console ?
How about create text file with inputs and run as follows?
cat inputs.txt | target_executable
Contents of inputs.txt can be something like follows,
y y y n y