Pages

Wednesday, September 26, 2018

Gradle: Debugging tests remotely on Raspberry-Pi

The ability to debug application remotely is very handy and useful to understand what is happening. On big computer using IDEs we sometime don't feel the problem but when it turns into the very small devices the "fun" has began. By small devices I mean for example RapsberryPi Zero based on single-core ARMv6Z (32-bit)
The Robo4J project is heavily multithreaded and writing quite advanced tests using sockets communication over the multiple units can be really time consuming process. More like searching for the magic number. The Robo4J uses Gradle build tool (4.10 and latter) which offers remote debugger for tests out of the box. For Robo4J the all tests run in parallel to speed up the build process. There is the necessity to build it on small devices , including tests, without any complications.
To attach the remote debugger for Gradle tests to run from the command-line without configuring any other Gradle property files. it's enough to extend the command by
adding the --debug-jvm command line option.
When the option is used Gradle will start the test process suspended and listening on port 5005. When you run the example you are free to attach your the remote debugger, the Gradle will nicely wait for you.
example to run one of Robo4J test: 

$ ./gradlew :robo4j-units-rpi-http:clean :robo4j-units-rpi-http:test --debug-jvm --tests "com.robo4j.units.rpi.http.camera.CameraImageProducerConsumerTests.cameraImageProdConTest"

Happy Coding!

No comments: