diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-14 14:10:28 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-09-14 14:20:25 -0300 |
| commit | 5f24c4a2284a0af84fb9d116f7a39f6a58e42ae9 (patch) | |
| tree | 8679763439492361fe99ea01f5190e5204fa590c /test/differential/session.go | |
| download | cloud9-5f24c4a2284a0af84fb9d116f7a39f6a58e42ae9.tar.gz cloud9-5f24c4a2284a0af84fb9d116f7a39f6a58e42ae9.zip | |
Implement base 9P2000 sessions, shared transports, and conformance probes
Diffstat (limited to 'test/differential/session.go')
| -rw-r--r-- | test/differential/session.go | 45 |
1 files changed, 45 insertions, 0 deletions
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 +} |
