dutfs

package
v0.0.0-...-9474aff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2022 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package dutfs provides remote file system operations on DUT.

Remote tests usually define their own gRPC services for respective testing scenarios, but if tests want to do only a few basic file operations on DUT, they can choose to use this package to avoid defining gRPC services.

Index

Constants

View Source
const ServiceName = "tast.cros.baserpc.FileSystem"

ServiceName is the name of the gRPC service this package uses to access remote file system on DUT.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides remote file system operations on DUT.

func NewClient

func NewClient(conn *grpc.ClientConn) *Client

NewClient creates Client from an existing gRPC connection. conn must be connected to the cros bundle.

func (*Client) Exists

func (c *Client) Exists(ctx context.Context, name string) (bool, error)

Exists returns true if the path (file or dir) specified by name exists.

func (*Client) ReadDir

func (c *Client) ReadDir(ctx context.Context, dirname string) ([]os.FileInfo, error)

ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename.

func (*Client) ReadFile

func (c *Client) ReadFile(ctx context.Context, name string) ([]byte, error)

ReadFile reads the file specified by name and returns its contents.

func (*Client) Remove

func (c *Client) Remove(ctx context.Context, name string) error

Remove removes the named file or (empty) directory.

func (*Client) RemoveAll

func (c *Client) RemoveAll(ctx context.Context, name string) error

RemoveAll removes the path and any children it contains.

func (*Client) Stat

func (c *Client) Stat(ctx context.Context, name string) (os.FileInfo, error)

Stat returns filesystem status of the file specified by name.

func (*Client) TempDir

func (c *Client) TempDir(ctx context.Context, dir, pattern string) (string, error)

TempDir creates a temporary directory. If pattern includes a "*", the random string replaces the last "*". If dir is the empty string, TempDir uses the default directory for temporary files. TempDir returns the name of the new directory. The remote implementation calls ioutil.TempDir; see that for more details.

func (*Client) WriteFile

func (c *Client) WriteFile(ctx context.Context, name string, content []byte, mode os.FileMode) error

WriteFile writes the file specified by name with the provided content and mode.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL