reset.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. screen_dummy: true,
  19. };
  20. const emulator = new V86(config);
  21. let did_restart = false;
  22. let serial_text = "";
  23. emulator.add_listener("serial0-output-byte", function(byte)
  24. {
  25. var chr = String.fromCharCode(byte);
  26. serial_text += chr;
  27. if(serial_text.includes("Files send via emulator appear in /mnt/")) {
  28. serial_text = "";
  29. if(did_restart) {
  30. console.log("Ok");
  31. emulator.stop();
  32. }
  33. else {
  34. console.log("Calling restart()");
  35. emulator.restart();
  36. did_restart = true;
  37. }
  38. }
  39. });