(returnExpression)
| 304 | }); |
| 305 | |
| 306 | function assertInvalidCallbackReturnAborts(returnExpression) { |
| 307 | const { stderr, status, signal } = spawnSync(process.execPath, [ |
| 308 | '--experimental-ffi', |
| 309 | '-e', |
| 310 | `'use strict'; |
| 311 | const ffi = require('node:ffi'); |
| 312 | const { fixtureSymbols, libraryPath } = require(${JSON.stringify(require.resolve('./ffi-test-common'))}); |
| 313 | const { lib, functions } = ffi.dlopen(libraryPath, fixtureSymbols); |
| 314 | const callback = lib.registerCallback( |
| 315 | { arguments: ['i32'], return: 'i32' }, |
| 316 | () => (${returnExpression}), |
| 317 | ); |
| 318 | functions.call_int_callback(callback, 21);`, |
| 319 | ], { |
| 320 | encoding: 'utf8', |
| 321 | }); |
| 322 | |
| 323 | assert.ok(common.nodeProcessAborted(status, signal), |
| 324 | `status: ${status}, signal: ${signal} |
| 325 | stderr: ${stderr}`); |
| 326 | assert.match(stderr, /Callback returned invalid value for declared FFI type/); |
| 327 | } |
| 328 | |
| 329 | function assertInvalidCallbackBehaviorAborts(callbackBody, message) { |
| 330 | const { stderr, status, signal } = spawnSync(process.execPath, [ |
no test coverage detected
searching dependent graphs…