liberate tests from libv86-debug.js

This commit is contained in:
Fabian 2025-04-07 19:29:47 +07:00
parent b44f6ea83b
commit 2a4fe44a7d
25 changed files with 53 additions and 87 deletions

View file

@ -297,27 +297,27 @@ build/integration-test-fs/fs.json: images/buildroot-bzimage68.bin
./tools/copy-to-sha256.py build/integration-test-fs/fs.tar build/integration-test-fs/flat
rm build/integration-test-fs/fs.tar build/integration-test-fs/bzImage build/integration-test-fs/initrd
tests: build/libv86-debug.js build/v86-debug.wasm build/integration-test-fs/fs.json
tests: build/v86-debug.wasm build/integration-test-fs/fs.json
LOG_LEVEL=3 ./tests/full/run.js
tests-release: build/libv86.js build/v86.wasm build/integration-test-fs/fs.json
TEST_RELEASE_BUILD=1 ./tests/full/run.js
nasmtests: build/libv86-debug.mjs build/v86-debug.wasm
nasmtests: build/v86-debug.wasm
$(NASM_TEST_DIR)/create_tests.js
$(NASM_TEST_DIR)/gen_fixtures.js
$(NASM_TEST_DIR)/run.js
nasmtests-force-jit: build/libv86-debug.mjs build/v86-debug.wasm
nasmtests-force-jit: build/v86-debug.wasm
$(NASM_TEST_DIR)/create_tests.js
$(NASM_TEST_DIR)/gen_fixtures.js
$(NASM_TEST_DIR)/run.js --force-jit
jitpagingtests: build/libv86-debug.mjs build/v86-debug.wasm
jitpagingtests: build/v86-debug.wasm
$(MAKE) -C tests/jit-paging test-jit
./tests/jit-paging/run.js
qemutests: build/libv86-debug.mjs build/v86-debug.wasm
qemutests: build/v86-debug.wasm
$(MAKE) -C tests/qemu test-i386
LOG_LEVEL=3 ./tests/qemu/run.js build/qemu-test-result
./tests/qemu/run-qemu.js > build/qemu-test-reference
@ -329,7 +329,7 @@ qemutests-release: build/libv86.mjs build/v86.wasm
./tests/qemu/run-qemu.js > build/qemu-test-reference
diff build/qemu-test-result build/qemu-test-reference
kvm-unit-test: build/libv86-debug.mjs build/v86-debug.wasm
kvm-unit-test: build/v86-debug.wasm
(cd tests/kvm-unit-tests && ./configure && make x86/realmode.flat)
tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/realmode.flat
@ -337,11 +337,11 @@ kvm-unit-test-release: build/libv86.mjs build/v86.wasm
(cd tests/kvm-unit-tests && ./configure && make x86/realmode.flat)
TEST_RELEASE_BUILD=1 tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/realmode.flat
expect-tests: build/libv86-debug.mjs build/v86-debug.wasm build/libwabt.cjs
expect-tests: build/v86-debug.wasm build/libwabt.cjs
make -C tests/expect/tests
./tests/expect/run.js
devices-test: build/libv86-debug.mjs build/v86-debug.wasm
devices-test: build/v86-debug.wasm
./tests/devices/virtio_9p.js
./tests/devices/virtio_console.js
./tests/devices/fetch_network.js
@ -356,7 +356,7 @@ rust-test: $(RUST_FILES)
rust-test-intensive:
QUICKCHECK_TESTS=100000000 make rust-test
api-tests: build/libv86-debug.mjs build/v86-debug.wasm
api-tests: build/v86-debug.wasm
./tests/api/clean-shutdown.js
./tests/api/state.js
./tests/api/reset.js

View file

