mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
Migrate the remaining SEA tests away from postject. This routes ELF generation through --build-sea, which keeps PT_LOAD segments on separate pages for compatibility with RHEL 8 kernels. Assisted-by: Codex Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: https://github.com/nodejs/node/pull/65553 Refs: https://github.com/nodejs/build/issues/4433 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
'use strict';
|
|
// This tests that SEA can load addons packaged as assets by writing them to disk
|
|
// and loading them via process.dlopen().
|
|
const common = require('../../common');
|
|
const { buildSEA, skipIfBuildSEAIsNotSupported } = require('../../common/sea');
|
|
|
|
skipIfBuildSEAIsNotSupported();
|
|
|
|
const tmpdir = require('../../common/tmpdir');
|
|
const { copyFileSync, rmSync, cpSync } = require('fs');
|
|
const {
|
|
spawnSyncAndAssert,
|
|
} = require('../../common/child_process');
|
|
const { join } = require('path');
|
|
const fixtures = require('../../common/fixtures');
|
|
|
|
const addonPath = join(__dirname, 'build', common.buildType, 'binding.node');
|
|
const copiedAddonPath = tmpdir.resolve('binding.node');
|
|
|
|
tmpdir.refresh();
|
|
|
|
// Copy fixture files to working directory.
|
|
const fixtureDir = fixtures.path('sea', 'addon');
|
|
cpSync(fixtureDir, tmpdir.path, { recursive: true });
|
|
|
|
// Copy the built addon to working directory.
|
|
copyFileSync(addonPath, copiedAddonPath);
|
|
|
|
// Generate the SEA using the working directory directly (skip copy).
|
|
const outputFile = buildSEA(tmpdir.path);
|
|
|
|
// Remove the copied addon after it's been packaged into the SEA blob.
|
|
rmSync(copiedAddonPath, { force: true });
|
|
|
|
spawnSyncAndAssert(
|
|
outputFile,
|
|
[],
|
|
{
|
|
env: {
|
|
...process.env,
|
|
NODE_DEBUG_NATIVE: 'SEA',
|
|
},
|
|
cwd: tmpdir.path,
|
|
},
|
|
{
|
|
stdout: /hello, world/,
|
|
},
|
|
);
|