| ||||||
Chapter 16 Reactis for C PluginThe base Reactis product treats S-Functions and Stateflow custom C code as black boxes. Models containing such C code can be processed, but the C source code is inaccessible. Hence, there is no way to perform basic debugging operations such as single-stepping, viewing variable values, setting breakpoints, or browsing the source code during simulation. Furthermore, targets cannot be created within the C source code when generating tests. Reactis for C Plugin integrates seamlessly with Reactis to offer white-box testing and validation of the C-code portions of models (S-Functions and C code called from Stateflow). Together, Reactis and Reactis for C Plugin automate the generation of test data from, and validation of models constructed with Simulink, Stateflow, and C code. A separate license is required to use the Reactis for C Plugin. If your organization does not yet own such a license please contact sales@reactive-systems.com to inquire about purchase options or to obtain a demo license for the product. Reactis for C Plugin also requires base Reactis to run. 16.1 Quick Start
16.2 Reactis for C Tab of the Settings Dialog
16.3 Specifying the C Source Files to Build an S-FunctionSimulink does not require the user to specify the C source files that implement an S-Function; instead only a name is given. For white-box testing, Reactis for C Plugin requires the C source files that implement an S-Function as well as the source files for any libraries referenced by the S-Function. Since the .mdl file does not include this information, Reactis for C Plugin has a mechanism for listing the C source files which comprise an S-Function. This mechanism is described in the rest of this section. The collection of C source files that implement an S-Function is specified using a Reactis Make File (.rsm file ), which is created and modified by the simple editor shown in Figure 16.2. A .rsm file is created to specify how Reactis for C Plugin should compile the S-Function. Additionally, a separate .rsm file is constructed for each library referenced by the S-Function. The .rsm files for the S-Function and any libraries referenced by the S-Function are defined in the same way. In the following discussion we denote the library compiled from an .rsm file as the library under construction (LUC). The following sections appear within the .rsm file editor window:
16.3.1 S-Function RequirementsAll source code (for both an S-Function and any referenced libraries) must be available. In addition, all code must satisfy the requirements listed in Section 14.2.1. 16.4 Specifying the C Source Files Called from StateflowReactis for C Plugin does not require an .rsm file to list the files containing custom C code called from Stateflow. This is because Stateflow requires the user to specify the C source files in the Target Options dialog 1 and stores the names of the files in the .mdl file for a model. Reactis for C Plugin will therefore automatically process custom C code without any action required from the user. The C files called from Stateflow will be listed at the bottom of the Reactis hierarchy panel under C Libraries -> Library: Stateflow User Sources. 16.4.1 Stateflow Custom Code Requirments
16.5 C Code Coverage CriteriaReactis uses a number of different coverage criteria to measure how thoroughly a test or set of tests exercises a model. In general, coverage criteria record how many of a given class of coverage targets (model features such as stateflow states, C program statements, etc.) have been executed at least once. Coverage criteria may be visualized using Simulator and are central to test generation and model validation using Tester and Validator. Chapter 6 describes the coverage criteria that are tracked within the Simulink and Stateflow portions of models. Those criteria include some which are specific to Simulink, some which appear only in Stateflow, and others which are generic and can appear in either Simulink or Stateflow. Three of the generic critera are also tracked by the C code portions of models by Reactis for C Plugin. These are decision coverage, condition coverage, and modified condition / decision coverage (MC/DC). Reactis for C Plugin uses precise criteria to determine which elements of C a program are decisions and which are conditions. A decision is any boolean-valued expression used to determine which execution path to follow. Conditions represent the atomic (i.e. smallest) boolean expressions within decisions. Specifically, decisions within a program are identified as follows:
Note that the argument expression of a Decision coverage tracks whether each decision in a program has evaluated to both true and false. Condition coverage tracks whether each condition in a program has evaluated to both true and false. For the definition of MC/DC coverage, please see Chapter 6. Finally, in addition to the generic coverage criteria discussed above, Reactis for C Plugin also tracks statement coverage, which records for each statement in a C program, whether or not the statement has been executed at least once. 16.5.1 Tracking Coverage in C CodeWhen Coverage -> Show Details in Simulator is selected, unexercised coverage targets in C code are reported visually as shown in Figure 16.3. Any unexecuted C statement is rendered in red. If a decision has not evaluated to true it has a thin red overline. If a decision has not evaluated to false it has a thin red underline. If a condition has not evaluated to true it has a thick red overline. If a condition has not evaluated to false it has a thick red underline. If a decision has not met the MC/DC criteria, then the text of the decision is dispayed in red. The MC/DC-related coverage details associated with a decision (Figure 16.4) may be displayed by right clicking on the decision and selecting View Coverage Details. For a description of this dialog, please see Chapter 6. To aid the user in finding unexercised targets, a thin red bar is drawn just to the right of the line number for any line that contains at least one unexercised coverage target. 16.6 C Code in the Main Reactis WindowAs shown in Figure 16.5, an .rsm file may be assigned, edited, or removed by right-clicking on the S-Function in the main panel when Simulator is disabled. After an .rsm file is assigned, the C source files for an S-Function are listed in the hierarchy panel and “RSM” appears in the upper right corner of the S-Function in the main panel. Figure 16.6 shows that a C file may be displayed in the main panel by clicking on the filename in the hierarchy panel. Line numbers and the grid may be turned on or off from the Reactis for C tab of the Settings dialog. 16.7 Debugging C Code with Reactis SimulatorWhen Reactis for C Plugin is enabled, Simulator seamlessly steps into Stateflow C
code and S-Functions that have .rsm files assigned. The Simulator
controls in the tool bar work in the same way within C code as they
do for the Simulink and Stateflow portions of models. Within C code,
the mini-step button (
As shown in Figure 16.7, a breakpoint may be toggled on lines within a C file which contain a C statement by double clicking just to the right of the line number, or by right-clicking to the right of the line number and selecting Toggle Breakpoint. When paused at a breakpoint within a function, you may hover over any local variable within the function to query its current value. For a description of how Simulator visually presents coverage information please see Section 16.5.1. 16.8 Generating Tests from C Code in Reactis TesterWhen Reactis for C Plugin is enabled, Tester automatically tries to exercise the coverage targets (described in Section 16.5) in Stateflow custom C code and S-Functions that have .rsm files assigned. The launch dialog includes a checkbox to enable or disable C statement coverage. 16.9 Validating C Code with Reactis ValidatorReactis Validator can check requirements on top-level S-Function inputs and outputs. To do so, Validator objectives are inserted within the subsystem which contains the S-Function. Reactis for C Plugin does not currently support the insertion of Validator objectives within the C code. 16.10 Unsupported C FeaturesReactis for C Plugin supports a very large subset of the C99 standard. The following features, however, are not currently supported.
The following restrictions apply for white-box analysis of S-Functions:
The following runtime library functions are currently unimplemented:
One additional restriction is that the size of type
| ||||||
| ||||||