fcmpact addPrototypes

Edge Case: Generating a C Bridge File for Custom Signal Handling

Scénario de test & Cas d'usage

Business Context

An engineering team is integrating a legacy C simulation library that is known to be unstable and can cause segmentation faults. They need to use the `addPrototypes` action to generate a C bridge file with custom signal handling (`bridgeCatchSignals=TRUE`) to trap potential crashes and allow for graceful error reporting within CAS.
About the Set : fcmpact

Execution of SAS FCMP functions within the CAS environment.

Discover all actions of fcmpact
Data Preparation

This test does not require a data step. It focuses on the file generation capability of the action. We will define a prototype for a potentially unstable function, `run_legacy_simulation`, and instruct the action to generate the C bridge file on the CAS server's file system.

Copied!
1/* No
2data step required. The test validates file generation on the CAS controller. */

Étapes de réalisation

1
Execute `addPrototypes` with the `bridgeFile` parameter to specify an output path for the C source file and set `bridgeCatchSignals` to `TRUE`.
Copied!
1PROC CAS;
2 fcmpact.addPrototypes
3 routineCode={"proto run_legacy_simulation(int, double) returns int;"},
4 package="LegacySim",
5 bridgeFile="/cas/data/legacy_sim_bridge.c",
6 bridgeCatchSignals=true,
7 funcTable={name="sim_protos", caslib="casuser", replace=true};
8RUN;
9QUIT;
2
Conceptual: Attempt to run the action again targeting a read-only path to test error handling. The status code should be captured and checked.
Copied!
1/* Conceptual Step: This would test error handling if we could make the path read-only. */
2PROC CAS;
3 fcmpact.addPrototypes
4 routineCode={"proto another_func() returns int;"},
5 package="LegacySim",
6 bridgeFile="/read_only_path/another_bridge.c",
7 funcTable={name="sim_protos_fail", caslib="casuser", replace=true} STATUS=rc;
8RUN;
9 PRINT rc;
10QUIT;

Expected Result


Step 1 should successfully create the `sim_protos` table and, more importantly, generate a C source file named `legacy_sim_bridge.c` at the specified server path `/cas/data/`. The log should confirm the file creation. The generated C code within that file should contain signal handling logic (e.g., for SIGSEGV) because `bridgeCatchSignals` was true. Step 2 is expected to fail, with the `status` parameter `rc` containing a non-zero error code and the log detailing a file system or permission error, proving the action's error handling robustness.