Commit Graph

27 Commits

Author SHA1 Message Date
Joyee Cheung
77fabfb2ab
cli: allow running wasm in limited vmem with --disable-wasm-trap-handler
By default, Node.js enables trap-handler-based WebAssembly bound
checks. As a result, V8 does not need to insert inline bound checks
int the code compiled from WebAssembly which may speedup WebAssembly
execution significantly, but this optimization requires allocating
a big virtual memory cage (currently 10GB). If the Node.js process
does not have access to a large enough virtual memory address space
due to system configurations or hardware limitations, users won't
be able to run any WebAssembly that involves allocation in this
virtual memory cage and will see an out-of-memory error.

```console
$ ulimit -v 5000000
$ node -p "new WebAssembly.Memory({ initial: 10, maximum: 100 });"
[eval]:1
new WebAssembly.Memory({ initial: 10, maximum: 100 });
^

RangeError: WebAssembly.Memory(): could not allocate memory
    at [eval]:1:1
    at runScriptInThisContext (node:internal/vm:209:10)
    at node:internal/process/execution:118:14
    at [eval]-wrapper:6:24
    at runScript (node:internal/process/execution:101:62)
    at evalScript (node:internal/process/execution:136:3)
    at node:internal/main/eval_string:49:3

```

`--disable-wasm-trap-handler` disables this optimization so that
users can at least run WebAssembly (with a less optimial performance)
when the virtual memory address space available to their Node.js
process is lower than what the V8 WebAssembly memory cage needs.

PR-URL: https://github.com/nodejs/node/pull/52766
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2024-05-10 16:32:34 +08:00
Michaël Zasso
a4e075f668
test: fix test runner for Python 3 on Windows
Explicitly open files with utf8 encoding, otherwise the system could use
another encoding such as latin1 by default.

PR-URL: https://github.com/nodejs/node/pull/30023
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-10-20 16:06:39 +02:00
Refael Ackermann
1fc4255221 tools: python: ignore instead of select flake8 rules
PR-URL: https://github.com/nodejs/node/pull/25614
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2019-04-13 20:33:06 -04:00
Rich Trott
bcea74f976 test: remove Files: comment processing from Python test runner
We don't use any Files: comments in our tests so remove the Python code
for it from test/testpy/__init__.py.

PR-URL: https://github.com/nodejs/node/pull/25183
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-12-23 09:46:14 -08:00
Daniel Bevenius
a361b94b78 build: add a space to clarify skipping crypto msg
This commit adds a space to the message that is displayed for tests that
are skipped when node was built --without-ssl. For example, this is what
is currently displayed:
"release test-https-agent-additional-optionsSkipping as node was
compiled without crypto support"

After this change this will be:
"release test-https-agent-additional-options: Skipping as node was
compiled without crypto support"

PR-URL: https://github.com/nodejs/node/pull/25011
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-12-17 10:35:24 +01:00
cclauss
7ee61fb3e5 test: from functools import reduce in test/testpy/__init__.py
$ __make lint-py__  # When run on Python 3
```
PYTHONPATH=tools/pip python -m flake8 . \
		--count --show-source --statistics --select=E901,E999,F821,F822,F823 \
		--exclude=.git,deps,lib,src,tools/*_macros.py,tools/gyp,tools/inspector_protocol,tools/jinja2,tools/markupsafe,tools/pip
./test/testpy/__init__.py:119:37: F821 undefined name 'reduce'
        file_path = join(self.root, reduce(join, test[1:], ""))
                                    ^
./test/testpy/__init__.py:161:37: F821 undefined name 'reduce'
        file_path = join(self.root, reduce(join, test[1:], "") + ".js")
                                    ^
2     F821 undefined name 'reduce'
2
make: *** [lint-py] Error 1
```

PR-URL: https://github.com/nodejs/node/pull/24954
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-12-13 17:20:12 -08:00
Daniel Bevenius
23e692813f test: skip test that use --tls-v1.x flags
Currently, configuring --without-ssl will cause the following test to
fail:

=== release test-https-agent-additional-options ===
Path: parallel/test-https-agent-additional-options
out/Release/node: bad option: --tls-v1.1
Command: out/Release/node --tls-v1.1
  /node/test/parallel/test-https-agent-additional-options.js

