Documentation

Overview

    Package v23test defines Shell, a wrapper around gosh.Shell that provides Vanadium-specific functionality such as credentials management, StartRootMountTable, and StartSyncbase.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func BuildGoPkg

    func BuildGoPkg(sh *Shell, pkg string, flags ...string) string

      BuildGoPkg compiles a Go package using the "go build" command and writes the resulting binary to a temporary directory, or to the -o flag location if specified. If -o is relative, it is interpreted as relative to the temporary directory. If the binary already exists at the target location, it is not rebuilt. Returns the absolute path to the binary.

      func InitMain

      func InitMain() func()

        InitMain is called by v23test.TestMain; non-tests must call it early on in main(), before flags are parsed. It calls gosh.InitMain, initializes the directory used by v23test.BuildGoPkg, and returns a cleanup function.

        InitMain can also be used by test developers with complex setup or teardown requirements, where v23test.TestMain is unsuitable. InitMain must be called early on in TestMain, before m.Run is called. The returned cleanup function should be called after m.Run but before os.Exit.

        func SkipUnlessRunningIntegrationTests

        func SkipUnlessRunningIntegrationTests(tb testing.TB)

          SkipUnlessRunningIntegrationTests should be called first thing inside of the test function body of an integration test. It causes this test to be skipped unless integration tests are being run, i.e. unless the -v23.tests flag is set. TODO(sadovsky): Switch to using -test.short. See TODO above.

          func TestMain

          func TestMain(m *testing.M)

            TestMain calls flag.Parse and does some v23test/gosh setup work, then calls os.Exit(m.Run()). Developers with complex setup or teardown requirements may need to use InitMain instead.

            Types

            type Cmd

            type Cmd struct {
            	*gosh.Cmd
            	S *expect.Session
            	// contains filtered or unexported fields
            }

              Cmd wraps gosh.Cmd and provides Vanadium-specific functionality.

              func (*Cmd) Clone

              func (c *Cmd) Clone() *Cmd

                Clone returns a new Cmd with a copy of this Cmd's configuration.

                func (*Cmd) WithCredentials

                func (c *Cmd) WithCredentials(cr *Credentials) *Cmd

                  WithCredentials returns a clone of this command, configured to use the given credentials.

                  type Credentials

                  type Credentials struct {
                  	Handle    string
                  	Principal security.Principal // equal to pm.Principal(Handle)
                  }

                    Credentials represents a principal with a set of blessings. It is designed to be implementable using either the filesystem (with a credentials dir) or an external agent.

                    type Shell

                    type Shell struct {
                    	*gosh.Shell
                    	Ctx *context.T
                    	// contains filtered or unexported fields
                    }

                      Shell wraps gosh.Shell and provides Vanadium-specific functionality.

                      func NewShell

                      func NewShell(tb testing.TB, ctx *context.T) *Shell

                        NewShell creates a new Shell. Tests and benchmarks should pass their testing.TB; non-tests should pass nil. Ctx is the Vanadium context to use; if it's nil, NewShell will call v23.Init to create a context.

                        func (*Shell) Cleanup

                        func (sh *Shell) Cleanup()

                          Cleanup cleans up all resources associated with this Shell. See gosh.Shell.Cleanup for detailed description.

                          func (*Shell) Cmd

                          func (sh *Shell) Cmd(name string, args ...string) *Cmd

                            Cmd returns a Cmd for an invocation of the named program. The given arguments are passed to the child as command-line arguments.

                            func (*Shell) DebugSystemShell

                            func (sh *Shell) DebugSystemShell()

                              DebugSystemShell drops the user into a debug system shell (e.g. bash) that includes all environment variables from sh. If there is no controlling TTY, DebugSystemShell does nothing.

                              func (*Shell) ForkContext

                              func (sh *Shell) ForkContext(extensions ...string) *context.T

                                ForkContext creates a new context with forked credentials.

                                func (*Shell) ForkCredentials

                                func (sh *Shell) ForkCredentials(extensions ...string) *Credentials

                                  ForkCredentials creates a new Credentials (with a fresh principal) and blesses it with the given extensions and no caveats, using this principal's default blessings. Additionally, it calls SetDefaultBlessings.

                                  func (*Shell) ForkCredentialsFromPrincipal

                                  func (sh *Shell) ForkCredentialsFromPrincipal(principal security.Principal, extensions ...string) *Credentials

                                    ForkCredentialsFromPrincipal creates a new Credentials (with a fresh principal) and blesses it with the given extensions and no caveats, using the given principal's default blessings. Additionally, it calls SetDefaultBlessings.

                                    func (*Shell) FuncCmd

                                    func (sh *Shell) FuncCmd(f *gosh.Func, args ...interface{}) *Cmd

                                      FuncCmd returns a Cmd for an invocation of the given registered Func. The given arguments are gob-encoded in the parent process, then gob-decoded in the child and passed to the Func as parameters. To specify command-line arguments for the child invocation, append to the returned Cmd's Args.

                                      func (*Shell) StartRootMountTable

                                      func (sh *Shell) StartRootMountTable() func(sig os.Signal)

                                        StartRootMountTable calls StartRootMountTableWithOpts with default options.

                                        func (*Shell) StartRootMountTableWithOpts

                                        func (sh *Shell) StartRootMountTableWithOpts(opts mounttablelib.Opts) func(sig os.Signal)

                                          StartRootMountTableWithOpts starts mounttabled and calls SetRoots. Returns a function that can be called to send a signal to the started process and wait for it to exit.