Skip to content

Commit

Permalink
test: run test-abort-aliased-buffer-overflow
Browse files Browse the repository at this point in the history
#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]>
  • Loading branch information
richardlau committed Apr 3, 2020
1 parent 7947811 commit 388c9b5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
2 changes: 2 additions & 0 deletions test/abort/test_abort-aliased-buffer-overflow/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ void init(v8::Local<v8::Object> exports) {
"allocateAndResizeBuffer",
AllocateAndResizeBuffer);
}

NODE_MODULE(NODE_GYP_MODULE_NAME, init)
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';
const common = require('../common');
const common = require('../../common');
const assert = require('assert');
const cp = require('child_process');
const debuglog = require('util').debuglog('test');

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

const bigValue = BigInt('0xE000 0000 E000 0000');
binding.AllocateAndResizeBuffer(bigValue);
const bigValue = BigInt('0xE0000000E0000000');
binding.allocateAndResizeBuffer(bigValue);
assert.fail('this should be unreachable');
} else {
// observer
const child = cp.spawn(`${process.execPath}`, [`${__filename}`, 'child']);
let stderr = '';
let stdout = '';
child.stderr.setEncoding('utf8');
child.stdout.setEncoding('utf8');
child.stderr.on('data', (data) => stderr += data);
child.stdout.on('data', (data) => stdout += data);
child.on('exit', common.mustCall(function(code, signal) {
if (common.isWindows) {
assert.strictEqual(code, 134);
assert.strictEqual(signal, null);
} else {
assert.strictEqual(code, null);
assert.strictEqual(signal, 'SIGABRT');
}
debuglog(`exit with code ${code}, signal ${signal}`);
debuglog(stdout);
debuglog(stderr);
assert.ok(common.nodeProcessAborted(code, signal));
}));
}
4 changes: 3 additions & 1 deletion test/testpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ def SelectTest(name):
for f in os.listdir(os.path.join(path, subpath)):
if SelectTest(f):
result.append([subpath, f[:-3]])
elif SelectTest(subpath):
result.append([subpath[:-3]])
return result

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

class AbortTestConfiguration(SimpleTestConfiguration):
class AbortTestConfiguration(AddonTestConfiguration):
def __init__(self, context, root, section, additional=None):
super(AbortTestConfiguration, self).__init__(context, root, section,
additional)
Expand Down
1 change: 1 addition & 0 deletions tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,7 @@ def PrintCrashed(code):
# default JavaScript test-run, e.g., internet/ requires a network connection,
# addons/ requires compilation.
IGNORED_SUITES = [
'abort',
'addons',
'benchmark',
'doctool',
Expand Down
2 changes: 1 addition & 1 deletion vcbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ if /i "%1"=="noetw" set noetw=1&goto arg-ok
if /i "%1"=="ltcg" set ltcg=1&goto arg-ok
if /i "%1"=="licensertf" set licensertf=1&goto arg-ok
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
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
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
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
if /i "%1"=="build-addons" set build_addons=1&goto arg-ok
if /i "%1"=="build-js-native-api-tests" set build_js_native_api_tests=1&goto arg-ok
Expand Down

0 comments on commit 388c9b5

Please sign in to comment.