Checkpoint web parity through Chromium input tasks
This commit is contained in:
51
tools/web/generate-ply-negative-fixtures.mjs
Normal file
51
tools/web/generate-ply-negative-fixtures.mjs
Normal file
@@ -0,0 +1,51 @@
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../..");
|
||||
const fixtureRoot = path.resolve(process.env.M12_PLY_NEGATIVE_OUTPUT ?? path.join(root, "tests/files/web/m12_ply_negative_v1"));
|
||||
const reportPath = path.resolve(process.env.M12_PLY_NEGATIVE_REPORT ?? path.join(root, "tests/golden/M12-07I/negative-report.json"));
|
||||
const sha256 = (bytes) => crypto.createHash("sha256").update(bytes).digest("hex");
|
||||
|
||||
function write(name, content) {
|
||||
const bytes = Buffer.isBuffer(content) ? content : Buffer.from(content, "utf8");
|
||||
fs.writeFileSync(path.join(fixtureRoot, name), bytes);
|
||||
return { name, byteLength: bytes.byteLength, sha256: sha256(bytes) };
|
||||
}
|
||||
|
||||
function bigEndian() {
|
||||
const header = "ply\nformat binary_big_endian 1.0\nelement vertex 1\nproperty float x\nproperty float y\nproperty float z\nelement face 0\nproperty list uchar uint vertex_indices\nend_header\n";
|
||||
const data = Buffer.alloc(12);
|
||||
data.writeFloatBE(0, 0); data.writeFloatBE(0, 4); data.writeFloatBE(0, 8);
|
||||
return Buffer.concat([Buffer.from(header, "ascii"), data]);
|
||||
}
|
||||
|
||||
function malformedList() {
|
||||
return "ply\nformat ascii 1.0\nelement vertex 3\nproperty float x\nproperty float y\nproperty float z\nelement face 1\nproperty list uchar uint vertex_indices\nend_header\n0 0 0\n1 0 0\n0 0 1\n3 0 1\n";
|
||||
}
|
||||
|
||||
function oversizedCount() {
|
||||
return "ply\nformat ascii 1.0\nelement vertex 65537\nproperty float x\nproperty float y\nproperty float z\nelement face 0\nproperty list uchar uint vertex_indices\nend_header\n";
|
||||
}
|
||||
|
||||
fs.mkdirSync(fixtureRoot, { recursive: true });
|
||||
const files = [
|
||||
write("big-endian.ply", bigEndian()),
|
||||
write("malformed-list-ascii.ply", malformedList()),
|
||||
write("oversized-count-ascii.ply", oversizedCount()),
|
||||
];
|
||||
const report = {
|
||||
schemaVersion: 1,
|
||||
task: "M12-07I",
|
||||
operation: "PLY_NEGATIVE_FORMAT_LIST_COUNT",
|
||||
cases: [
|
||||
{ id: "big-endian", file: "big-endian.ply", expectedCode: "PLY_FORMAT_UNSUPPORTED" },
|
||||
{ id: "malformed-list", file: "malformed-list-ascii.ply", expectedCode: "PLY_DATA_TRUNCATED" },
|
||||
{ id: "oversized-count", file: "oversized-count-ascii.ply", expectedCode: "PLY_IMPORT_BUDGET_EXCEEDED: vertex" },
|
||||
],
|
||||
files,
|
||||
nextTask: "M12-07J",
|
||||
};
|
||||
fs.mkdirSync(path.dirname(reportPath), { recursive: true });
|
||||
fs.writeFileSync(reportPath, JSON.stringify(report, null, 2) + "\n");
|
||||
process.stdout.write(`ply-negative-fixtures-generated cases=${report.cases.length} next=${report.nextTask}\n`);
|
||||
Reference in New Issue
Block a user