test(brainfs): per-caller in-brain symlink targets for slices 1-3 (#171) #172

Merged
mathias merged 5 commits from test/in-brain-targets-171 into main 2026-10-05 19:36:31 +00:00
2 changed files with 9 additions and 7 deletions
Showing only changes of commit a83f0cb381 - Show all commits
@@ -1,8 +1,10 @@
// Package brainfstest is the shared harness for hyperguild#157's swap-race
// tests: it keeps swapping a regular note, a symlink to an outside file, or a
// FIFO (with a writer held open) into a path while a reader under test loops.
// It observes two things: no sentinel byte from the outside file reaches the
// reader's output, and the reader returns within a timeout. It does not cover
// tests: it keeps swapping a regular note, a symlink to a sentinel target file
// (outside the brain, or inside it for hyperguild#171), or a FIFO (with a
// writer held open) into a path while a reader under test loops.
// It observes two things, over a sampled window only: no sentinel byte from
// the target reaches the reader's output, and the reader returns within a
// timeout. It does not cover
// hard links, other paths into the reader, or races it does not generate.
package brainfstest
@@ -18,7 +20,7 @@ import (
"time"
)
// Sentinel marks the outside file's contents.
// Sentinel marks the target file's contents.
const Sentinel = "zqbrainfssentinelonefiftyseven"
// outsideContent carries Sentinel in every field a reader might extract: the
+2 -2
View File
@@ -184,7 +184,7 @@ func inBrainTarget(t *testing.T, brain string) string {
return brainfstest.WriteSentinelAt(t, filepath.Join(brain, "raw", "s.md"))
}
func TestQueryLeaksNothingFromAnInBrainTargetUnderASymlinkSwapRace(t *testing.T) {
func TestQueryDoesNotReturnAnInBrainSymlinkTargetDuringASampledSwapRace(t *testing.T) {
brain, facts, _ := searchBrain(t)
target := inBrainTarget(t, brain)
read := func() string {
@@ -200,7 +200,7 @@ func TestQueryLeaksNothingFromAnInBrainTargetUnderASymlinkSwapRace(t *testing.T)
assert.NotContains(t, read(), brainfstest.Sentinel, "static in-brain link")
}
func TestHydrateRefusesAnInBrainSymlinkAndLeaksNothingUnderASwapRace(t *testing.T) {
func TestHydrateRefusesAnInBrainSymlinkAndDoesNotReturnItsTargetDuringASampledSwapRace(t *testing.T) {
brain, facts, _ := searchBrain(t)
target := inBrainTarget(t, brain)
require.NoError(t, os.Symlink(filepath.Join("..", "..", "..", "raw", "s.md"), filepath.Join(facts, "inlink.md")))