commit 6c2177e6c470a56fe374d5b7ea445921f96b99c3
parent 3fc1e891026f595032546d2aacb1089bea90a1e6
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 3 Jan 2024 14:51:28 +0900
change file_test.go from lib9p_test to lib9p
Diffstat:
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/file_test.go b/file_test.go
@@ -1,33 +1,29 @@
-package lib9p_test
+package lib9p
import (
"context"
"testing"
-
- "git.mtkn.jp/lib9p"
- "git.mtkn.jp/lib9p/testfs"
)
func BenchmarkRead(b *testing.B) {
- conn := testfs.SetupConn()
- defer conn.Close()
- ctx := context.Background()
- _, err := conn.C.Attach(ctx, ^uint16(0), 0, lib9p.NOFID, "kenji", "")
+ c, tc, rc := setupConn(testfs)
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ go sRead(ctx, c, tc)
+ fid, err := c.fPool.add(0)
if err != nil {
- b.Fatalf("attach: %v", err)
- }
- wqid, err := conn.C.Walk(ctx, 0, 0, 1, []string{"dir", "file"})
- if err != nil || len(wqid) != 2 {
- b.Fatalf("walk: %v, %v", wqid, err)
+ b.Fatal(err)
}
- _, _, err = conn.C.Open(ctx, 0, 1, lib9p.OREAD)
+ fid.omode = OREAD
+ fid.file, err = testfs.OpenFile("dir/file", OREAD)
if err != nil {
- b.Fatalf("open: %v", err)
+ b.Fatal(err)
}
+ fid.path = "dir/file"
for i := 0; i < b.N; i++ {
- _, err := conn.C.Read(ctx, 0, 1, 0, 8*1024)
- if err != nil {
- b.Fatalf("read: %v", err)
+ tc <- &request{ifcall:&TRead{Count:8*1024}}
+ if rerr, ok := (<-rc).ofcall.(*RError); ok {
+ b.Fatal(rerr.Ename)
}
}
}