reset.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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/linux3.iso", async: true },
  12. network_relay_url: "<UNUSED>",
  13. autostart: true,
  14. memory_size: 32 * 1024 * 1024,
  15. filesystem: {},
  16. log_level: 0,
  17. screen_dummy: true,
  18. };
  19. const emulator = new V86(config);
  20. let did_restart = false;
  21. let serial_text = "";
  22. emulator.add_listener("serial0-output-char", function(chr)
  23. {
  24. serial_text += chr;
  25. if(serial_text.includes("Files send via emulator appear in /mnt/")) {
  26. serial_text = "";
  27. if(did_restart) {
  28. console.log("Ok");
  29. emulator.stop();
  30. }
  31. else {
  32. console.log("Calling restart()");
  33. emulator.restart();
  34. did_restart = true;
  35. }
  36. }
  37. });