lib9p

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

commit 1d8bcf63fb2ef276c5dfeb7e911d997f4f2e02d2
parent 0a9e489cbcf9f090d653799afa97794b91ae6de8
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Mon, 22 Jan 2024 08:19:39 +0900

use random tag

Diffstat:
Mclient/client_test.go | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/client/client_test.go b/client/client_test.go @@ -5,6 +5,7 @@ import ( "context" "errors" "io" + "math/rand" "reflect" "sync" "testing" @@ -80,8 +81,9 @@ func TestMux(t *testing.T) { defer cancel() c, r, w := newClientForTest(ctx, 1024, "glenda") for i, test := range tests{ - test.tmsg.SetTag(uint16(i)) - test.rmsg.SetTag(uint16(i)) + tag := uint16(rand.Uint32()) + test.tmsg.SetTag(tag) + test.rmsg.SetTag(tag) rq := newReq(test.tmsg) c.txc <- rq gottmsg, err := lib9p.RecvMsg(r) @@ -92,8 +94,9 @@ func TestMux(t *testing.T) { if !reflect.DeepEqual(test.tmsg, gottmsg) { t.Errorf("%d: mux modified tmsg:\n\twant: %v\n\tgot: %v", i, test.tmsg, gottmsg) + continue } - rq0, ok := c.rPool.lookup(uint16(i)) + rq0, ok := c.rPool.lookup(tag) if !ok { t.Errorf("%d: req not registered to the pool.", i) continue @@ -111,7 +114,7 @@ func TestMux(t *testing.T) { t.Errorf("%d: mux modified tmsg:\n\twant: %v\n\tgot: %v", i, test.tmsg, gottmsg) } - _, ok = c.rPool.lookup(uint16(i)) + _, ok = c.rPool.lookup(tag) if ok { t.Errorf("req not deleted from the pool.") continue