lib9p

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

commit f5144a4c74f5b87e94660e24a2284ec804b1fa15
parent 9312bcb425b344829c365fd66cff151159689102
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Tue,  2 Jan 2024 15:48:56 +0900

unexport unnecessary test functions
 and struct

Diffstat:
Mexport_test.go | 76++--------------------------------------------------------------------------
Mserver_test.go | 8++++----
Muid_test.go | 15++++++---------
3 files changed, 12 insertions(+), 87 deletions(-)

diff --git a/export_test.go b/export_test.go @@ -1,88 +1,15 @@ package lib9p -import ( - "context" - "sync" -) - -var ( - NewTVersion = newTVersion - NewRVersion = newRVersion - NewTAuth = newTAuth - NewRAuth = newRAuth - NewTAttach = newTAttach - NewRAttach = newRAttach - NewTFlush = newTFlush - NewRFlush = newRFlush - NewTWalk = newTWalk - NewRWalk = newRWalk - NewTOpen = newTOpen - NewROpen = newROpen - NewTCreate = newTCreate - NewRCreate = newRCreate - NewTRead = newTRead - NewRRead = newRRead - NewTWrite = newTWrite - NewRWrite = newRWrite - NewTClunk = newTClunk - NewRClunk = newRClunk - NewTRemove = newTRemove - NewRRemove = newRRemove - NewTStat = newTStat - NewRStat = newRStat - NewTWStat = newTWStat - NewRWStat = newRWStat - - SAttach = sAttach - SWalk = sWalk - SOpen = sOpen - - HasPerm = hasPerm - NewFidPool = newFidPool -) - -type BufMsg = bufMsg - -func (s *Server) SetFS(fs FS) { s.fs = fs } - -type Conn = conn -func (c *Conn) FPool() *FidPool { return c.fPool } -func (c *Conn) RunListener(ctx context.Context, rp *ReqPool) { - c.runListener(ctx, rp) -} -func (c *Conn) RunResponder(ctx context.Context, rp *ReqPool) { - c.runResponder(ctx, rp) -} -func (c *Conn) SetServer(s *Server) { c.s = s } -func (c *Conn) SetRespChan(rc chan *Req) { c.respChan = rc } -func (c *Conn) SetFPool(fp *FidPool) { c.fPool = fp } -func (c *Conn) NewMSizeLock() { c.mSizeLock = new(sync.Mutex) } -func (c *Conn) SetMSize(size uint32) { c.setMSize(size) } - type Req = request - func (r *Req) Ifcall() Msg { return r.ifcall } func (r *Req) SetIfcall(m Msg) { r.ifcall = m } func (r *Req) Ofcall() Msg { return r.ofcall } func (r *Req) SetOfcall(m Msg) { r.ofcall = m } func (r *Req) Afid() *Fid { return r.afid } -type ReqPool = reqPool - -func (rp *ReqPool) Add(tag uint16) (*Req, error) { return rp.add(tag) } - type Fid = fid - func (fid *Fid) SetPath(path string) { fid.path = path } func (fid *Fid) SetUid(uid string) { fid.uid = uid } func (fid *Fid) File() File { return fid.file } func (fid *Fid) SetFile(f File) { fid.file = f } -func (fid *Fid) SetOmode(m OpenMode) { fid.omode = m } - -type FidPool = fidPool - -func (fp *FidPool) Lookup(fid uint32) (*Fid, bool) { return fp.lookup(fid) } -func (fp *FidPool) Add(fid uint32) (*Fid, error) { return fp.add(fid) } -func (fp *FidPool) Delete(fid uint32) { fp.delete(fid) } - -func MarshalMsg(m Msg) []byte { return m.marshal() } +func (fid *Fid) SetOmode(m OpenMode) { fid.omode = m } +\ No newline at end of file diff --git a/server_test.go b/server_test.go @@ -25,7 +25,7 @@ func TestRunListener(t *testing.T) { t.Fatalf("open file: %v", err) } defer tFile2.Close() - c := &Conn{ + c := &conn{ s: &Server{chatty9P: false}, r: tFile, } @@ -63,7 +63,7 @@ func TestRunResponder(t *testing.T) { } defer rFile.Close() r, w := io.Pipe() - c := &Conn{s: &Server{chatty9P: false}, w: w} + c := &conn{s: &Server{chatty9P: false}, w: w} rp := newReqPool() ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -287,7 +287,7 @@ func TestSAttach(t *testing.T) { &RAttach{}}, // ok } c, tc, rc := setupConn(testfs) - dammyAuth := func(context.Context, *Req) {} + dammyAuth := func(context.Context, *request) {} af := &AuthFile{ Qid: Qid{Type: QTAUTH}, Uname: "kenji", @@ -361,7 +361,7 @@ func TestSWalk(t *testing.T) { defer cancel() go sWalk(ctx, c, tc) for i, test := range tests { - req := &Req{ifcall: test.input} + req := &request{ifcall: test.input} tc <- req ofcall := (<-rc).ofcall if test.wantErr == nil { diff --git a/uid_test.go b/uid_test.go @@ -1,26 +1,23 @@ -package lib9p_test +package lib9p import ( "io/fs" "testing" - - "git.mtkn.jp/lib9p" - "git.mtkn.jp/lib9p/testfs" ) func TestHasPerm(t *testing.T) { tests := []struct { - st lib9p.Stat + st Stat uid string perm fs.FileMode want bool }{ - {lib9p.Stat{Mode: 0777, Uid: "gotoh", Gid: "kessoku"}, "gotoh", 04, true}, - {lib9p.Stat{Mode: 0770, Uid: "gotoh", Gid: "kessoku"}, "ijichi", 04, true}, - {lib9p.Stat{Mode: 0000, Uid: "gotoh", Gid: "kessoku"}, "gotoh", 04, false}, + {Stat{Mode: 0777, Uid: "gotoh", Gid: "kessoku"}, "gotoh", 04, true}, + {Stat{Mode: 0770, Uid: "gotoh", Gid: "kessoku"}, "ijichi", 04, true}, + {Stat{Mode: 0000, Uid: "gotoh", Gid: "kessoku"}, "gotoh", 04, false}, } for i, test := range tests { - if got := lib9p.HasPerm(testfs.Fsys, &lib9p.FileInfo{test.st}, test.uid, test.perm); got != test.want { + if got := hasPerm(testfs, &FileInfo{test.st}, test.uid, test.perm); got != test.want { t.Errorf("hasPerm(pfs, file[%d], %s, 0%o) == %t\n", i, test.uid, test.perm, got) continue