11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci// Test exec() when a timeout is set, but not expired.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst common = require('../common');
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ciconst cp = require('child_process');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst {
101cb0ef41Sopenharmony_ci  cleanupStaleProcess,
111cb0ef41Sopenharmony_ci  logAfterTime
121cb0ef41Sopenharmony_ci} = require('../common/child_process');
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciconst kTimeoutNotSupposedToExpire = 2 ** 30;
151cb0ef41Sopenharmony_ciconst childRunTime = common.platformTimeout(100);
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci// The time spent in the child should be smaller than the timeout below.
181cb0ef41Sopenharmony_ciassert(childRunTime < kTimeoutNotSupposedToExpire);
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ciif (process.argv[2] === 'child') {
211cb0ef41Sopenharmony_ci  logAfterTime(childRunTime);
221cb0ef41Sopenharmony_ci  return;
231cb0ef41Sopenharmony_ci}
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ciconst cmd = `"${process.execPath}" "${__filename}" child`;
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_cicp.exec(cmd, {
281cb0ef41Sopenharmony_ci  timeout: kTimeoutNotSupposedToExpire
291cb0ef41Sopenharmony_ci}, common.mustSucceed((stdout, stderr) => {
301cb0ef41Sopenharmony_ci  assert.strictEqual(stdout.trim(), 'child stdout');
311cb0ef41Sopenharmony_ci  assert.strictEqual(stderr.trim(), 'child stderr');
321cb0ef41Sopenharmony_ci}));
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_cicleanupStaleProcess(__filename);
35