Update testloader.js

This commit is contained in:
Namhyeon Go 2024-01-04 16:14:13 +09:00
parent 7f9840f765
commit f0504e12ec

View File

@ -889,23 +889,31 @@ var test_implements = {
"sharedmemory_listener": function() { "sharedmemory_listener": function() {
var Toolkit = require("lib/toolkit"); var Toolkit = require("lib/toolkit");
var mem; var targets = (function() {
var memName = Toolkit.prompt("Input the shared memory name"); var s = Toolkit.prompt("Input the shared memory names (Comma seperated)");
return s.split(',');
})();
if (!memName) { if (!targets) {
console.log("Aborted."); console.log("Aborted.");
} else { } else {
// Open the shared memory // Open the shared memory
mem = new Toolkit.NamedSharedMemory(memName); var memories = targets.map(function(x) {
return [x, new Toolkit.NamedSharedMemory(x)];
});
// Open the second process will be communicate // Open the second process will be communicate
Toolkit.openProcess(); Toolkit.openProcess();
// Listen the shared memory // Listen the shared memory
console.log("Listening the shared memory:", memName); console.log("Listening the shared memory:", targets.join(', '));
while (true) { while (true) {
var message = mem.readText(memName); console.log(new Date().toISOString());
console.log(memName + ": ", message); memories.forEach(function(x) {
var name = x[0];
var mem = x[1];
console.log(name + ": ", mem.readText());
});
sleep(100); sleep(100);
} }
} }