commit 471e1c02cddcfeab56a6c6e1c02a51acc8d8c34f
parent 6b940bb5ca8ba25cc507a4e882ea4ba1542a2ba0
Author: Matsuda Kenji <info@mtkn.jp>
Date: Sat, 4 Nov 2023 14:15:20 +0900
modify fcall_test
Diffstat:
2 files changed, 5 insertions(+), 18 deletions(-)
diff --git a/fcall_test.go b/fcall_test.go
@@ -7,12 +7,9 @@ import (
"testing"
)
-// TestParse parses 9P message and marshals it back, and
+// TestFcallParse parses 9P message and marshals it back, and
// checks whether they are identical.
func TestFcallParse(t *testing.T) {
- var raws [][]byte
- var msgs []Msg
-
tFile, err := os.Open("testdata/test_Tmsg.dat")
if err != nil {
t.Fatalf("open file: %v", err)
@@ -28,25 +25,16 @@ func TestFcallParse(t *testing.T) {
break
} else if err != nil {
t.Errorf("read msg: %v", err)
- mb = []byte{}
+ continue
}
- raws = append(raws, mb)
-
m, err := unmarshal(mb)
if err != nil {
t.Errorf("unmarshal: %v", err)
- m = nil
- }
- msgs = append(msgs, m)
- t.Log(m)
- }
- for i := 0; i < len(raws); i++ {
- if msgs[i] == nil {
- t.Errorf("nil message: %v", raws[i])
continue
}
- if !bytes.Equal(msgs[i].marshal(), raws[i]) {
- t.Errorf("data mismatch: %v, %v != %v", msgs[i], msgs[i].marshal(), raws[i])
+ t.Log(m)
+ if !bytes.Equal(m.marshal(), mb) {
+ t.Errorf("data mismatch: %v, %v != %v", m, m.marshal(), mb)
}
}
}
diff --git a/server.go b/server.go
@@ -40,7 +40,6 @@ type Server struct {
// Maximum length in byte of 9P messages.
msize uint32
// Mutex to change msize.
- // TODO: should be RWMutex?
mSizeLock *sync.Mutex
// FidPool of the Server.