11cb0ef41Sopenharmony_ciimport '../common/index.mjs'; 21cb0ef41Sopenharmony_ciimport assert from 'assert'; 31cb0ef41Sopenharmony_ciimport { fork } from 'child_process'; 41cb0ef41Sopenharmony_ciimport { once } from 'events'; 51cb0ef41Sopenharmony_ciimport { fileURLToPath } from 'url'; 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciif (process.argv[2] !== 'child') { 81cb0ef41Sopenharmony_ci const filename = fileURLToPath(import.meta.url); 91cb0ef41Sopenharmony_ci const cp = fork(filename, ['child']); 101cb0ef41Sopenharmony_ci const message = 'Hello World'; 111cb0ef41Sopenharmony_ci cp.send(message); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci const [received] = await once(cp, 'message'); 141cb0ef41Sopenharmony_ci assert.deepStrictEqual(received, message); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci cp.disconnect(); 171cb0ef41Sopenharmony_ci await once(cp, 'exit'); 181cb0ef41Sopenharmony_ci} else { 191cb0ef41Sopenharmony_ci process.on('message', (msg) => process.send(msg)); 201cb0ef41Sopenharmony_ci} 21