-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Node.js test program to work as expected
- Loading branch information
Showing
1 changed file
with
21 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,44 @@ | ||
from dmoj.executors.script_executor import ScriptExecutor | ||
from dmoj.cptbox.filesystem_policies import ExactFile | ||
|
||
|
||
class Executor(ScriptExecutor): | ||
ext = 'js' | ||
command = 'node' | ||
nproc = -1 | ||
command_paths = ['node', 'nodejs'] | ||
syscalls = [ | ||
# Start syscalls copied from COFFEE.py | ||
'capget', | ||
'eventfd2', | ||
'newselect', | ||
'sched_yield', | ||
'select', | ||
'setrlimit', | ||
'statx', | ||
# End syscalls copied from COFFEE.py | ||
|
||
# Without this, we get | ||
# > Protection fault on: 425 (sys_io_uring_setup) | ||
'io_uring_setup', | ||
# Without this, when running an actual test case (though not the | ||
# self-test), we get | ||
# > RTE (shutdown syscall disallowed) | ||
'shutdown' | ||
] | ||
address_grace = 1048576 | ||
test_program = """ | ||
process.stdin.resume(); | ||
process.stdin.setEncoding('utf-8'); | ||
let inputString = ''; | ||
process.stdin.on('data', function(inputStdin) { | ||
inputString += inputStdin; | ||
}); | ||
process.stdin.on('end', function() { | ||
process.stdout.write(inputString); | ||
process.stdin.on('readable', () => { | ||
const chunk = process.stdin.read(); | ||
if (chunk != null) { | ||
process.stdout.write(chunk); | ||
} | ||
}); | ||
""" | ||
|
||
def get_fs(self): | ||
return super().get_fs() + [ExactFile('/usr/lib/ssl/openssl.cnf')] | ||
|
||
@classmethod | ||
def get_version_flags(cls, command): | ||
return ['--version'] |