I'd approach this by trying to craft a Makefile recipe to carry out the steps you want, including passing the binary to be tested as a command to ssh
. Something along the lines of (note that this is totally untested and probably overly complicated):
SCP_CMD=scp
SSH_CMP=ssh
HOST_URI=pi@raspberrypi.local
HOST_PATH=/home/pi/bin/
LOCAL_PATH=./
OUTPUT=binary_to_test
.PHONY: transfer remote_execute test_on_remote
test_on_remote: $(OUTPUT) transfer remote_execute
transfer:
$(SCP_CMD) $(LOCAL_PATH)$(OUTPUT) $(HOST_URI):$(HOST_PATH)$(OUTPUT)
remote_execute:
$(SSH_CMD) $(HOST_URI) "$(HOST_PATH)$(OUTPUT)"
Obviously you'd need to add some rules here to compile your binary as well. Just typing make
should then compile, transfer and run your binary. You may prefer to use rsync
instead of scp
if, for example, you had supporting files that need copying over as well as the binary to be tested.
A possible alternative to running the binary through ssh
for testing might be to install gdbserver
on your Pi and start it through ssh
and then connect to it with the cross-compiler gdb
on your development machine.
scp
to copy the files over, c) SSHs into the Pi, d) runs the program? The terminal window can be kept open until after program has finished running on the Pi. – stevieb Feb 8 at 16:31