v86/tests/full/run.js

1249 lines
39 KiB
JavaScript
Raw Normal View History

2015-11-11 04:28:59 +01:00
#!/usr/bin/env node
2015-09-15 19:30:53 +02:00
"use strict";
process.on("unhandledRejection", exn => { throw exn; });
var TIMEOUT_EXTRA_FACTOR = +process.env.TIMEOUT_EXTRA_FACTOR || 1;
var MAX_PARALLEL_TESTS = +process.env.MAX_PARALLEL_TESTS || 4;
2016-09-07 10:02:46 +02:00
var TEST_NAME = process.env.TEST_NAME;
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const RUN_SLOW_TESTS = +process.env.RUN_SLOW_TESTS;
2016-01-03 19:10:13 +01:00
2018-06-11 20:13:46 +02:00
const VERBOSE = false;
const LOG_SCREEN = false;
2016-01-03 19:10:13 +01:00
2015-09-15 19:30:53 +02:00
try
{
var V86 = require(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.js`).V86;
2015-09-15 19:30:53 +02:00
}
catch(e)
{
console.error("Failed to import build/libv86-debug.js. Run `make build/libv86-debug.js first.");
2015-09-15 19:30:53 +02:00
process.exit(1);
}
2021-01-01 02:14:30 +01:00
const assert = require("assert").strict;
2015-12-30 22:36:44 +01:00
var cluster = require("cluster");
var os = require("os");
2015-09-15 19:30:53 +02:00
var fs = require("fs");
var root_path = __dirname + "/../..";
var SCREEN_WIDTH = 80;
2016-08-02 05:13:23 +02:00
function get_line(screen, y)
{
return screen.subarray(y * SCREEN_WIDTH, (y + 1) * SCREEN_WIDTH);
}
2015-09-15 19:30:53 +02:00
function line_to_text(screen, y)
{
2016-08-02 05:13:23 +02:00
return bytearray_to_string(get_line(screen, y));
}
function string_to_bytearray(str)
{
return new Uint8Array(str.split("").map(chr => chr.charCodeAt(0)));
}
function bytearray_to_string(arr)
{
2022-11-23 00:54:34 +01:00
return String.fromCharCode.apply(String, arr).replace(/[\x00-\x08\x0b-\x1f\x7f\x80-\xff]/g, " ");
2015-09-15 19:30:53 +02:00
}
function screen_to_text(s)
{
var result = [];
2016-01-01 23:23:17 +01:00
result.push("+==================================== SCREEN ====================================+");
2015-09-15 19:30:53 +02:00
for(var i = 0; i < 25; i++)
{
var line = line_to_text(s, i);
2016-01-01 23:23:17 +01:00
result.push("|" + line + "|");
2015-09-15 19:30:53 +02:00
}
2016-01-01 23:23:17 +01:00
result.push("+================================================================================+");
2015-09-15 19:30:53 +02:00
return result.join("\n");
}
function send_work_to_worker(worker, message)
{
if(current_test < tests.length)
{
worker.send(tests[current_test]);
current_test++;
}
else
{
worker.disconnect();
}
}
2015-12-30 22:36:44 +01:00
if(cluster.isMaster)
2015-09-15 19:30:53 +02:00
{
2015-12-30 22:36:44 +01:00
var tests = [
{
name: "FreeDOS boot",
fda: root_path + "/images/freedos722.img",
timeout: 20,
2015-12-30 22:36:44 +01:00
expected_texts: [
"Welcome to FreeDOS",
],
},
2016-02-05 14:40:46 +01:00
{
name: "FreeDOS boot with Bochs BIOS",
fda: root_path + "/images/freedos722.img",
timeout: 20,
2016-02-05 14:40:46 +01:00
alternative_bios: true,
expected_texts: [
"Welcome to FreeDOS",
],
},
2015-12-30 22:36:44 +01:00
{
name: "Windows 1.01 boot",
fda: root_path + "/images/windows101.img",
timeout: 10,
expect_graphical_mode: true,
expect_mouse_registered: true,
},
{
name: "Sol OS",
fda: root_path + "/images/os8.img",
2016-02-05 14:40:46 +01:00
timeout: 20,
2015-12-30 22:36:44 +01:00
expect_graphical_mode: true,
expect_mouse_registered: true,
actions: [
{
2016-08-02 05:13:23 +02:00
on_text: " or press",
2015-12-30 22:36:44 +01:00
run: "\n"
},
],
},
2021-03-30 11:35:27 +02:00
{
name: "Snowdrop",
2021-04-05 07:28:42 +02:00
skip_if_disk_image_missing: true,
2021-03-30 11:35:27 +02:00
fda: root_path + "/images/snowdrop.img",
timeout: 30,
expect_graphical_mode: true,
expect_mouse_registered: true,
actions: [
{
on_text: "[Snowdrop OS snowshell]:",
run: "desktop\n"
},
],
},
2015-12-30 22:36:44 +01:00
{
name: "Linux",
cdrom: root_path + "/images/linux.iso",
2016-08-02 05:13:23 +02:00
timeout: 90,
2016-02-05 14:40:46 +01:00
expected_texts: [
"/root%",
"test passed",
],
actions: [
{
on_text: "/root%",
run: "cd tests; ./test-i386 > emu.test; diff emu.test reference.test && echo test pas''sed || echo failed\n",
2016-02-05 14:40:46 +01:00
},
],
},
2022-03-10 21:31:56 +01:00
{
name: "Windows XP CD",
skip_if_disk_image_missing: true,
cdrom: root_path + "/images/experimental/VirtualXP.iso",
memory_size: 512 * 1024 * 1024,
timeout: 600,
expect_graphical_mode: true,
expect_graphical_size: [800, 600],
expect_mouse_registered: true,
},
{
name: "Windows XP HD",
skip_if_disk_image_missing: true,
hda: root_path + "/images/experimental/copy_winxp_lite-from-pixelsuft.img",
memory_size: 512 * 1024 * 1024,
timeout: 300,
expect_graphical_mode: true,
expect_graphical_size: [800, 600],
expect_mouse_registered: true,
},
2021-01-17 02:58:34 +01:00
{
name: "Windows 2000",
skip_if_disk_image_missing: true,
hda: root_path + "/images/windows2k.img",
memory_size: 512 * 1024 * 1024,
timeout: 300,
expect_graphical_mode: true,
expect_graphical_size: [1024, 768],
expect_mouse_registered: true,
},
2022-09-13 08:07:47 +02:00
{
name: "Windows NT 4.0",
skip_if_disk_image_missing: true,
hda: root_path + "/images/winnt4_noacpi.img",
memory_size: 512 * 1024 * 1024,
timeout: 60,
expect_graphical_mode: true,
expect_graphical_size: [1024, 768],
expect_mouse_registered: true,
cpuid_level: 2,
},
{
name: "Windows NT 3.1",
skip_if_disk_image_missing: true,
hda: root_path + "/images/winnt31.img",
memory_size: 256 * 1024 * 1024,
timeout: 60,
expect_graphical_mode: true,
expect_graphical_size: [640, 480],
expect_mouse_registered: true,
},
2017-07-26 15:56:53 +02:00
//{
// name: "Windows 98",
2021-01-01 02:14:34 +01:00
// skip_if_disk_image_missing: true,
2017-07-26 15:56:53 +02:00
// hda: root_path + "/images/windows98.img",
// timeout: 60,
// expect_graphical_mode: true,
// expect_graphical_size: [800, 600],
// expect_mouse_registered: true,
// failure_allowed: true,
2017-07-26 15:56:53 +02:00
//},
2016-02-05 14:40:46 +01:00
{
2021-01-01 02:14:30 +01:00
name: "Windows 95",
2021-01-01 02:14:34 +01:00
skip_if_disk_image_missing: true,
2021-01-01 02:14:30 +01:00
hda: root_path + "/images/w95.img",
2016-09-07 10:02:46 +02:00
timeout: 60,
2016-08-04 19:47:19 +02:00
expect_graphical_mode: true,
2021-01-01 02:14:30 +01:00
expect_graphical_size: [1024, 768],
2016-08-04 19:47:19 +02:00
expect_mouse_registered: true,
failure_allowed: true,
2021-01-01 02:14:30 +01:00
},
2021-01-01 02:14:31 +01:00
{
name: "Oberon",
2016-08-04 19:47:19 +02:00
skip_if_disk_image_missing: true,
2021-01-01 02:14:31 +01:00
hda: root_path + "/images/oberon.img",
timeout: 30,
expect_graphical_mode: true,
expect_mouse_registered: true,
2016-08-04 19:47:19 +02:00
},
2015-12-30 22:36:44 +01:00
{
name: "Linux 3",
2021-01-01 02:14:34 +01:00
skip_if_disk_image_missing: true,
2015-12-30 22:36:44 +01:00
cdrom: root_path + "/images/linux3.iso",
timeout: 200,
expected_texts: [
"test passed",
],
actions: [
{
on_text: "~%",
run: "head -c 10000 /dev/urandom > rand; echo test pas''sed\n",
after: 1000,
2015-12-30 22:36:44 +01:00
},
],
},
2021-03-31 03:56:37 +02:00
{
name: "Linux 3 reboot",
cdrom: root_path + "/images/linux3.iso",
timeout: 90,
expected_texts: [
"~%",
"SeaBIOS ",
"~%",
],
actions: [
{
on_text: "~%",
run: "reboot\n",
},
],
},
2015-12-30 22:36:44 +01:00
{
name: "KolibriOS",
fda: root_path + "/images/kolibri.img",
timeout: 120,
expect_graphical_mode: true,
expect_mouse_registered: true,
},
2016-08-04 19:47:19 +02:00
{
name: "Linux with Bochs BIOS",
cdrom: root_path + "/images/linux.iso",
timeout: 90,
expected_texts: [
"/root%",
"test passed",
],
alternative_bios: true,
actions: [
{
on_text: "/root%",
run: "cd tests; ./test-i386 > emu.test; diff emu.test reference.test && echo test pas''sed || echo failed\n",
2016-08-04 19:47:19 +02:00
},
],
},
2016-01-03 19:15:46 +01:00
{
name: "MS-DOS",
skip_if_disk_image_missing: true,
hda: root_path + "/images/msdos.img",
timeout: 90,
expected_texts: [
"C:\\>",
],
},
2022-08-01 08:21:08 +02:00
{
name: "MS-DOS (hard disk + floppy disk)",
skip_if_disk_image_missing: true,
hda: root_path + "/images/msdos.img",
fda: root_path + "/images/kolibri.img",
boot_order: 0x132,
timeout: 90,
actions: [
{ on_text: "C:\\>", run: "a:\n" },
],
expected_texts: [
"A:\\>",
],
},
{
name: "Linux 4",
skip_if_disk_image_missing: true,
cdrom: root_path + "/images/linux4.iso",
timeout: 200,
expected_texts: [
"~%",
],
2021-01-01 02:14:29 +01:00
expected_serial_text: [
"Files send via emulator appear in",
],
expect_mouse_registered: true,
},
2018-10-09 21:15:28 +02:00
{
2021-01-01 02:14:34 +01:00
name: "Linux bzImage",
bzimage: root_path + "/images/buildroot-bzimage.bin",
2018-10-09 21:15:28 +02:00
cmdline: "auto",
timeout: 200,
expected_texts: [
"~%",
],
2021-01-01 02:14:29 +01:00
expected_serial_text: [
"Files send via emulator appear in",
],
2018-10-09 21:15:28 +02:00
expect_mouse_registered: true,
},
{
2021-01-01 02:14:34 +01:00
name: "Linux with bzImage from filesystem",
bzimage_initrd_from_filesystem: true,
filesystem: {
basefs: root_path + "/build/integration-test-fs/fs.json",
baseurl: root_path + "/build/integration-test-fs/flat/",
},
cmdline: "auto",
timeout: 200,
expected_texts: [
"~%",
],
2021-01-01 02:14:29 +01:00
expected_serial_text: [
"Files send via emulator appear in",
],
expect_mouse_registered: true,
},
{
name: "QNX",
2021-01-01 02:14:34 +01:00
skip_if_disk_image_missing: true,
fda: root_path + "/images/qnx-demo-network-4.05.img",
2021-01-01 02:14:34 +01:00
timeout: 300,
expect_mouse_registered: true,
expect_graphical_mode: true,
expect_graphical_size: [640, 480],
actions: [
2021-01-01 02:14:34 +01:00
{ run: " ", after: 30 * 1000 },
{ run: " ", after: 15 * 1000 },
{ run: " ", after: 15 * 1000 },
{ run: " ", after: 15 * 1000 },
{ run: " ", after: 15 * 1000 },
{ run: " ", after: 15 * 1000 },
{ run: " ", after: 15 * 1000 },
],
},
2016-01-03 19:15:46 +01:00
{
2021-01-01 02:14:31 +01:00
name: "OpenBSD Floppy",
fda: root_path + "/images/openbsd-floppy.img",
2016-02-05 14:40:46 +01:00
timeout: 180,
2016-01-03 19:15:46 +01:00
expected_texts: ["(I)nstall, (U)pgrade or (S)hell"],
},
2021-01-01 02:14:31 +01:00
{
name: "OpenBSD",
2021-01-01 02:14:34 +01:00
skip_if_disk_image_missing: true,
2021-01-01 02:14:31 +01:00
hda: root_path + "/images/openbsd.img",
timeout: 300,
actions: [
{
on_text: "boot>",
run: "boot -c\n",
},
{
on_text: "UKC>",
run: "disable mpbios\nexit\n",
},
{
on_text: "login:",
run: "root\n",
},
{
on_text: "Password:",
run: "root\n",
},
],
expected_texts: ["nyu# "],
},
{
name: "Windows 3.0",
slow: 1,
skip_if_disk_image_missing: true,
2018-10-01 23:48:15 +02:00
timeout: 10 * 60,
2021-01-04 05:58:13 +01:00
cdrom: root_path + "/images/Win30.iso",
expected_texts: [
"Press any key to continue",
" **************************************************",
],
expect_graphical_mode: true,
expect_mouse_registered: true,
actions: [
{
on_text: "Press any key to continue . . .",
after: 1000,
run: "x",
},
{
on_text: " **************************************************",
after: 1000,
run: "x",
},
{
on_text: "C> ",
after: 1000,
run: "win\n",
},
],
},
2021-03-30 11:35:27 +02:00
{
name: "Windows 3.1",
skip_if_disk_image_missing: true,
timeout: 2 * 60,
hda: root_path + "/images/win31.img",
expect_graphical_mode: true,
expect_graphical_size: [1024, 768],
expect_mouse_registered: true,
expected_texts: [
"MODE prepare code page function completed",
],
},
{
name: "FreeBSD",
skip_if_disk_image_missing: true,
timeout: 15 * 60,
2021-01-01 02:14:29 +01:00
hda: root_path + "/images/internal/freebsd/freebsd.img",
expected_texts: [
"FreeBSD/i386 (nyu) (ttyv0)",
"root@nyu:~ #",
],
actions: [
{
2021-01-01 02:14:29 +01:00
on_text: " Autoboot in",
run: "\n",
2021-01-01 02:14:29 +01:00
},
{
// workaround for freebsd not accepting key inputs just before the boot prompt
// (probably needs delay between keydown and keyup)
on_text: "FreeBSD/i386 (nyu) (ttyv0)",
run: "\x08", // backspace to avoid messing with login prompt
},
{
on_text: "login:",
after: 1000,
run: "root\n",
},
{
on_text: "Password:",
after: 1000,
run: "\n",
},
],
},
{
name: "FreeBSD cdrom",
skip_if_disk_image_missing: true,
slow: 1,
timeout: 10 * 60,
2021-01-01 02:14:29 +01:00
cdrom: root_path + "/images/experimental/os/FreeBSD-11.0-RELEASE-i386-bootonly.iso",
expected_texts: ["Welcome to FreeBSD!"],
actions: [
{
on_text: " Autoboot in ",
run: "\n",
}
],
},
{
name: "Arch Linux",
skip_if_disk_image_missing: true,
timeout: 20 * 60,
bzimage_initrd_from_filesystem: true,
2022-11-10 17:53:51 +01:00
memory_size: 512 * 1024 * 1024,
cmdline: [
"rw apm=off vga=0x344 video=vesafb:ypan,vremap:8",
"root=host9p rootfstype=9p rootflags=trans=virtio,cache=loose mitigations=off",
"audit=0 init=/usr/bin/init-openrc net.ifnames=0 biosdevname=0",
].join(" "),
filesystem: {
basefs: "images/fs.json",
2021-01-01 02:14:34 +01:00
baseurl: "images/arch-nongz/",
},
expected_texts: [
"root@localhost",
"aaaaaaaaaaaaaaaaaaaa",
"Hello, world",
"Hello from JS",
"Hello from OCaml",
"Compress okay",
2022-11-10 17:53:51 +01:00
"v86-in-v86 okay",
],
actions: [
{
on_text: "root@localhost",
run: `python -c 'print(100 * "a")'\n`,
},
{
on_text: "aaaaaaaaaaaaaaaaaaaa",
run: `gcc hello.c && ./a.out\n`,
},
{
on_text: "Hello, world",
run: `echo 'console.log("Hello from JS")' | node\n`,
},
{
on_text: "Hello from JS",
run: `echo 'print_endline "Hello from OCaml"' > hello.ml && ocamlopt hello.ml && ./a.out\n`,
},
{
on_text: "Hello from OCaml",
run:
"zstd hello.c && gzip -k hello.c && bzip2 -k hello.c && xz -k hello.c && lzma -k hello.c && " +
"zstdcat hello.c.zst && zcat hello.c.gz && bzcat hello.c.bz2 && xzcat hello.c.xz && lzmadec hello.c.lzma && " +
"echo Compress okay\n",
},
{
on_text: "Compress okay",
2022-11-10 17:53:51 +01:00
run:
RUN_SLOW_TESTS ?
"./v86-in-v86.js | tee /dev/stderr | grep -m1 'Files send via emulator appear in' ; sleep 2; echo v86-in-v86 okay\n"
:
"./v86-in-v86.js | tee /dev/stderr | grep -m1 'Kernel command line:' ; sleep 2; echo v86-in-v86 okay\n",
},
{
on_text: "v86-in-v86 okay",
run: "./startx.sh\n",
},
],
expect_graphical_mode: true,
expect_graphical_size: [1024, 768],
expect_mouse_registered: true,
},
{
name: "FreeGEM",
skip_if_disk_image_missing: true,
timeout: 60,
2021-01-01 02:14:29 +01:00
hda: root_path + "/images/experimental/os/freegem.bin",
expect_graphical_mode: true,
expect_mouse_registered: true,
actions: [
{
on_text: " Select from Menu",
run: "3",
}
],
},
{
name: "Haiku",
skip_if_disk_image_missing: true,
2021-01-01 02:14:29 +01:00
timeout: 15 * 60,
memory_size: 512 * 1024 * 1024,
hda: root_path + "/images/haiku-r1beta2-hrev54154_111-x86_gcc2h-anyboot.iso",
2021-01-01 02:14:29 +01:00
expected_serial_text: [
"init_hardware()",
2021-01-01 02:14:29 +01:00
"Running post install script /boot/system/boot/post-install/sshd_keymaker.sh",
// After pressing enter in the boot dialog:
"Running first login script /boot/system/boot/first-login/default_deskbar_items.sh",
],
expect_graphical_mode: true,
2021-01-01 02:14:31 +01:00
expect_graphical_size: [1024, 768],
expect_mouse_registered: true,
2021-01-01 02:14:29 +01:00
actions: [
{ after: 1 * 60 * 1000, run: "\n" },
{ after: 2 * 60 * 1000, run: "\n" },
{ after: 3 * 60 * 1000, run: "\n" },
{ after: 4 * 60 * 1000, run: "\n" },
{ after: 5 * 60 * 1000, run: "\n" },
{ after: 6 * 60 * 1000, run: "\n" },
{ after: 7 * 60 * 1000, run: "\n" },
{ after: 8 * 60 * 1000, run: "\n" },
],
},
{
name: "9front",
2021-01-01 02:14:34 +01:00
skip_if_disk_image_missing: true,
acpi: true,
timeout: 5 * 60,
hda: root_path + "/images/9front-7781.38dcaeaa222c.386.iso",
expect_graphical_mode: true,
expect_graphical_size: [1024, 768],
expect_mouse_registered: true,
actions: [
{ after: 60 * 1000, run: "\n" },
{ after: 70 * 1000, run: "\n" },
{ after: 80 * 1000, run: "\n" },
{ after: 90 * 1000, run: "\n" },
2021-01-01 02:14:34 +01:00
{ after: 100 * 1000, run: "\n" },
{ after: 110 * 1000, run: "\n" },
{ after: 120 * 1000, run: "\n" },
2021-03-17 22:55:16 +01:00
{ after: 130 * 1000, run: "\n" },
{ after: 140 * 1000, run: "\n" },
{ after: 150 * 1000, run: "\n" },
{ after: 160 * 1000, run: "\n" },
{ after: 170 * 1000, run: "\n" },
{ after: 180 * 1000, run: "\n" },
],
},
2021-01-01 02:14:31 +01:00
{
name: "ReactOS",
2021-01-01 02:14:34 +01:00
skip_if_disk_image_missing: true,
timeout: 10 * 60,
hda: root_path + "/images/reactos-livecd-0.4.15-dev-73-g03c09c9-x86-gcc-lin-dbg.iso",
2021-01-01 02:14:31 +01:00
expect_graphical_mode: true,
expect_graphical_size: [800, 600],
expect_mouse_registered: true,
actions: [
{ after: 1 * 60 * 1000, run: "\n" },
{ after: 2 * 60 * 1000, run: "\n" },
{ after: 3 * 60 * 1000, run: "\n" },
{ after: 4 * 60 * 1000, run: "\n" },
{ after: 5 * 60 * 1000, run: "\n" },
{ after: 6 * 60 * 1000, run: "\n" },
{ after: 7 * 60 * 1000, run: "\n" },
{ after: 8 * 60 * 1000, run: "\n" },
],
expected_serial_text: [
"DnsIntCacheInitialize()",
// when desktop is rendered:
"err: Attempted to close thread desktop",
],
},
{
name: "ReactOS CD",
2021-01-01 02:14:34 +01:00
skip_if_disk_image_missing: true,
timeout: 10 * 60,
cdrom: root_path + "/images/reactos-livecd-0.4.15-dev-73-g03c09c9-x86-gcc-lin-dbg.iso",
2021-01-01 02:14:31 +01:00
expect_graphical_mode: true,
expect_graphical_size: [800, 600],
expect_mouse_registered: true,
expected_serial_text: ["DnsIntCacheInitialize()"],
},
{
name: "HelenOS",
skip_if_disk_image_missing: true,
timeout: 3 * 60,
2022-05-23 16:24:29 +02:00
cdrom: root_path + "/images/HelenOS-0.11.2-ia32.iso",
expect_graphical_mode: true,
expect_mouse_registered: true,
2022-05-23 16:24:29 +02:00
expected_serial_text: ["init: Spawning"],
},
{
name: "Minix",
skip_if_disk_image_missing: true,
timeout: 60,
2021-01-01 02:14:29 +01:00
hda: root_path + "/images/experimental/os/minix2hd.img",
actions: [
{
on_text: " = Start Minix",
run: "=",
},
{
on_text: "noname login:",
run: "root\n",
},
],
expected_texts: ["noname login:", "# "],
},
{
name: "Minix CD",
skip_if_disk_image_missing: true,
timeout: 3 * 60,
cdrom: root_path + "/images/minix-3.3.0.iso",
actions: [
{
on_text: "login:",
run: "root\n",
},
],
expected_texts: ["login:", "We'd like your feedback", "# "],
},
{
name: "Mobius",
skip_if_disk_image_missing: true,
timeout: 2 * 60,
2021-01-01 02:14:34 +01:00
fda: root_path + "/images/mobius-fd-release5.img",
expect_graphical_mode: true,
actions: [
{
on_text: " The highlighted entry will be booted automatically",
run: "\n",
},
],
},
2022-01-18 00:08:42 +01:00
{
name: "FreeNOS",
skip_if_disk_image_missing: true,
timeout: 2 * 60,
cdrom: root_path + "/images/FreeNOS-1.0.3.iso",
acpi: true,
actions: [
{
on_text: "login:",
run: "root\n",
},
],
expected_texts: ["login:", "(localhost)"],
expected_serial_text: ["FreeNOS 1.0.3"],
},
2022-01-15 00:23:25 +01:00
{
name: "SerenityOS",
skip_if_disk_image_missing: true,
timeout: 2 * 60,
hda: root_path + "/images/serenity.img",
expect_graphical_mode: true,
expect_graphical_size: [1024, 768],
expect_mouse_registered: true,
},
2022-11-26 19:33:48 +01:00
{
name: "Redox",
skip_if_disk_image_missing: true,
timeout: 2 * 60,
memory_size: 512 * 1024 * 1024,
acpi: true,
hda: root_path + "/images/redox_demo_i686_2022-11-26_643_harddrive.img",
actions: [
{ on_text: "Arrow keys and enter select mode", run: "\n" },
],
expect_graphical_mode: true,
expect_mouse_registered: true,
expected_serial_text: ["# Login with the following:"],
},
{
name: "Android 1.6",
skip_if_disk_image_missing: true,
timeout: 2 * 60,
cdrom: root_path + "/images/android-x86-1.6-r2.iso",
expect_graphical_mode: true,
expect_graphical_size: [800, 600],
expect_mouse_registered: true,
},
{
name: "Android 4.4",
skip_if_disk_image_missing: true,
timeout: 5 * 60,
hda: root_path + "/images/android_x86_nonsse3_4.4r1_20140904.iso",
expect_graphical_mode: true,
expect_graphical_size: [800, 600],
expect_mouse_registered: true,
},
2022-09-05 11:44:07 +02:00
{
name: "Linux with Postgres",
skip_if_disk_image_missing: true,
2022-09-13 08:07:47 +02:00
timeout: 5 * 60,
2022-09-05 11:44:07 +02:00
memory_size: 512 * 1024 * 1024,
cdrom: root_path + "/images/experimental/linux-postgres.iso",
expected_texts: [
"performing post-bootstrap initialization",
"syncing data to disk",
"Success. You can now start the database server using",
],
},
{
name: "Tiny Core 11 CD",
skip_if_disk_image_missing: 1,
2021-11-05 04:43:15 +01:00
timeout: 10 * 60,
2021-01-01 02:14:34 +01:00
cdrom: root_path + "/images/TinyCore-11.0.iso",
expect_graphical_mode: true,
expect_mouse_registered: true,
actions: [{ on_text: " BIOS default device boot in", run: "\n", after: 5000 }],
},
{
name: "Tiny Core 11 HD",
skip_if_disk_image_missing: 1,
2021-11-05 04:43:15 +01:00
timeout: 10 * 60,
hda: root_path + "/images/TinyCore-11.0.iso",
expect_graphical_mode: true,
expect_mouse_registered: true,
actions: [{ on_text: " BIOS default device boot in", run: "\n", after: 5000 }],
},
{
2022-08-01 08:21:08 +02:00
name: "Core 9 (with floppy disk)",
skip_if_disk_image_missing: 1,
timeout: 5 * 60,
2021-01-01 02:14:29 +01:00
cdrom: root_path + "/images/experimental/os/Core-9.0.iso",
2022-08-01 08:21:08 +02:00
fda: root_path + "/images/freedos722.img",
actions: [
{ on_text: "boot:", run: "\n" },
{ on_text: "tc@box", run: "sudo mount /dev/fd0 /mnt && ls /mnt\n" },
],
expected_texts: ["AUTOEXEC.BAT"],
},
{
name: "Core 8",
skip_if_disk_image_missing: 1,
timeout: 5 * 60,
2021-01-01 02:14:29 +01:00
cdrom: root_path + "/images/experimental/os/Core-8.0.iso",
expected_texts: ["tc@box"],
actions: [{ on_text: "boot:", run: "\n" }],
},
{
name: "Core 7",
skip_if_disk_image_missing: 1,
timeout: 5 * 60,
2021-01-01 02:14:29 +01:00
cdrom: root_path + "/images/experimental/os/Core-7.2.iso",
expected_texts: ["tc@box"],
actions: [{ on_text: "boot:", run: "\n" }],
},
{
name: "Core 6",
skip_if_disk_image_missing: 1,
timeout: 5 * 60,
2021-01-01 02:14:29 +01:00
cdrom: root_path + "/images/experimental/os/Core-6.4.1.iso",
expected_texts: ["tc@box"],
actions: [{ on_text: "boot:", run: "\n" }],
},
{
name: "Core 5",
skip_if_disk_image_missing: 1,
timeout: 5 * 60,
2021-01-01 02:14:29 +01:00
cdrom: root_path + "/images/experimental/os/Core-5.4.iso",
expected_texts: ["tc@box"],
actions: [{ on_text: "boot:", run: "\n" }],
},
{
name: "Core 4",
skip_if_disk_image_missing: 1,
timeout: 5 * 60,
2021-01-01 02:14:29 +01:00
cdrom: root_path + "/images/experimental/os/Core-4.7.7.iso",
expected_texts: ["tc@box"],
actions: [{ on_text: "boot:", run: "\n" }],
},
{
name: "Damn Small Linux",
skip_if_disk_image_missing: 1,
timeout: 5 * 60,
2021-01-01 02:14:31 +01:00
cdrom: root_path + "/images/dsl-4.11.rc2.iso",
expect_graphical_mode: true,
2021-01-01 02:14:31 +01:00
expect_graphical_size: [1024, 768],
expect_mouse_registered: true,
},
2015-12-30 22:36:44 +01:00
];
2016-09-07 10:02:46 +02:00
if(TEST_NAME)
{
tests = tests.filter(test => test.name === TEST_NAME);
}
2016-07-28 00:29:32 +02:00
var nr_of_cpus = Math.min(Math.round(os.cpus().length / 2) || 1, tests.length, MAX_PARALLEL_TESTS);
2015-12-30 22:36:44 +01:00
console.log("Using %d cpus", nr_of_cpus);
var current_test = 0;
for(var i = 0; i < nr_of_cpus; i++)
2015-09-15 19:30:53 +02:00
{
2015-12-30 22:36:44 +01:00
var worker = cluster.fork();
2017-03-07 01:03:28 +01:00
worker.on("message", send_work_to_worker.bind(null, worker));
worker.on("online", send_work_to_worker.bind(null, worker));
2015-12-30 22:36:44 +01:00
worker.on("exit", function(code, signal)
{
if(signal)
{
console.warn("Worker killed by signal " + signal);
process.exit(1);
}
else if(code !== 0)
2015-12-30 22:36:44 +01:00
{
process.exit(code);
}
2016-01-03 19:10:13 +01:00
});
2015-12-30 22:36:44 +01:00
2016-01-03 19:10:13 +01:00
worker.on("error", function(error)
{
console.error("Worker error: ", error.toString(), error);
process.exit(1);
});
2015-09-15 19:30:53 +02:00
}
2015-12-30 22:36:44 +01:00
}
else
{
cluster.worker.on("message", function(test_case)
{
run_test(test_case, function()
{
process.send("I'm done");
});
});
}
2016-08-02 05:13:23 +02:00
function bytearray_starts_with(arr, search)
{
for(var i = 0; i < search.length; i++)
{
if(arr[i] !== search[i])
{
2017-03-07 01:03:28 +01:00
return false;
2016-08-02 05:13:23 +02:00
}
}
return true;
}
2015-12-30 22:36:44 +01:00
function run_test(test, done)
{
console.log("Starting test: %s", test.name);
2015-09-15 19:30:53 +02:00
2022-08-01 08:21:08 +02:00
const images = [test.fda, test.hda, test.cdrom, test.bzimage, test.filesystem && test.filesystem.basefs].filter(x => x);
assert(images.length, "Bootable drive expected");
2022-08-01 08:21:08 +02:00
const missing_images = images.filter(i => !fs.existsSync(i));
if(missing_images.length)
{
if(test.skip_if_disk_image_missing)
{
2022-08-01 08:21:08 +02:00
console.warn("Missing disk image: " + missing_images.join(", ") + ", test skipped");
console.warn();
done();
return;
}
else
{
2022-08-01 08:21:08 +02:00
console.warn("Missing disk image: " + missing_images.join(", "));
process.exit(1);
}
}
if(test.slow && !RUN_SLOW_TESTS)
{
console.warn("Slow test: " + test.name + ", skipped");
console.warn();
done();
return;
}
2016-02-05 14:40:46 +01:00
if(test.alternative_bios)
{
var bios = root_path + "/bios/bochs-bios.bin";
var vga_bios = root_path + "/bios/bochs-vgabios.bin";
2016-02-05 14:40:46 +01:00
}
2021-01-01 02:14:29 +01:00
else if(TEST_RELEASE_BUILD)
2016-02-05 14:40:46 +01:00
{
var bios = root_path + "/bios/seabios.bin";
var vga_bios = root_path + "/bios/vgabios.bin";
2016-02-05 14:40:46 +01:00
}
2021-01-01 02:14:29 +01:00
else
{
var bios = root_path + "/bios/seabios-debug.bin";
var vga_bios = root_path + "/bios/vgabios-debug.bin";
}
2015-09-15 19:30:53 +02:00
var settings = {
bios: { url: bios },
vga_bios: { url: vga_bios },
2015-09-15 19:30:53 +02:00
autostart: true,
2021-01-01 02:14:29 +01:00
memory_size: test.memory_size || 128 * 1024 * 1024,
log_level: 0,
cmdline: test.cmdline,
2015-09-15 19:30:53 +02:00
};
if(test.cdrom)
2015-09-15 19:30:53 +02:00
{
settings.cdrom = { url: test.cdrom };
2015-09-15 19:30:53 +02:00
}
if(test.fda)
2015-09-15 19:30:53 +02:00
{
settings.fda = { url: test.fda };
}
if(test.hda)
{
settings.hda = { url: test.hda, async: true };
2015-09-15 19:30:53 +02:00
}
2018-10-09 21:15:28 +02:00
if(test.bzimage)
{
settings.bzimage = { url: test.bzimage };
}
if(test.filesystem)
{
settings.filesystem = test.filesystem;
2018-10-09 21:15:28 +02:00
}
settings.cmdline = test.cmdline;
settings.bzimage_initrd_from_filesystem = test.bzimage_initrd_from_filesystem;
settings.acpi = test.acpi;
2022-08-01 08:21:08 +02:00
settings.boot_order = test.boot_order;
2022-09-13 08:07:47 +02:00
settings.cpuid_level = test.cpuid_level;
2015-09-15 19:30:53 +02:00
2016-08-02 05:13:23 +02:00
if(test.expected_texts)
{
test.expected_texts = test.expected_texts.map(string_to_bytearray);
}
else
2015-12-30 21:25:42 +01:00
{
test.expected_texts = [];
}
2021-01-01 02:14:29 +01:00
if(!test.expected_serial_text)
{
test.expected_serial_text = [];
}
2015-09-15 19:30:53 +02:00
var emulator = new V86(settings);
2015-12-30 22:36:44 +01:00
var screen = new Uint8Array(SCREEN_WIDTH * 25);
2015-09-15 19:30:53 +02:00
2015-12-30 21:25:42 +01:00
function check_text_test_done()
2015-09-15 19:30:53 +02:00
{
2015-12-30 21:25:42 +01:00
return test.expected_texts.length === 0;
2015-09-15 19:30:53 +02:00
}
2021-01-01 02:14:29 +01:00
function check_serial_test_done()
{
return test.expected_serial_text.length === 0;
}
2015-12-30 21:25:42 +01:00
var mouse_test_done = false;
function check_mouse_test_done()
2015-09-15 19:30:53 +02:00
{
2015-12-30 21:25:42 +01:00
return !test.expect_mouse_registered || mouse_test_done;
2015-09-15 19:30:53 +02:00
}
2015-12-30 21:25:42 +01:00
var graphical_test_done = false;
2016-08-04 19:47:19 +02:00
var size_test_done = false;
2020-10-04 19:46:41 +02:00
function check_graphical_test_done()
2015-09-15 19:30:53 +02:00
{
2021-01-01 02:14:29 +01:00
return !test.expect_graphical_mode || (graphical_test_done && (!test.expect_graphical_size || size_test_done));
2015-09-15 19:30:53 +02:00
}
var test_start = Date.now();
2016-01-03 19:10:13 +01:00
var timeout_seconds = test.timeout * TIMEOUT_EXTRA_FACTOR;
var timeout = setTimeout(check_test_done, (timeout_seconds + 1) * 1000);
2021-01-01 02:14:29 +01:00
var timeouts = [timeout];
2015-12-30 21:25:42 +01:00
2015-09-15 19:30:53 +02:00
var on_text = [];
2015-12-30 21:25:42 +01:00
var stopped = false;
2015-09-15 19:30:53 +02:00
var screen_interval = null;
2015-09-15 19:30:53 +02:00
function check_test_done()
{
2015-12-30 21:25:42 +01:00
if(stopped)
{
return;
}
2021-01-01 02:14:29 +01:00
if(check_text_test_done() &&
check_mouse_test_done() &&
2021-01-03 07:51:29 +01:00
check_graphical_test_done() &&
2021-01-01 02:14:29 +01:00
check_serial_test_done())
2015-09-15 19:30:53 +02:00
{
2016-08-02 05:13:23 +02:00
var end = Date.now();
2021-01-01 02:14:29 +01:00
for(let timeout of timeouts) clearTimeout(timeout);
2015-12-30 21:25:42 +01:00
stopped = true;
2016-01-03 19:10:13 +01:00
2015-09-15 19:30:53 +02:00
emulator.stop();
if(screen_interval !== null)
{
clearInterval(screen_interval);
}
2016-08-02 05:13:23 +02:00
console.warn("Passed test: %s (took %ds)", test.name, (end - test_start) / 1000);
2015-09-15 19:30:53 +02:00
console.warn();
2015-12-30 22:36:44 +01:00
done();
2015-09-15 19:30:53 +02:00
}
2016-01-03 19:10:13 +01:00
else if(Date.now() >= test_start + timeout_seconds * 1000)
2015-09-15 19:30:53 +02:00
{
2021-01-01 02:14:29 +01:00
for(let timeout of timeouts) clearTimeout(timeout);
2015-12-30 22:36:44 +01:00
stopped = true;
2016-01-03 19:10:13 +01:00
if(screen_interval !== null)
{
clearInterval(screen_interval);
}
2015-09-15 19:30:53 +02:00
emulator.stop();
emulator.destroy();
2015-12-30 22:36:44 +01:00
if(test.failure_allowed)
{
console.warn("Test failed: %s (failure allowed)\n", test.name);
}
else
{
console.warn(screen_to_text(screen));
console.warn("Test failed: %s\n", test.name);
}
2015-09-15 19:30:53 +02:00
2015-12-30 21:25:42 +01:00
if(!check_text_test_done())
2015-09-15 19:30:53 +02:00
{
2016-09-07 10:02:46 +02:00
console.warn('Expected text "%s" after %d seconds.', bytearray_to_string(test.expected_texts[0]), timeout_seconds);
2015-09-15 19:30:53 +02:00
}
2020-10-04 19:46:41 +02:00
if(!check_graphical_test_done())
2015-09-15 19:30:53 +02:00
{
2016-01-03 19:10:13 +01:00
console.warn("Expected graphical mode after %d seconds.", timeout_seconds);
2015-09-15 19:30:53 +02:00
}
2015-12-30 21:25:42 +01:00
if(!check_mouse_test_done())
2015-09-15 19:30:53 +02:00
{
2016-01-03 19:10:13 +01:00
console.warn("Expected mouse activation after %d seconds.", timeout_seconds);
2015-09-15 19:30:53 +02:00
}
if(!check_serial_test_done())
{
console.warn('Expected serial text "%s" after %d seconds.', test.expected_serial_text, timeout_seconds);
}
2021-01-01 02:14:29 +01:00
if(on_text.length)
{
console.warn(`Note: Expected text "${bytearray_to_string(on_text[0].text)}" to run "${on_text[0].run}"`);
}
if(!test.failure_allowed)
{
process.exit(1);
}
else
{
done();
}
2015-09-15 19:30:53 +02:00
}
}
2015-12-30 21:25:42 +01:00
emulator.add_listener("mouse-enable", function()
{
mouse_test_done = true;
check_test_done();
});
emulator.add_listener("screen-set-mode", function(is_graphical)
{
graphical_test_done = is_graphical;
check_test_done();
});
2016-08-04 19:47:19 +02:00
emulator.add_listener("screen-set-size-graphical", function(size)
{
if(test.expect_graphical_size)
{
size_test_done = size[0] === test.expect_graphical_size[0] &&
size[1] === test.expect_graphical_size[1];
check_test_done();
}
});
2015-09-15 19:30:53 +02:00
emulator.add_listener("screen-put-char", function(chr)
{
var y = chr[0];
var x = chr[1];
var code = chr[2];
screen[x + SCREEN_WIDTH * y] = code;
2016-08-02 05:13:23 +02:00
var line = get_line(screen, y);
2015-09-15 19:30:53 +02:00
2015-12-30 21:25:42 +01:00
if(!check_text_test_done())
2015-09-15 19:30:53 +02:00
{
2016-08-02 05:13:23 +02:00
let expected = test.expected_texts[0];
if(x < expected.length && bytearray_starts_with(line, expected))
2015-09-15 19:30:53 +02:00
{
test.expected_texts.shift();
2021-01-01 02:14:29 +01:00
if(VERBOSE) console.log(`Passed: "${bytearray_to_string(expected)}" on screen (${test.name})`);
2015-09-15 19:30:53 +02:00
check_test_done();
}
}
if(on_text.length)
{
2016-08-02 05:13:23 +02:00
let expected = on_text[0].text;
Squash 2e469796 Minor fab422ef Improve generation of 0f instructions 08ad7fe9 Improved if-else generation 3f81014d Minor: Align test output 4a3a84ef Generate modrm tests 61aa1875 Simplify a6e47954 Generate decoding of immediate operands 435b2c10 Fix warnings e4933042 Add missing immediate operand 3f3810c7 Generate immediate operands for instructions with modrm byte a0aa7b1f Make memory layout in nasm tests clearer 6b8ef212 Remove 'g' property from instruction table (implied by 'e') bf15c58c Remove unused declarations 1e543035 Remove useless `| 0` and `>>> 0` javascriptisms 1ccc5d53 Fix headers 8b40c532 Update qemu tests with changes from qemu ec9b0fb5 Port xchg instructions to C c73613e7 Port virt_boundary_* to C d61d1241 Add headers fd19f22c Make written value in write8 and write16 int32_t 497dcaec Generate read_imm for instructions with a modrm byte 8b7003d6 Generate read_imm8s 0cc75498 Remove read_op 9d716086 Trigger unimplemented_sse for partial sse instructions with prefix 8d5edd03 Remove unimplmented sse c-to-js hack 585d3565 Remove | 0 308124b2 Use int32_t as return value f193f8e1 Use JS version of cvttsd2si for now 12747b97 Generate trigger_ud for missing modrm branches 770f674e Split 0f00 and 0f01 into multiple instructions depending on modrm bits 1cb372a3 Generate decoder for some 0f-prefix instructions cec7bc63 Disable unused parameter warnings in instruction functions 807665b1 Generate read_imm for 0f/jmpcc cdf6eccc Generate modrm decoding for shld 04528429 Create temporary files in /tmp/, not cwd d8f3fbd8 Generate modrm/imm decoding for shld 00ef0942 Generate modrm decoding for bts f531984b Generate modrm decoding for shrd and imul 07569c53 Generate modrm decoding cmpxchg 535ff190 Generate modrm decoding for lfs/lgs/lss 2f8ced8d Generate modrm decoding for btr and btc 95de6c66 Generate modrm decoding for movzx c4d07e7e Generate modrm decoding for bsf and bsr f0985d26 Generate modrm decoding for movsx 4b30937a Generate modrm decoding for xadd a422eb27 Generate modrm decoding for movnti e5501d3c Generate modrm decoding for mov to/from control/debug registers bce11ec5 Generate modrm decoding for lar/lsl 5729a23c Fix access to DR4 and DR5 when cr4.DE is clear 44269a81 Specify immediate size explicitly instead of inferring it 82b2867a Fix STR instruction 98a9cc89 Log failing assertion 6d2f9964 Fix rdtsc 00260694 Log GP exceptions 7916883d Port trigger_ud and trigger_nm to C 36fedae9 Remove unused code e08fabd0 Generate modrm decoding for 0f00 and 0f01 8ae8174d Generate modrm decoding for 0fae and 0fc7 (fxsave, cmpxchg8, etc.) 26168164 Generate modrm+immediate decoding for 0fba (bit test with immediate operand) 6adf7fa7 Simplify create_tests.js (unused prefix call) c77cbdd8 Add comments about the implementation of pop [addr] 4640b4fe Simplify prefix call a81a5497 Don't use var 3ca5d13d Separate call name and arguments in code generator 3191a543 Simplify other prefix call (8D/lea) 5185080e Update generated code (stylistic changes and #ud generation) 93b51d41 Remove unused wasm externals e4af0a7f Avoid hardcoding special cases in code generator (lea, pop r/m) 654a2b49 Avoid hardcoding special cases in code generator (enter/jumpf/callf) fd1a1e86 Commit generated code (only stylistic changes) 7310fd1a Simplify code generator by merging code for with and without 0f prefix e7eae4af Simplify code generator by merging code for immediate operands 00fafd8a Improve assertions db084e49 Simplify code generator (modrm if-else) 0a0e4c9e Improve code generation of switch-case ce292795 Clarify some comments 37cf33fa Generate code in if/else blocks cbcc33fc Document naming scheme e30b97eb Generate modrm decoding for 0f12 (sse) instruction 24b72c2f movlpd cannot be used for register-to-register moves 72d72995 Generate modrm decoding for 0f13 (sse) instruction and disable register-to-register moving 75d76fbb Generate modrm decoding for 0f14 (sse) instruction ac8965a7 Generate modrm decoding for 0f28-0f2b (movap, movntp) e919d33e Generate modrm decoding for cvttsd2si 5f2ca2b4 Generate modrm decoding for andp and xorp c8d1c6de Generate modrm decoding for 0f60-0f70 (sse instructions) ae4ed46d Add multi-byte nop and prefetch to nasm test, generate modrm decoding 718a1acf Print qemu test error message more useful d1ecc37e Generate modrm decoding for 0f70-0f80 (sse instructions) 6a7219a5 Generate modrm decoding for popcnt 25278217 Generate modrm decoding for 0f71-0f73 (sse shift with immediate byte) ed1ec81b Generate modrm decoding for the remaining sse instructions (0fc0-0fff) 42bc5a6f Use 64-bit multiplication for native code dda3fb39 Remove old modrm-decoding functions 717975ef Move register access functions to cpu.c aee8138f Remove read_op, read_sib, read_op0F, read_disp f31317f2 Rename xmm/mmx register access functions a525e70b Remove 32-bit access to reg_xmm and reg_mmx c803eabc Rename s8/s16/s32 to i8/i16/i32 9fbd2ddf Don't use uninitialised structs 942eb4f7 Use 64-bit load for mmx registers and assert reg64 and reg128 size f94ec612 Use 64-bit writes for write_xmm64 08022de9 Use more efficient method for some 128-bit stores 9d5b084c Make timestamp counter unsigned 2ef388b3 Pass 64-bit value to safe_write64 4cb2b1be Optimise safe_write64 and safe_write128 b0ab09fb Implement psllq (660ff3) 9935e5d4 Optimise safe_read64s and safe_read128s af9ea1cc Log cl in cpuid only if relevant be5fe23e Add multi-op cache (disabled by default through ENABLE_JIT macro) and JIT paging test (similar to QEMU test). aa2f286e Don't initialise group_dirtiness with 1 as it increases the binary size significantly b8e14ed9 Remove unused reg_xmm32s bc726e03 Implement dbg_log for native code with format characters 'd' and 'x' 454039d6 Fix store task register 63a4b349 Remove unnecessary parens and clean up some log statements 4cc96814 Add logop and dbg_trace imports 7940655d Only inhibit interrupts if the interrupt flag was 0 in STI 876c68a7 Split create_tests into create_tests and generate_interpreter aa82499f Move detection of string instructions to x86_table f3840ec2 Move C ast to separate file 90400703 Skip tests for lfence/mfence/sfence, clarify their encoding 4a9d8204 elf: Hide log messages when log level is zero a601c526 Allow setting log level via settings 8a624453 Add cpu_exception_hook to debug builds f9e335bf Nasm: Test exceptions 599ad088 logop: Format instruction pointer as unsigned f95cf22b Don't skip zero dividing tests 2a655a0e Remove get_seg_prefix_ds from read_moffs (preparation for calling read_moffs from the code generator) bc580b71 Remove obsolete comment e556cee0 Fix nasmtest dependencies in makefile and clean dcb1e72b Use all cores on travis 86efa737 Replace all instances of u32 & 0xFFFF with the respective u16 accesses 98b9f439 Use u8 instead of bit-shifts and masks from u32 b43f6569 Replace all instances of u32 >> 16 with the respective u16 accesses 9bfa72c7 Remove unnecessary parens 9cf93734 Clean up remaining instance of u32 with a mask instead of u16 22d4117f Correct order of writes in virt_boundary_write32 6734c7c1 Fix keyboard on ios, fixes #105 858a4506 Add missing file, c_ast.js 1d62e39e Move instruction naming scheme into function f4816852 Reorder some code 69d49788 Minor improvements 0493e05f Add util.js af9000c1 Improve full test e5feba31 Add missing export c7c42065 Replace prefix_call with custom_resolve_modrm 3186e6ad Add support for "%%" format string to dbg_log_wasm for printf import efe54fad Add barebones instrumentation profiler (disabled by default). c9f0d462 Implement movlps m64, xmm and enable its test 42869a12 Add tests for cross-page reads/writes confirmed with byte reads/writes d68976ea Mask word values in port byte reads 9758d51e Add PS2_LOG_VERBOSE 5f52f037 Update NASM Makefile to include all dependencies to prevent unnecessary recompilation 2c71f927 Have NASM test generator use a seedable PRNG to allow for faster incremental tests e4aa45bb Add chunk{16,32}_rw paging tests; instructions that read and write to memory bdf538a2 add codegen to cpu constructor aa76ce8e add resolve_modrm16 14d7ecf1 refactor codegen b710319f [rebased] Merge branch codegen 0565ea42 minor refactoring 071dff3f temporary fix for automatic cast warnings 57c504f2 fix modrm16 issue c2db5d9e jit modrm32 85c04245 reinstate modrm_fn0 and modrm_fn1 be65dafd add ip and previous ip manipulating functions ae00ef89 update codegen js interface 530a74fa squashed commit for refactor 2c692199 add codegen-test to build c15afe68 prefix gen to codegen api c9611533 codegen tests fixes
2020-05-08 23:39:42 +02:00
2016-08-02 05:13:23 +02:00
if(x < expected.length && bytearray_starts_with(line, expected))
2015-09-15 19:30:53 +02:00
{
var action = on_text.shift();
Squash 2e469796 Minor fab422ef Improve generation of 0f instructions 08ad7fe9 Improved if-else generation 3f81014d Minor: Align test output 4a3a84ef Generate modrm tests 61aa1875 Simplify a6e47954 Generate decoding of immediate operands 435b2c10 Fix warnings e4933042 Add missing immediate operand 3f3810c7 Generate immediate operands for instructions with modrm byte a0aa7b1f Make memory layout in nasm tests clearer 6b8ef212 Remove 'g' property from instruction table (implied by 'e') bf15c58c Remove unused declarations 1e543035 Remove useless `| 0` and `>>> 0` javascriptisms 1ccc5d53 Fix headers 8b40c532 Update qemu tests with changes from qemu ec9b0fb5 Port xchg instructions to C c73613e7 Port virt_boundary_* to C d61d1241 Add headers fd19f22c Make written value in write8 and write16 int32_t 497dcaec Generate read_imm for instructions with a modrm byte 8b7003d6 Generate read_imm8s 0cc75498 Remove read_op 9d716086 Trigger unimplemented_sse for partial sse instructions with prefix 8d5edd03 Remove unimplmented sse c-to-js hack 585d3565 Remove | 0 308124b2 Use int32_t as return value f193f8e1 Use JS version of cvttsd2si for now 12747b97 Generate trigger_ud for missing modrm branches 770f674e Split 0f00 and 0f01 into multiple instructions depending on modrm bits 1cb372a3 Generate decoder for some 0f-prefix instructions cec7bc63 Disable unused parameter warnings in instruction functions 807665b1 Generate read_imm for 0f/jmpcc cdf6eccc Generate modrm decoding for shld 04528429 Create temporary files in /tmp/, not cwd d8f3fbd8 Generate modrm/imm decoding for shld 00ef0942 Generate modrm decoding for bts f531984b Generate modrm decoding for shrd and imul 07569c53 Generate modrm decoding cmpxchg 535ff190 Generate modrm decoding for lfs/lgs/lss 2f8ced8d Generate modrm decoding for btr and btc 95de6c66 Generate modrm decoding for movzx c4d07e7e Generate modrm decoding for bsf and bsr f0985d26 Generate modrm decoding for movsx 4b30937a Generate modrm decoding for xadd a422eb27 Generate modrm decoding for movnti e5501d3c Generate modrm decoding for mov to/from control/debug registers bce11ec5 Generate modrm decoding for lar/lsl 5729a23c Fix access to DR4 and DR5 when cr4.DE is clear 44269a81 Specify immediate size explicitly instead of inferring it 82b2867a Fix STR instruction 98a9cc89 Log failing assertion 6d2f9964 Fix rdtsc 00260694 Log GP exceptions 7916883d Port trigger_ud and trigger_nm to C 36fedae9 Remove unused code e08fabd0 Generate modrm decoding for 0f00 and 0f01 8ae8174d Generate modrm decoding for 0fae and 0fc7 (fxsave, cmpxchg8, etc.) 26168164 Generate modrm+immediate decoding for 0fba (bit test with immediate operand) 6adf7fa7 Simplify create_tests.js (unused prefix call) c77cbdd8 Add comments about the implementation of pop [addr] 4640b4fe Simplify prefix call a81a5497 Don't use var 3ca5d13d Separate call name and arguments in code generator 3191a543 Simplify other prefix call (8D/lea) 5185080e Update generated code (stylistic changes and #ud generation) 93b51d41 Remove unused wasm externals e4af0a7f Avoid hardcoding special cases in code generator (lea, pop r/m) 654a2b49 Avoid hardcoding special cases in code generator (enter/jumpf/callf) fd1a1e86 Commit generated code (only stylistic changes) 7310fd1a Simplify code generator by merging code for with and without 0f prefix e7eae4af Simplify code generator by merging code for immediate operands 00fafd8a Improve assertions db084e49 Simplify code generator (modrm if-else) 0a0e4c9e Improve code generation of switch-case ce292795 Clarify some comments 37cf33fa Generate code in if/else blocks cbcc33fc Document naming scheme e30b97eb Generate modrm decoding for 0f12 (sse) instruction 24b72c2f movlpd cannot be used for register-to-register moves 72d72995 Generate modrm decoding for 0f13 (sse) instruction and disable register-to-register moving 75d76fbb Generate modrm decoding for 0f14 (sse) instruction ac8965a7 Generate modrm decoding for 0f28-0f2b (movap, movntp) e919d33e Generate modrm decoding for cvttsd2si 5f2ca2b4 Generate modrm decoding for andp and xorp c8d1c6de Generate modrm decoding for 0f60-0f70 (sse instructions) ae4ed46d Add multi-byte nop and prefetch to nasm test, generate modrm decoding 718a1acf Print qemu test error message more useful d1ecc37e Generate modrm decoding for 0f70-0f80 (sse instructions) 6a7219a5 Generate modrm decoding for popcnt 25278217 Generate modrm decoding for 0f71-0f73 (sse shift with immediate byte) ed1ec81b Generate modrm decoding for the remaining sse instructions (0fc0-0fff) 42bc5a6f Use 64-bit multiplication for native code dda3fb39 Remove old modrm-decoding functions 717975ef Move register access functions to cpu.c aee8138f Remove read_op, read_sib, read_op0F, read_disp f31317f2 Rename xmm/mmx register access functions a525e70b Remove 32-bit access to reg_xmm and reg_mmx c803eabc Rename s8/s16/s32 to i8/i16/i32 9fbd2ddf Don't use uninitialised structs 942eb4f7 Use 64-bit load for mmx registers and assert reg64 and reg128 size f94ec612 Use 64-bit writes for write_xmm64 08022de9 Use more efficient method for some 128-bit stores 9d5b084c Make timestamp counter unsigned 2ef388b3 Pass 64-bit value to safe_write64 4cb2b1be Optimise safe_write64 and safe_write128 b0ab09fb Implement psllq (660ff3) 9935e5d4 Optimise safe_read64s and safe_read128s af9ea1cc Log cl in cpuid only if relevant be5fe23e Add multi-op cache (disabled by default through ENABLE_JIT macro) and JIT paging test (similar to QEMU test). aa2f286e Don't initialise group_dirtiness with 1 as it increases the binary size significantly b8e14ed9 Remove unused reg_xmm32s bc726e03 Implement dbg_log for native code with format characters 'd' and 'x' 454039d6 Fix store task register 63a4b349 Remove unnecessary parens and clean up some log statements 4cc96814 Add logop and dbg_trace imports 7940655d Only inhibit interrupts if the interrupt flag was 0 in STI 876c68a7 Split create_tests into create_tests and generate_interpreter aa82499f Move detection of string instructions to x86_table f3840ec2 Move C ast to separate file 90400703 Skip tests for lfence/mfence/sfence, clarify their encoding 4a9d8204 elf: Hide log messages when log level is zero a601c526 Allow setting log level via settings 8a624453 Add cpu_exception_hook to debug builds f9e335bf Nasm: Test exceptions 599ad088 logop: Format instruction pointer as unsigned f95cf22b Don't skip zero dividing tests 2a655a0e Remove get_seg_prefix_ds from read_moffs (preparation for calling read_moffs from the code generator) bc580b71 Remove obsolete comment e556cee0 Fix nasmtest dependencies in makefile and clean dcb1e72b Use all cores on travis 86efa737 Replace all instances of u32 & 0xFFFF with the respective u16 accesses 98b9f439 Use u8 instead of bit-shifts and masks from u32 b43f6569 Replace all instances of u32 >> 16 with the respective u16 accesses 9bfa72c7 Remove unnecessary parens 9cf93734 Clean up remaining instance of u32 with a mask instead of u16 22d4117f Correct order of writes in virt_boundary_write32 6734c7c1 Fix keyboard on ios, fixes #105 858a4506 Add missing file, c_ast.js 1d62e39e Move instruction naming scheme into function f4816852 Reorder some code 69d49788 Minor improvements 0493e05f Add util.js af9000c1 Improve full test e5feba31 Add missing export c7c42065 Replace prefix_call with custom_resolve_modrm 3186e6ad Add support for "%%" format string to dbg_log_wasm for printf import efe54fad Add barebones instrumentation profiler (disabled by default). c9f0d462 Implement movlps m64, xmm and enable its test 42869a12 Add tests for cross-page reads/writes confirmed with byte reads/writes d68976ea Mask word values in port byte reads 9758d51e Add PS2_LOG_VERBOSE 5f52f037 Update NASM Makefile to include all dependencies to prevent unnecessary recompilation 2c71f927 Have NASM test generator use a seedable PRNG to allow for faster incremental tests e4aa45bb Add chunk{16,32}_rw paging tests; instructions that read and write to memory bdf538a2 add codegen to cpu constructor aa76ce8e add resolve_modrm16 14d7ecf1 refactor codegen b710319f [rebased] Merge branch codegen 0565ea42 minor refactoring 071dff3f temporary fix for automatic cast warnings 57c504f2 fix modrm16 issue c2db5d9e jit modrm32 85c04245 reinstate modrm_fn0 and modrm_fn1 be65dafd add ip and previous ip manipulating functions ae00ef89 update codegen js interface 530a74fa squashed commit for refactor 2c692199 add codegen-test to build c15afe68 prefix gen to codegen api c9611533 codegen tests fixes
2020-05-08 23:39:42 +02:00
2021-01-01 02:14:29 +01:00
timeouts.push(
setTimeout(() => {
if(VERBOSE) console.error("Sending '%s'", action.run);
emulator.keyboard_send_text(action.run);
}, action.after || 0)
);
2015-09-15 19:30:53 +02:00
}
}
});
if(LOG_SCREEN)
{
screen_interval = setInterval(() => {
console.warn(screen_to_text(screen));
}, 10000);
}
2021-01-01 02:14:29 +01:00
2021-01-01 02:14:29 +01:00
let serial_line = "";
emulator.add_listener("serial0-output-char", function(c)
{
if(c === "\n")
{
if(VERBOSE)
{
2021-01-01 02:14:29 +01:00
console.log(`Serial (${test.name}):`, serial_line);
2021-01-01 02:14:29 +01:00
}
if(test.expected_serial_text.length)
{
2021-01-01 02:14:29 +01:00
const expected = test.expected_serial_text[0];
if(serial_line.includes(expected))
2021-01-01 02:14:29 +01:00
{
test.expected_serial_text.shift();
2021-01-01 02:14:29 +01:00
if(VERBOSE) console.log(`Passed: "${expected}" on serial (${test.name})`);
2021-01-01 02:14:29 +01:00
check_test_done();
}
}
serial_line = "";
}
else if(c >= " " && c <= "~")
{
serial_line += c;
}
});
2015-09-15 19:30:53 +02:00
test.actions && test.actions.forEach(function(action)
{
if(action.on_text)
{
2021-01-01 02:14:29 +01:00
on_text.push({ text: string_to_bytearray(action.on_text), run: action.run, after: action.after });
}
else
{
timeouts.push(
setTimeout(() => {
if(VERBOSE) console.error("Sending '%s'", action.run);
emulator.keyboard_send_text(action.run);
}, action.after || 0)
);
2015-09-15 19:30:53 +02:00
}
});
}