=== release test-https-agent-session-eviction ===
Path: parallel/test-https-agent-session-eviction
out/Release/node: bad option: --tls-v1.0

Command: out/Release/node --tls-v1.0
  /node/test/parallel/test-https-agent-session-eviction.js

This commit adds a check for the --tls-v.x flags and skips them if node
was built without crypto support.

PR-URL: https://github.com/nodejs/node/pull/24376
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
2018-11-18 13:26:08 +01:00
Refael Ackermann
ec4f70e59a tools,test: cleanup and dedup code
* Hoist common code to base class
  (`GetTestStatus`, and the `section` property to `TestConfiguration`)
* Replace ListSet with the built in set
* Remove ClassifiedTest
* Inline PrintReport
* How cases_to_run are filtered

PR-URL: https://github.com/nodejs/node/pull/23251
Reviewed-By: Rich Trott <rtrott@gmail.com>
2018-10-16 11:09:53 -04:00
Jon Moss
3a056c0409 test: remove custom AsyncHooksTestConfiguration
Has the same behavior as `ParallelTestConfiguration`

PR-URL: https://github.com/nodejs/node/pull/22008
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-07-30 23:50:17 -04:00
Rich Trott
3674bee884 test: simplify common.PORT code
common.PORT is no longer used in parallelized tests and should not be.
Remove code that accommodates parallelized tests.

PR-URL: https://github.com/nodejs/node/pull/17559
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-12-11 19:49:30 -08:00
Bradley Farias
c8a389e19f module: Allow runMain to be ESM
This follows the EPS an allows the node CLI to have ESM as an entry point.
`node ./example.mjs`. A newer V8 is needed for `import()` so that is not
included. `import.meta` is still in specification stage so that also is not
included.

PR-URL: https://github.com/nodejs/node/pull/14369
Author: Bradley Farias <bradley.meck@gmail.com>
Author: Guy Bedford <guybedford@gmail.com>
Author: Jan Krems <jan.krems@groupon.com>
Author: Timothy Gu <timothygu99@gmail.com>
Author: Michaël Zasso <targos@protonmail.com>
Author: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2017-09-07 15:18:32 -05:00
Rich Trott
70c775a810 test: run abort tests
Currently, tests in test/abort do not run in CI.

This change configures the test runner to not write core files for abort
tests and to run them.

PR-URL: https://github.com/nodejs/node/pull/14013
Fixes: https://github.com/nodejs/node/issues/14012
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2017-08-26 16:30:35 -07:00
Thorsten Lorenz
e3e56f1d71
test: adding tests for initHooks API
Async wrap providers tested:

- crypto.randomBytes
- crypto.pbkdf2
- fs event wrap
- fsreqwrap access
- fsreqwrap readFile
- getaddrinforeq wrap
- getnameinforeq wrap
- pipe connect wrap
- query wrap
- pipewrap
- processwrap
- shutdown wrap
- tcpwrap
- udpwrap
- send wrap
- detailed signal wrap
- statwatcher
- timerwrap via setTimeout
- timerwrap via setInterval
- for Immediate
- http parser request
- http parser response
- connection via ssl server
- tls wrap
- write wrap
- ttywrap via readstream
- ttywrap via wriream
- zctx via zlib binding deflate

Embedder API:

-  async-event tests
  - one test looks at the happy paths
  - another ensures that in cases of events emitted in an order that
  doesn't make sense, the order is enforced by async hooks throwing a
  meaningful error
  - embedder enforcement tests are split up since async hook stack
  corruption now the process
  - therefore we launch a child and check for error output of the offending code

Additional tests:

- tests that show that we can enable/disable hooks inside their lifetime
events
- tests that verify the graph of resources triggering the creation of
other resources

Test Helpers:

- init-hooks:
  - returns one collector instance
  - when created an async hook is created and the lifetime events are
  registered to call the appropriate collector functions
  - the collector also exposes `enable` and `disable` functions which call
  through to the async hook

- hook checks:
  - checks invocations of life time hooks against the actual invocations
  that were collected
  - in some cases like `destroy` a min/max range of invocations can be
  supplied since in these cases the exact number is non-deterministic

