lib9p

Go 9P library.
Log | Files | Refs | LICENSE

commit ef65aa51d1331f9390bd2dfa1af26c6d32cec5d2
parent 7d3a3ab52e32bb16b3c2136234fdf3ac49a72d35
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Tue,  2 Jan 2024 18:49:40 +0900

add TestSClunk

Diffstat:
Mserver_test.go | 41+++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+), 0 deletions(-)

diff --git a/server_test.go b/server_test.go @@ -616,4 +616,45 @@ func TestSWrite(t *testing.T) { f.content = []byte("") }() } +} + +func TestSClunk(t *testing.T) { + tests := []struct{ + fid uint32 + ifcall *TClunk + }{ + {0, &TClunk{Fid: 0}}, + {0, &TClunk{Fid: 1}}, + {1, &TClunk{Fid: 1}}, + } + c, tc, rc := setupConn(testfs) + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + go sClunk(ctx, c, tc) + for i, test := range tests { + func() { + _, err := c.fPool.add(test.fid) + if err != nil { + t.Error(err) + return + } + defer c.fPool.delete(test.fid) + tc <- &request{ifcall: test.ifcall} + ofcall := (<-rc).ofcall + switch ofcall := ofcall.(type) { + case *RClunk: + if _, ok := c.fPool.lookup(test.fid); ok { + if test.fid == test.ifcall.Fid { + t.Errorf("%d: fid not flushed", i) + } + } else { + if test.fid != test.ifcall.Fid { + t.Errorf("%d: wrong fid flushed", i) + } + } + default: + t.Errorf("%d: unexpected message %v", i, ofcall) + } + }() + } } \ No newline at end of file