Unit Testing on Real Time Targets

I’ve written a lot previously on unit testing and the value of unit tests. I try very hard to write unit tests for all my software and i try to use Test Driven Development (TDD) as much as I can. It’s not always easy.

I just started a Real Time (RT) project recently. I don’t do a whole lot of RT. I haven’t done much with it since I got into unit testing and TDD. I wanted to implement some unit tests for this project, but wasn’t quite sure how to go about that. I remembered hearing that JKI VITester wouldn’t work on RT and that Caraya would. I’ve also been meaning to play around with Caraya some more. As much as I like VI Tester, Caraya does appear to be the way of the future. I thought I would check it out.

Initial Attempt

My initial attempt at a Unit Test on RT.

My initial thought was to write a test exactly as I would on Windows and then run it on the RT target. I didn’t really expect it to work, but thought it might be a good place to start. Of course, it didn’t work. It generated an error.

Oh no!


Creating a Test Suite and setting the non-interactive flag works (it gets rid of the error), but how do you view the results?

A little google searching led to a solution. The issue is with the Caraya GUI. If you’ve done any RT stuff you will know that GUIs are limited on RT targets, so that all makes sense. The solution is to wrap your tests in a Test Suite and set the Suite to be non-interactive (ie. no GUI). That gets rid of the error.

Adding a test report to collect the results.

The question then is, well how do you see your results if there is no GUI? It turns out the answer is to just have it create a report. The problem is that the report is generated on the target, so you have to figure out how to view it. As a first pass, I just SSHed into the cRIO and viewed the report in the terminal.

SSH is one way to view the results file. Using cat and piping the output to grep is a quick way to find failed tests.


Once I was able to run Caraya and generate a report, I was one step closer. However, SSHing in is a bit of a pain and not everyone is comfortable on the CLI. So I wanted a better solution. The VI that runs the tests is running on the cRIO and the results file is on the cRIO so it was pretty easy to just add a little code to parse the contents of the results file and display it on the front panel.

Here we just read the results file. Column 2 is the pass/fail column.


If you need help implementing unit testing or TDD in your project, we can help! Use the button below to schedule a call.

3 Comments on “Unit Testing on Real Time Targets

  1. Nice Post. I haven’t had an opportunity to try UT in cRIO, maybe I’ll give it a try in a next project.
    For navigating in cRIO, I would suggest BitVise Client as it provides visual interface for navigating in files through SSH (and it is freeware).
    About this approach on UT, I am pretty sure it only works on UI Capable cRIOs (9040 series), if you try to run the same code on non UI Capable, you get a lost connection warning.

    • Thanks for pointing out BitVise. It looks interesting. Right now I either use WinSCP or use WSL for transferring files.

      As far as UI capable or not, I am running it on a 9040 which has an embedded UI, but I have the embedded UI disabled. When running the tests I was setting a flag on the test suite, so that it wouldn’t show the Caraya GUI. Note if you look in the Caraya code you will notice a lot of it is disabled on RT anyway. It seems to work just fine. I haven’t tried it on a non UI Capable CRIO.

  2. You were right. I am definetely outdated. It seems it works fine even with non UI capable cRIO (9053).
    Probably I had this issue once with some structure (or older LV Version) and took this as the ultimate truth.
    Good to know.

Leave a Reply

Your email address will not be published. Required fields are marked *