-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset.js
executable file
·47 lines (38 loc) · 1.22 KB
/
reset.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env node
"use strict";
// This test checks that reset works
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const fs = require("fs");
var V86 = require(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.js`).V86;
process.on("unhandledRejection", exn => { throw exn; });
const config = {
bios: { url: __dirname + "/../../bios/seabios.bin" },
vga_bios: { url: __dirname + "/../../bios/vgabios.bin" },
cdrom: { url: __dirname + "/../../images/linux4.iso", async: true },
network_relay_url: "<UNUSED>",
autostart: true,
memory_size: 32 * 1024 * 1024,
filesystem: {},
log_level: 0,
disable_jit: +process.env.DISABLE_JIT,
};
const emulator = new V86(config);
let did_restart = false;
let serial_text = "";
emulator.add_listener("serial0-output-byte", function(byte)
{
var chr = String.fromCharCode(byte);
serial_text += chr;
if(serial_text.includes("Files send via emulator appear in /mnt/")) {
serial_text = "";
if(did_restart) {
console.log("Ok");
emulator.stop();
}
else {
console.log("Calling restart()");
emulator.restart();
did_restart = true;
}
}
});