From 5f24c4a2284a0af84fb9d116f7a39f6a58e42ae9 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 14 Sep 2026 14:10:28 -0300 Subject: Implement base 9P2000 sessions, shared transports, and conformance probes --- test/differential/session.go | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/differential/session.go (limited to 'test/differential/session.go') diff --git a/test/differential/session.go b/test/differential/session.go new file mode 100644 index 0000000..3fda214 --- /dev/null +++ b/test/differential/session.go @@ -0,0 +1,45 @@ +package main + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "github.com/knusbaum/go9p" + "github.com/knusbaum/go9p/fs" + "os/exec" + "strconv" + "time" +) + +func sessionProbe(binary string, seed int64, rounds int) map[string]any { + tree, root := fs.NewFS("user", "user", 0755) + check(root.AddChild(fs.NewStaticFile(tree.NewStat("file", "user", "user", 0600), nil))) + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() + command := exec.CommandContext(ctx, binary, strconv.FormatInt(seed, 10), strconv.Itoa(rounds)) + input, e := command.StdinPipe() + check(e) + output, e := command.StdoutPipe() + check(e) + var stderr bytes.Buffer + command.Stderr = &stderr + check(command.Start()) + done := make(chan error, 1) + go func() { done <- go9p.ServeReadWriter(output, input, tree.Server()) }() + e = command.Wait() + input.Close() + if e != nil { + panic(fmt.Sprintf("session probe: %v: %s", e, stderr.String())) + } + select { + case <-done: + case <-time.After(time.Second): + panic("reference server did not stop") + } + var result map[string]any + check(json.Unmarshal(stderr.Bytes(), &result)) + result["server"] = "go9p v1.18.0 StaticFile" + result["checks"] = "walk/open/write/read/stat/EOF/clunk, content oracle, fragmented requests and replies" + return result +} -- cgit v1.3