11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciif (common.isWindows)
41cb0ef41Sopenharmony_ci  common.skip('symlinks are weird on windows');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ciconst child_process = require('child_process');
81cb0ef41Sopenharmony_ciconst path = require('path');
91cb0ef41Sopenharmony_ciconst fs = require('fs');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciassert.strictEqual(process.execPath, fs.realpathSync(process.execPath));
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciif (process.argv[2] === 'child') {
141cb0ef41Sopenharmony_ci  // The console.log() output is part of the test here.
151cb0ef41Sopenharmony_ci  console.log(process.execPath);
161cb0ef41Sopenharmony_ci} else {
171cb0ef41Sopenharmony_ci  const tmpdir = require('../common/tmpdir');
181cb0ef41Sopenharmony_ci  tmpdir.refresh();
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci  const symlinkedNode = path.join(tmpdir.path, 'symlinked-node');
211cb0ef41Sopenharmony_ci  fs.symlinkSync(process.execPath, symlinkedNode);
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ci  const proc = child_process.spawnSync(symlinkedNode, [__filename, 'child']);
241cb0ef41Sopenharmony_ci  assert.strictEqual(proc.stderr.toString(), '');
251cb0ef41Sopenharmony_ci  assert.strictEqual(proc.stdout.toString(), `${process.execPath}\n`);
261cb0ef41Sopenharmony_ci  assert.strictEqual(proc.status, 0);
271cb0ef41Sopenharmony_ci}
28