v86/tests/api/state.js

68 lines
2 KiB
JavaScript
Raw Normal View History

2018-05-07 20:46:23 +02:00
#!/usr/bin/env node
"use strict";
process.on("unhandledRejection", exn => { throw exn; });
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
var V86 = require(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.js`).V86;
2021-01-01 02:14:30 +01:00
const assert = require("assert").strict;
2018-05-07 20:46:23 +02:00
var fs = require("fs");
const config_async_cdrom = {
2018-05-07 20:46:23 +02:00
bios: { url: __dirname + "/../../bios/seabios.bin" },
vga_bios: { url: __dirname + "/../../bios/vgabios.bin" },
cdrom: { url: __dirname + "/../../images/linux3.iso", async: true },
2018-05-07 20:46:23 +02:00
autostart: true,
memory_size: 32 * 1024 * 1024,
filesystem: {},
log_level: 0,
};
2018-05-07 20:46:23 +02:00
const config_sync_cdrom = {
bios: { url: __dirname + "/../../bios/seabios.bin" },
vga_bios: { url: __dirname + "/../../bios/vgabios.bin" },
cdrom: { url: __dirname + "/../../images/linux3.iso", async: false },
autostart: true,
memory_size: 32 * 1024 * 1024,
filesystem: {},
log_level: 0,
};
function run_test(name, config, done)
{
const emulator = new V86(config);
setTimeout(function()
{
console.log("Saving: %s", name);
emulator.save_state(function(error, state)
{
2018-07-23 21:32:38 +02:00
if(error)
{
console.error(error);
2021-01-01 02:14:30 +01:00
assert(false);
2018-07-23 21:32:38 +02:00
}
setTimeout(function()
{
console.log("Restoring: %s", name);
emulator.restore_state(state);
setTimeout(function()
{
console.log("Done: %s", name);
emulator.stop();
done();
}, 1000);
}, 1000);
});
2018-07-24 21:02:16 +02:00
}, 5000);
}
run_test("async cdrom", config_async_cdrom, function()
2018-05-07 20:46:23 +02:00
{
2018-07-19 01:32:51 +02:00
// XXX: Fails currently
//run_test("sync cdrom", config_sync_cdrom, function() {});
});