- verify graph:
  - verifies the triggerIds of specific async resources are as expected,
  i.e. the creation of resources was triggered by the resource we expect
  - includes a printGraph function to generate easily readable test
  input for verify graph
  - both functions prune TickObjects to create less brittle and easier
  to understand tests

PR-URL: https://github.com/nodejs/node/pull/12892
Ref: https://github.com/nodejs/node/pull/11883
Ref: https://github.com/nodejs/node/pull/8531
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2017-05-10 22:22:33 +02:00
Rich Trott
dc4313c620 test: remove unused testpy code
The temporary directory for tests is managed in the JS `common` module.
Remove unused variable from `testpy` that is legacy from when it was
managed in the Python test harness.

PR-URL: https://github.com/nodejs/node/pull/12844
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Cai <davidcai1993@yahoo.com>
2017-05-08 13:14:35 -07:00
Rich Trott
ff001c12b0 test: move WPT to its own testing module
This is first in a hoped-for series of moves away from a monolithic
common.js that is loaded for every test and towards a more modular
approach. (In the end, common.js will hopefully contain checks for
variables leaking into the global space and perhaps some of the more
ubiquitous functions like common.mustCall().)

Move the WPT testing code to its own module.

PR-URL: https://github.com/nodejs/node/pull/12736
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2017-05-03 17:00:31 -07:00
Daniel Bevenius
f3f9dd73aa test: skip tests using ca flags
Currently when building --without-ssl there is a failure due to a change
made by me in commit 3cf88a45e8 ("test:
add --use-bundled-ca to tls-cnnic-whitelist") which added a
'--use-bundled-ca' flag to that test. But when building --without-ssl
that flag will be invalid and an error (bad option)  will be reported.

This commit filters tests that specify the --use-bundled-ca or
--use-openssl-ca flags so that they are skipped when configured
--without-ssl.

PR-URL: https://github.com/nodejs/node/pull/12485
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-04-20 09:39:59 +02:00
Jason Ginchereau
56e881d0b0
n-api: add support for abi stable module API
Add support for abi stable module API (N-API) as "Experimental feature".
The goal of this API is to provide a stable Node API for native
module developers. N-API aims to provide ABI compatibility guarantees
across different Node versions and also across different
Node VMs - allowing N-API enabled native modules to just work
across different versions and flavors of Node.js without recompilation.

A more detailed introduction is provided in:
https://github.com/nodejs/node-eps/blob/master/005-ABI-Stable-Module-API.md
and https://github.com/nodejs/abi-stable-node/blob/doc/VM%20Summit.pdf.

The feature, during its experimental state, will be guarded by a runtime
flag "--napi-modules". Only when this flag is added to the command line
will N-API modules along with regular non N-API modules be supported.

The API is defined by the methods in "src/node_api.h" and
"src/node_api_types.h". This is the best
starting point to review the API surface. More documentation will follow.

In addition to the implementation of the API using V8, which is included
in this PR, the API has also been validated against chakracore and that
port is available in
https://github.com/nodejs/abi-stable-node/tree/api-prototype-chakracore-8.x.

The current plan is to provide N-API support in versions 8.X and 6.X
directly. For older versions, such as 4.X or pre N-API versions of 6.X,
we plan to create an external npm module to provide a migration path
that will allow modules targeting older Node.js versions to use the API,
albeit without getting the advantage of not having to recompile.

In addition, we also plan an external npm package with C++ sugar to
simplify the use of the API. The sugar will be in-line only and will
only use the exported N-API methods but is not part of the N-API
itself. The current version is in:
https://github.com/nodejs/node-api.

This PR is a result of work in the abi-stable-node repo:
https://github.com/nodejs/abi-stable-node/tree/doc,
with this PR being the cumulative work on the api-prototype-8.x
branch with the following contributors in alphabetical order:

Author: Arunesh Chandra <arunesh.chandra@microsoft.com>
Author: Gabriel Schulhof <gabriel.schulhof@intel.com>
Author: Hitesh Kanwathirtha <hiteshk@microsoft.com>
Author: Ian Halliday <ianhall@microsoft.com>
Author: Jason Ginchereau <jasongin@microsoft.com>
Author: Michael Dawson <michael_dawson@ca.ibm.com>
Author: Sampson Gao <sampsong@ca.ibm.com>
Author: Taylor Woll <taylor.woll@microsoft.com>
PR-URL: https://github.com/nodejs/node/pull/11975
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-04-03 10:31:25 +02:00
Daniel Bevenius
1402fef098 test: make tests pass when configured without-ssl
Currently when node is build --without-ssl and the test are run,
there are a number of failing test due to tests expecting crypto
support to be available. This commit fixes fixes the failure and
instead skips the tests that expect crypto to be available.

PR-URL: https://github.com/nodejs/node/pull/11631
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-03-04 20:16:52 +01:00
Ben Noordhuis
782620f03f src: add /json/protocol endpoint to inspector
Embed the compressed and minified protocol.json from the bundled
v8_inspector and make it available through the /json/protocol endpoint.

Refs: https://github.com/nodejs/diagnostics/issues/52
PR-URL: https://github.com/nodejs/node/pull/7491
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-09-23 18:51:47 +02:00
Sakthipriyan Vairamani
89ede72fca tools: remove unnecessary imports and assignments
PR-URL: https://github.com/nodejs/node/pull/7483
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2016-07-08 20:17:08 +05:30
Sakthipriyan Vairamani
52f84add77 test: fix default value for additional param
In Python, the default values of parameters are evaluated only once
during their declaration. So, whenever the default parameter is used
the same object will be used. Since we use a list, which is a mutable
object, this could lead to unexpected results.

PR-URL: https://github.com/nodejs/node/pull/2553
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-09-15 19:59:38 +05:30
Rich Trott
a6b8ee19b8 test: create temp dir in common.js
Move creation of temporary directories for tests
out of the Python harness and into common.js. This
allows all tests to be run reliably outside of the
Python wrapper.

PR-URL: https://github.com/nodejs/io.js/pull/1877
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-06-12 10:27:29 +10:00
Ben Noordhuis
dd260d2152 test: fix make test-addons target
I broke the python script in commit edaf7af but because test-all does
not run test-addons, it slipped under the radar.  Mea culpa.

Fixes the following test runner error:

    Traceback (most recent call last):
      File "tools/test.py", line 1522, in <module>
        sys.exit(Main())
      File "tools/test.py", line 1454, in Main
        test_list = root.ListTests([], path, context, arch, mode)
      File "tools/test.py", line 720, in ListTests
        test.AddTestsToList(result, full_path, path, context, arch, mode)
      File "tools/test.py", line 690, in AddTestsToList
        arch, mode)
      File "/home/bnoordhuis/src/v1.x/test/gc/../testpy/__init__.py", line 176, in ListTests
        result.append(SimpleTestCase(test, file_path, mode, self.context, self))
    TypeError: __init__() takes at least 7 arguments (6 given)

