mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 22:11:12 +00:00
* test: fix false-pass assertions, consolidate suites, and close coverage gaps * test: finish signal-0, unchecked close_binary, and vacuous .every() audit * test(registration): run shared capture inside test so child inherits scaled deadline * test(artifacts): bind final verification fault to reader source and post-read phase
53 lines
2.0 KiB
TypeScript
53 lines
2.0 KiB
TypeScript
import type { FileHandle } from "node:fs/promises";
|
|
import { it, vi } from "vitest";
|
|
import { TsharkCaptureProvider } from "../../../src/captures/TsharkCaptureProvider.js";
|
|
import { PacketCaptureService } from "../../../src/application/captures/PacketCaptureService.js";
|
|
import {
|
|
DESCRIPTOR_CLEANUP_MEMBERS,
|
|
runCliToolDescriptorCleanupScenario,
|
|
} from "../../fixtures/cliToolDescriptorCleanup.js";
|
|
|
|
const cleanup = vi.hoisted(() => ({
|
|
path: "",
|
|
denied: false,
|
|
handles: [] as FileHandle[],
|
|
}));
|
|
vi.mock("node:fs/promises", async (importOriginal) => {
|
|
const filesystem = await importOriginal<typeof import("node:fs/promises")>();
|
|
const { withDescriptorCloseFailure } =
|
|
await import("../../fixtures/descriptorCloseFailure.js");
|
|
return withDescriptorCloseFailure(filesystem, cleanup);
|
|
});
|
|
|
|
it.runIf(process.platform === "linux").each(DESCRIPTOR_CLEANUP_MEMBERS)(
|
|
"retains failed %s descriptors and retries them before further acquisition and shutdown",
|
|
async (member) => {
|
|
await runCliToolDescriptorCleanupScenario({
|
|
cleanup,
|
|
member,
|
|
tempPrefix: "rea-capture-descriptor-",
|
|
recordingFileName: "recording.pcap",
|
|
commandFileName: "tshark.mjs",
|
|
commandSource: `if(process.argv.includes('--version'))console.log('TShark (Wireshark) 4.0.17');else console.log('[{"_source":{"layers":{"frame.number":["1"]}}}]');`,
|
|
commandEnvKey: "REA_TSHARK_COMMAND",
|
|
limiterEnvKey: "REA_TSHARK_PRLIMIT_COMMAND",
|
|
primaryOperation: "inspect_packet_capture",
|
|
discoveryOperation: "inspect_packet_fields",
|
|
createFixture: ({ env, spawn, createRuntimeRoot, recordingPath }) => {
|
|
const provider = new TsharkCaptureProvider(
|
|
env,
|
|
spawn,
|
|
createRuntimeRoot,
|
|
);
|
|
const service = new PacketCaptureService(provider);
|
|
return {
|
|
close: () => provider.close(),
|
|
runPrimary: () =>
|
|
service.inspect({ path: recordingPath, fields: ["frame.number"] }),
|
|
runDiscovery: () => service.inspectFields({ query: "usb" }),
|
|
};
|
|
},
|
|
});
|
|
},
|
|
);
|