reset.js 1.2 KB

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