command

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package command provides a generic way for running testing commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	// Name of the command to be run, used to give information.
	Name string

	// ValidateOutput is a function used to verify the output. It must make the test fail in
	// case of error.
	ValidateOutput func(t *testing.T, output string)

	// StartAndStop indicates this command should first be started then stopped.
	// It corresponds to gadget like execsnoop which wait user to type Ctrl^C.
	StartAndStop bool

	// Cmd object is used when we want to start the command, then do
	// other stuff and wait for its completion or just run the command.
	Cmd *exec.Cmd
	// contains filtered or unexported fields
}

func (*Command) IsStartAndStop

func (c *Command) IsStartAndStop() bool

func (*Command) Run

func (c *Command) Run(t *testing.T)

Run runs the Command on the given as parameter test.

func (*Command) Running

func (c *Command) Running() bool

func (*Command) Start

func (c *Command) Start(t *testing.T)

Start starts the Command on the given as parameter test, you need to wait it using Stop().

func (*Command) Stop

func (c *Command) Stop(t *testing.T)

Stop stops a Command previously started with Start(). To do so, it Kill() the process corresponding to this Cmd and then wait for its termination. Cmd output is then checked with regard to ExpectedString, ExpectedRegexp or ExpectedEntries.

Jump to

Keyboard shortcuts

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