Until now, XJRunner tests have been limited to functions which have no input arguments and a single return argument (which returns the result). XJTAG v3.5 relaxes that restriction, allowing input in XJRunner tests, though there is still a requirement to have a single return argument for the result.
This is useful in a number of different scenarios. For example:
- You might create a general purpose flash programming function that takes the image to program as an argument.
- You might have a function that has a parameter to switch debug output on and off. The function could be run once in the test list with no debug output and then conditionally a second time if it fails with the debug output enabled.
In order to make a function with input arguments available, the function must be explicitly defined as GLOBAL. Once the function is marked as GLOBAL it will appear in the list of functions (either via the relevant device if it’s in a device file, or the Global functions if it’s in a circuit code file) for you to select it for testing.
When you add a test with input arguments it will appear as red in the XJRunner Test list – because the parameters have not yet been defined. Double-click the test and then select the Arguments tab, which will show a list of the arguments required. The arguments can be literals (ie numbers or strings) or (think of typing a spreadsheet formula here!) you can type an ‘=’ character followed by any valid XJEase expression. If you want to enter a string starting with an ‘=’ character, enclose the string in double-quotes, e.g. “= some string”.
When you set an argument on a function a small ‘A’ icon will appear next to the function where it is shown in XJDeveloper.
In XJRunner, where the arguments cannot be edited, no icon is shown.
Here is an example XJEase function that takes a filename as a parameter:
GLOBAL ProgramFlash(STRING filename)(INT result) FILE f; FOPEN(filename, "r")(f); // rest of function omitted... END;
When added to the testlist, you then need to edit the function and provide a value for the parameter:
The value for the parameter can be a constant value as above, but it can also be any XJEase expression. Here, we use the INPUTBOX XJEase function to prompt the user for the filename instead:
When the test is run, the user will be prompted like so:
This article was amended on 18/4/2017 to include a more thorough example.