lib9p

Go 9P library.
Log | Files | Refs

commit 69f6bebf17cd459725cccc22942cb9427001825a
parent 73068cbc606906582489adc3b7783645545277d9
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Sun, 24 Sep 2023 07:02:58 +0900

update tests

Diffstat:
Mclient_test.go | 2+-
Mfs_test.go | 8++++++--
Mserver.go | 1-
Muid_test.go | 8+++++---
4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/client_test.go b/client_test.go @@ -236,7 +236,7 @@ func TestServer(t *testing.T) { if !ok { t.Fatalf("lookup fid %d", m.(*TRead).Fid()) } - if fid.Qid.Type&QTDIR != 0 { + if fid.File.Qid().Type&QTDIR != 0 { for i := 0; i < len(data); { stat := newStat(data[i:]) t.Logf("stat: %v", stat) diff --git a/fs_test.go b/fs_test.go @@ -26,8 +26,8 @@ func (f *testFile) Child() ([]File, error) { return child, nil } func (f *testFile) Stat() (*FileInfo, error) { return &FileInfo{Stat: f.stat}, nil } -func (f *testFile) Open() error { - fmt.Println("open") +func (f *testFile) Qid() Qid { return f.stat.Qid } +func (f *testFile) Open(mode OpenMode) error { f.reader = bytes.NewReader(f.content) return nil } @@ -45,6 +45,10 @@ type testFS struct { root *testFile } +func (fs *testFS) Root() File { + return fs.root +} + func (fs *testFS) Open(path string) (File, error) { path = clean9path(path) wnames := split9path(path) diff --git a/server.go b/server.go @@ -251,7 +251,6 @@ func sWalk(s *Server, r *Req) { n++ } newFid.File = cwd - log.Printf("fPool: %p %v", s.fPool, s.fPool) newFid.Uid = oldFid.Uid r.ofcall = &RWalk{ diff --git a/uid_test.go b/uid_test.go @@ -17,6 +17,8 @@ func (f permFile) Child() ([]File, error) { return nil, nil } func (f permFile) Stat() (*FileInfo, error) { return &FileInfo{Stat: Stat{Mode: f.mode, Uid: f.uid, Gid: f.gid}}, nil } +func (f permFile) Qid() Qid { return Qid{} } +func (f permFile) Open(mode OpenMode) error { return nil } func (f permFile) Close() error { return nil } func (f permFile) Read(b []byte) (int, error) { return 0, io.EOF } @@ -27,10 +29,10 @@ func TestHasPerm(t *testing.T) { perm fs.FileMode want bool }{ - {permFile{0777, "bocchi", "kessoku"}, "bocchi", 04, true}, + {permFile{0777, "gotoh", "kessoku"}, "gotoh", 04, true}, // TODO: user is assumed to be the leader of the group... - {permFile{0770, "bocchi", "kessoku"}, "nijika", 04, false}, - {permFile{0000, "bocchi", "kessoku"}, "bocchi", 04, false}, + {permFile{0770, "gotoh", "kessoku"}, "ijichi", 04, false}, + {permFile{0000, "gotoh", "kessoku"}, "gotoh", 04, false}, } for i, test := range tests {