gvisor: gvisor.dev/gvisor/pkg/p9/p9test Index | Files

package p9test

import "gvisor.dev/gvisor/pkg/p9/p9test"

Package p9test provides standard mocks for p9.

Index

Package Files

p9test.go

func MakePath Uses

func MakePath() uint64

MakePath returns a globally unique path.

type Generator Uses

type Generator func(parent *Mock) *Mock

Generator is a function that generates a new file.

type Harness Uses

type Harness struct {
    Attacher *MockAttacher
    // contains filtered or unexported fields
}

Harness is an attacher mock.

func NewHarness Uses

func NewHarness(t *testing.T) (*Harness, *p9.Client)

NewHarness creates and returns a new test server.

It should always be used as:

h, c := NewHarness(t)
defer h.Finish()

func (*Harness) Finish Uses

func (h *Harness) Finish()

Finish completes all checks and shuts down the server.

func (*Harness) NewBlockDevice Uses

func (h *Harness) NewBlockDevice() Generator

NewBlockDevice returns a new mock block device.

func (*Harness) NewCharacterDevice Uses

func (h *Harness) NewCharacterDevice() Generator

NewCharacterDevice returns a new mock character device.

func (*Harness) NewDirectory Uses

func (h *Harness) NewDirectory(contents map[string]Generator) Generator

NewDirectory returns a new mock directory.

Note that Mkdir, Link, Mknod, RenameAt, UnlinkAt and Readdir must be mocked separately. Walk is provided and children may be manipulated via AddChild and RemoveChild. After calling Walk remotely, one can use Pop to find the corresponding backend mock on the server side.

func (*Harness) NewFile Uses

func (h *Harness) NewFile() Generator

NewFile returns a new file mock.

Note that ReadAt and WriteAt must be mocked separately.

func (*Harness) NewMock Uses

func (h *Harness) NewMock(parent *Mock, path uint64, attr p9.Attr) *Mock

NewMock returns a new base file.

func (*Harness) NewNamedPipe Uses

func (h *Harness) NewNamedPipe() Generator

NewNamedPipe returns a new mock named pipe.

func (*Harness) NewSocket Uses

func (h *Harness) NewSocket() Generator

NewSocket returns a new mock socket.

func (h *Harness) NewSymlink() Generator

NewSymlink returns a new mock directory.

Note that Readlink must be mocked separately.

func (*Harness) Pop Uses

func (h *Harness) Pop(clientFile p9.File) *Mock

Pop pops off the most recently created Mock and assert that this mock represents the same file passed in. If nil is passed in, no check is performed.

Precondition: there must be at least one Mock or this will panic.

type Mock Uses

type Mock struct {
    p9.DefaultWalkGetAttr
    *MockFile

    QID  p9.QID
    Attr p9.Attr

    // WalkCallback is a special function that will be called from within
    // the walk context. This is needed for the concurrent tests within
    // this package.
    WalkCallback func() error
    // contains filtered or unexported fields
}

Mock is a common mock element.

func (*Mock) AddChild Uses

func (m *Mock) AddChild(name string, generator Generator)

AddChild adds a new child to the Mock.

func (*Mock) GetAttr Uses

func (m *Mock) GetAttr(mask p9.AttrMask) (p9.QID, p9.AttrMask, p9.Attr, error)

GetAttr returns the current attributes.

func (*Mock) Matches Uses

func (m *Mock) Matches(x interface{}) bool

Matches implements gomock.Matcher.Matches.

func (*Mock) RemoveChild Uses

func (m *Mock) RemoveChild(name string)

RemoveChild removes the child with the given name.

func (*Mock) String Uses

func (m *Mock) String() string

String implements gomock.Matcher.String.

func (*Mock) Walk Uses

func (m *Mock) Walk(names []string) ([]p9.QID, p9.File, error)

Walk supports clone and walking in directories.

func (*Mock) WalkGetAttr Uses

func (m *Mock) WalkGetAttr(names []string) ([]p9.QID, p9.File, p9.AttrMask, p9.Attr, error)

WalkGetAttr calls the default implementation; this is a client-side optimization.

Package p9test imports 8 packages (graph). Updated 2020-12-31. Refresh now. Tools for package owners.