fix(windows): allow Java to read retained target snapshots (#1027)
This commit is contained in:
@@ -300,6 +300,28 @@ try {
|
||||
readbackRuntime.observation.path,
|
||||
"snapshot.bin",
|
||||
);
|
||||
// Java RandomAccessFile uses read/write sharing without delete sharing.
|
||||
// Exercise that independent Win32 reader contract without requiring Java.
|
||||
const readerDigest = execFileSync(
|
||||
"powershell.exe",
|
||||
[
|
||||
"-NoProfile",
|
||||
"-NonInteractive",
|
||||
"-Command",
|
||||
"$ErrorActionPreference = 'Stop'; " +
|
||||
"$stream = [IO.File]::Open($env:REA_SNAPSHOT_READER_PATH, [IO.FileMode]::Open, [IO.FileAccess]::Read, [IO.FileShare]::ReadWrite); " +
|
||||
"$hash = [Security.Cryptography.SHA256]::Create(); " +
|
||||
"try { [BitConverter]::ToString($hash.ComputeHash($stream)).Replace('-', '').ToLowerInvariant() } " +
|
||||
"finally { $hash.Dispose(); $stream.Dispose() }",
|
||||
],
|
||||
{
|
||||
encoding: "utf8",
|
||||
timeout: 15_000,
|
||||
env: { ...process.env, REA_SNAPSHOT_READER_PATH: snapshotPath },
|
||||
},
|
||||
).trim();
|
||||
assert.equal(readerDigest, readbackSnapshot.sha256);
|
||||
await assert.rejects(writeFile(snapshotPath, "replace"));
|
||||
await assert.rejects(rename(snapshotPath, `${snapshotPath}.renamed`));
|
||||
await assert.rejects(rm(snapshotPath));
|
||||
assert.equal(
|
||||
@@ -310,6 +332,7 @@ try {
|
||||
...report.controls,
|
||||
completedRuntimeFileReadback: true,
|
||||
completedRuntimeFileMutationDenied: true,
|
||||
snapshotReadWriteSharingReader: true,
|
||||
};
|
||||
} finally {
|
||||
await readbackRuntime.close();
|
||||
|
||||
Reference in New Issue
Block a user