Skip to content

Commit 388c9b5

Browse files
committed
test: run test-abort-aliased-buffer-overflow
nodejs#31740 added an addon-style test to `test/abort` that was never run because `test/abort/testcfg.py` uses the AbortTestConfiguration which inherits from SimpleTestConfiguration which only finds tests in the root of `test/abort`. Make AbortTestConfiguration inherit from AddonTestConfiguration and change AddonTestConfiguration to find the tests in the root of the test bucket in addition to the subfolders. Fixup `test-abort-aliased-buffer-overflow` so that it works as intended. Signed-off-by: Richard Lau <[email protected]>
1 parent 7947811 commit 388c9b5

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

test/abort/test_abort-aliased-buffer-overflow/binding.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ void init(v8::Local<v8::Object> exports) {
2121
"allocateAndResizeBuffer",
2222
AllocateAndResizeBuffer);
2323
}
24+
25+
NODE_MODULE(NODE_GYP_MODULE_NAME, init)
Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
2-
const common = require('../common');
2+
const common = require('../../common');
33
const assert = require('assert');
44
const cp = require('child_process');
5+
const debuglog = require('util').debuglog('test');
56

67
// This test ensures that during resizing of an Aliased*Array the computation
78
// of the new size does not overflow.
@@ -10,19 +11,22 @@ if (process.argv[2] === 'child') {
1011
// test
1112
const binding = require(`./build/${common.buildType}/binding`);
1213

13-
const bigValue = BigInt('0xE000 0000 E000 0000');
14-
binding.AllocateAndResizeBuffer(bigValue);
14+
const bigValue = BigInt('0xE0000000E0000000');
15+
binding.allocateAndResizeBuffer(bigValue);
1516
assert.fail('this should be unreachable');
1617
} else {
1718
// observer
1819
const child = cp.spawn(`${process.execPath}`, [`${__filename}`, 'child']);
20+
let stderr = '';
21+
let stdout = '';
22+
child.stderr.setEncoding('utf8');
23+
child.stdout.setEncoding('utf8');
24+
child.stderr.on('data', (data) => stderr += data);
25+
child.stdout.on('data', (data) => stdout += data);
1926
child.on('exit', common.mustCall(function(code, signal) {
20-
if (common.isWindows) {
21-
assert.strictEqual(code, 134);
22-
assert.strictEqual(signal, null);
23-
} else {
24-
assert.strictEqual(code, null);
25-
assert.strictEqual(signal, 'SIGABRT');
26-
}
27+
debuglog(`exit with code ${code}, signal ${signal}`);
28+
debuglog(stdout);
29+
debuglog(stderr);
30+
assert.ok(common.nodeProcessAborted(code, signal));
2731
}));
2832
}

test/testpy/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ def SelectTest(name):
144144
for f in os.listdir(os.path.join(path, subpath)):
145145
if SelectTest(f):
146146
result.append([subpath, f[:-3]])
147+
elif SelectTest(subpath):
148+
result.append([subpath[:-3]])
147149
return result
148150

149151
def ListTests(self, current_path, path, arch, mode):
@@ -156,7 +158,7 @@ def ListTests(self, current_path, path, arch, mode):
156158
SimpleTestCase(tst, file_path, arch, mode, self.context, self, self.additional_flags))
157159
return result
158160

159-
class AbortTestConfiguration(SimpleTestConfiguration):
161+
class AbortTestConfiguration(AddonTestConfiguration):
160162
def __init__(self, context, root, section, additional=None):
161163
super(AbortTestConfiguration, self).__init__(context, root, section,
162164
additional)

tools/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,7 @@ def PrintCrashed(code):
14881488
# default JavaScript test-run, e.g., internet/ requires a network connection,
14891489
# addons/ requires compilation.
14901490
IGNORED_SUITES = [
1491+
'abort',
14911492
'addons',
14921493
'benchmark',
14931494
'doctool',

vcbuild.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ if /i "%1"=="noetw" set noetw=1&goto arg-ok
9292
if /i "%1"=="ltcg" set ltcg=1&goto arg-ok
9393
if /i "%1"=="licensertf" set licensertf=1&goto arg-ok
9494
if /i "%1"=="test" set test_args=%test_args% -J %common_test_suites%&set lint_cpp=1&set lint_js=1&set lint_md=1&goto arg-ok
95-
if /i "%1"=="test-ci-native" set test_args=%test_args% %test_ci_args% -J -p tap --logfile test.tap %CI_NATIVE_SUITES% %CI_DOC%&set build_addons=1&set build_js_native_api_tests=1&set build_node_api_tests=1&set cctest_args=%cctest_args% --gtest_output=xml:cctest.junit.xml&goto arg-ok
95+
if /i "%1"=="test-ci-native" set test_args=%test_args% %test_ci_args% -J -p tap --logfile test.tap %CI_NATIVE_SUITES% %CI_DOC%&set build_addons=1&set build_js_native_api_tests=1&set build_node_api_tests=1&set build_abort_tests=1&set cctest_args=%cctest_args% --gtest_output=xml:cctest.junit.xml&goto arg-ok
9696
if /i "%1"=="test-ci-js" set test_args=%test_args% %test_ci_args% -J -p tap --logfile test.tap %CI_JS_SUITES%&set no_cctest=1&goto arg-ok
9797
if /i "%1"=="build-addons" set build_addons=1&goto arg-ok
9898
if /i "%1"=="build-js-native-api-tests" set build_js_native_api_tests=1&goto arg-ok

0 commit comments

Comments
 (0)