clean-shutdown.js 968 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env node
  2. "use strict";
  3. // This test checks that calling emulator.stop() will remove all event
  4. // listeners, so that the nodejs process cleanly and automatically exits.
  5. const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
  6. const fs = require("fs");
  7. var V86 = require(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.js`).V86;
  8. process.on("unhandledRejection", exn => { throw exn; });
  9. const config = {
  10. bios: { url: __dirname + "/../../bios/seabios.bin" },
  11. vga_bios: { url: __dirname + "/../../bios/vgabios.bin" },
  12. cdrom: { url: __dirname + "/../../images/linux4.iso", async: true },
  13. network_relay_url: "<UNUSED>",
  14. autostart: true,
  15. memory_size: 32 * 1024 * 1024,
  16. filesystem: {},
  17. log_level: 0,
  18. screen_dummy: true,
  19. };
  20. const emulator = new V86(config);
  21. setTimeout(function()
  22. {
  23. console.error("Calling stop()");
  24. emulator.stop();
  25. console.error("Called stop()");
  26. }, 3000);