@ -3,6 +3,7 @@
import { CPU } from "./cpu.js";
import { save_state, restore_state } from "./state.js";
export { V86 } from "./browser/starter.js";
export { print_stats } from "./browser/print_stats.js";
/**
* @constructor

View file

@ -19,7 +19,7 @@ following list is roughtly sorted from most interesting/useful to least.
The following environmental variables are respected by most tests if applicable:
- `TEST_RELEASE_BUILD=1`: Test the release build (libv86.js, v86.wasm) instead of the
debug build (libv86-debug.js, v86-debug.wasm)
debug build (source files with v86-debug.wasm)
- `MAX_PARALLEL_TESTS=n`: Maximum number of tests to run in parallel. Defaults
to the number of cores in your system or less.
- `TEST_NAME="…"`: Run only the specified test (only expect, full, nasm)

View file

@ -8,8 +8,7 @@ const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
// listeners, so that the nodejs process cleanly and automatically exits.
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
var { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
process.on("unhandledRejection", exn => { throw exn; });

View file

@ -1,14 +1,13 @@
#!/usr/bin/env node
"use strict";
import {setTimeout as pause} from "timers/promises";
import { setTimeout as pause } from "timers/promises";
import url from "node:url";
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
var { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
process.on("unhandledRejection", exn => { throw exn; });

View file

@ -1,12 +1,13 @@
#!/usr/bin/env node
"use strict";
import url from "node:url";
import fs from "node:fs";
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
import fs from "node:fs";
const { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
const root_path = __dirname + "/../..";

View file

@ -6,8 +6,7 @@ import url from "node:url";
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
var { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
process.on("unhandledRejection", exn => { throw exn; });

View file

@ -8,8 +8,7 @@ import crypto from "node:crypto";
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
var { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
process.on("unhandledRejection", exn => { throw exn; });

View file

@ -8,8 +8,7 @@ const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
process.on("unhandledRejection", exn => { throw exn; });
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
var { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
const config_async_cdrom = {
bios: { url: __dirname + "/../../bios/seabios.bin" },

View file

@ -4,9 +4,9 @@
import url from "node:url";
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
process.on("unhandledRejection", exn => { throw exn; });

View file

@ -6,8 +6,7 @@ import url from "node:url";
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const BENCH_COLLECT_STATS = +process.env.BENCH_COLLECT_STATS;
const { V86, print_stats } = await import(`../../build/${BENCH_COLLECT_STATS ? "libv86-debug" : "libv86"}.js`);
const { V86, print_stats } = await import(BENCH_COLLECT_STATS ? "../../src/main.js" : "../../build/libv86.mjs");
const V86_ROOT = path.join(__dirname, "../..");

View file

@ -5,9 +5,9 @@ import path from "node:path";
import url from "node:url";
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const BENCH_COLLECT_STATS = +process.env.BENCH_COLLECT_STATS;
const { V86, print_stats } = await import(`../../build/${BENCH_COLLECT_STATS ? "libv86-debug" : "libv86"}.js`);
const BENCH_COLLECT_STATS = +process.env.BENCH_COLLECT_STATS;
const { V86, print_stats } = await import(BENCH_COLLECT_STATS ? "../../src/main.js" : "../../build/libv86.mjs");
const V86_ROOT = path.join(__dirname, "../..");

View file

@ -8,7 +8,7 @@ import url from "node:url";
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const BENCH_COLLECT_STATS = +process.env.BENCH_COLLECT_STATS;
const { V86, print_stats } = await import(`../../build/${BENCH_COLLECT_STATS ? "libv86-debug" : "libv86"}.js`).V86;
const { V86, print_stats } = await import(BENCH_COLLECT_STATS ? "../../src/main.js" : "../../build/libv86.mjs");
const V86_ROOT = path.join(__dirname, "../..");

View file

@ -5,8 +5,7 @@ import path from "node:path";
import url from "node:url";
const BENCH_COLLECT_STATS = +process.env.BENCH_COLLECT_STATS;
let { V86, print_stats } = await import(`../../build/${BENCH_COLLECT_STATS ? "libv86-debug" : "libv86"}.js`);
const { V86, print_stats } = await import(BENCH_COLLECT_STATS ? "../../src/main.js" : "../../build/libv86.mjs");
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const V86_ROOT = path.join(__dirname, "../..");

View file

@ -7,10 +7,11 @@ import url from "node:url";
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
process.on("unhandledRejection", exn => { throw exn; });
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const USE_VIRTIO = !!process.env.USE_VIRTIO;
const { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
const SHOW_LOGS = false;
function wait(time) {

View file

@ -5,10 +5,10 @@ import fs from "node:fs";
process.on("unhandledRejection", exn => { throw exn; });
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
var { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
const testfsjson = JSON.parse(fs.readFileSync(__dirname + "/testfs.json", "utf-8"));
const SHOW_LOGS = false;

View file

@ -7,8 +7,7 @@ const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
process.on("unhandledRejection", exn => { throw exn; });
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
const SHOW_LOGS = false;

View file

@ -7,11 +7,10 @@ import url from "node:url";
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
process.on("unhandledRejection", exn => { throw exn; });
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const SHOW_LOGS = false;
var { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
const emulator = new V86({
bios: { url: __dirname + "/../../bios/seabios.bin" },

View file

@ -8,8 +8,7 @@ const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
process.on("unhandledRejection", exn => { throw exn; });
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
const SHOW_LOGS = false;

View file

@ -6,23 +6,14 @@ import path from "node:path";
import assert from "node:assert/strict";
import url from "node:url";
import { spawnSync } from "node:child_process";
import wabtfactory from "../../build/libwabt.cjs";
import wabt from "../../build/libwabt.cjs";
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
const libwabt = wabtfactory();
try {
var { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
}
catch(e) {
console.error(e);
console.error("Failed to import build/libv86-debug.js. Run " +
"`make build/libv86-debug.js` first.");
process.exit(1);
}
const libwabt = wabt();
const TEST_NAME = process.env.TEST_NAME;

View file

@ -7,6 +7,9 @@ import os from "node:os";
import fs from "node:fs";
import url from "node:url";
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
process.on("unhandledRejection", exn => { throw exn; });
@ -14,21 +17,11 @@ 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;
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;
const VERBOSE = false;
const LOG_SCREEN = false;
try
{
var { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
}
catch(e)
{
console.error("Failed to import build/libv86-debug.js. Run `make build/libv86-debug.js first.");
process.exit(1);
}
var root_path = __dirname + "/../..";

View file

@ -6,10 +6,9 @@ import url from "node:url";
process.on("unhandledRejection", exn => { throw exn; });
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
var { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
var test_executable = new Uint8Array(fs.readFileSync(__dirname + "/test-jit"));

View file

@ -10,8 +10,7 @@ const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
process.on("unhandledRejection", exn => { throw exn; });
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
var { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
function readfile(path)
{

View file

@ -8,6 +8,9 @@ import assert from "node:assert/strict";
import os from "node:os";
import cluster from "node:cluster";
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
process.on("unhandledRejection", exn => { throw exn; });
@ -27,7 +30,6 @@ process.on("unhandledRejection", exn => { throw exn; });
const MAX_PARALLEL_TESTS = +process.env.MAX_PARALLEL_TESTS || 99;
const TEST_NAME = new RegExp(process.env.TEST_NAME || "", "i");
const SINGLE_TEST_TIMEOUT = 10000;
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const TEST_DIR = __dirname + "/build/";
const DONE_MSG = "DONE";
@ -50,16 +52,6 @@ const FPU_TAG_ALL_INVALID = 0xAAAA;
const FPU_STATUS_MASK = 0xFFFF & ~(1 << 9 | 1 << 5 | 1 << 3 | 1 << 1); // bits that are not correctly implemented by v86
const FP_COMPARISON_SIGNIFICANT_DIGITS = 7;
try {
var { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
}
catch(e) {
console.error(e);
console.error("Failed to import build/libv86-debug.js. Run " +
"`make build/libv86-debug.js` first.");
process.exit(1);
}
function float_equal(x, y)
{
assert(typeof x === "number");

View file

@ -3,14 +3,13 @@
process.on("unhandledRejection", exn => { throw exn; });
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
import { fileURLToPath } from "url";
import path from "path";
import fs from "fs";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const { V86 } = await import(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.mjs`);
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const { V86 } = await import(TEST_RELEASE_BUILD ? "../../build/libv86.mjs" : "../../src/main.js");
var test_executable = new Uint8Array(fs.readFileSync(__dirname + "/test-i386"));