PR-URL: https://github.com/iojs/io.js/pull/313
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-01-12 23:21:51 +01:00
Fedor Indutny
b7d247856e test: run tests in parallel, common improvements
* Allow running tests in mixed parallel/sequential modes
* Add -J flag for running tests on all available CPUs
* Support TEST_THREAD_ID in test/common.js and use it for tmpDir and PORT
* make: use -J flag

Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: https://github.com/iojs/io.js/pull/172
Fix: iojs/io.js#139
2014-12-17 20:45:37 +07:00
Ben Noordhuis
edaf7af30b test: make test runner multi-arch/mode compatible
Make `python tools/test.py --arch=ia32,x64 --mode=debug,release` work.
The test runner looks for the `node` binary in `out/${arch}.${mode}/`.

Running tools/test.py without --arch makes it use `out/Release/node` or
`out/Debug/node` like before.

This commit removes `test/simple/test-executable-path.js` because the
assumptions it makes about the locations of the debug and release
binaries are now outdated.

PR-URL: https://github.com/node-forward/node/pull/24
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-10-16 22:39:34 +02:00
Fedor Indutny
1442c1c6de addons: build and test examples
fix #6910
2014-01-22 00:39:13 +04:00
Timothy J Fontaine
6cc95b06ea test: refactor to use common testcfg 2014-01-20 09:00:13 -08:00