Documentation ¶
Index ¶
- func CompareDirectoryEntries(e1 []os.FileInfo, e2 []os.FileInfo) error
- func ConsumeWithSpeed(reader io.Reader, chunkSize int, interval time.Duration, stop chan bool) (n int, err error)
- func ConvertSliceOfStringsToMap(input []string) map[string]struct{}
- func EqualNormalizedString(t require.TestingT, transformFun func(rune) rune, actual, expected string)
- func ErrorContains(t require.TestingT, err error, expectedError string)
- func IsKilled(err error) bool
- func ListTar(f io.Reader) ([]string, error)
- func ParseCgroupPaths(procCgroupData string) map[string]string
- func RandomTmpDirPath(s string, platform string) string
- func ReadBody(b io.ReadCloser) ([]byte, error)
- func RemoveSpace(r rune) rune
- func RunCommandPipelineWithOutput(cmds ...*exec.Cmd) (output string, exitCode int, err error)
- type ChannelBuffer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareDirectoryEntries ¶
CompareDirectoryEntries compares two sets of FileInfo (usually taken from a directory) and returns an error if different.
func ConsumeWithSpeed ¶
func ConsumeWithSpeed(reader io.Reader, chunkSize int, interval time.Duration, stop chan bool) (n int, err error)
ConsumeWithSpeed reads chunkSize bytes from reader before sleeping for interval duration. Returns total read bytes. Send true to the stop channel to return before reading to EOF on the reader.
func ConvertSliceOfStringsToMap ¶
ConvertSliceOfStringsToMap converts a slices of string in a map with the strings as key and an empty string as values.
func EqualNormalizedString ¶
func EqualNormalizedString(t require.TestingT, transformFun func(rune) rune, actual, expected string)
EqualNormalizedString compare the actual value to the expected value after applying the specified transform function. It fails the test if these two transformed string are not equal. For example `EqualNormalizedString(t, RemoveSpace, "foo\n", "foo")` wouldn't fail the test as spaces (and thus '\n') are removed before comparing the string.
func ErrorContains ¶
ErrorContains checks that the error is not nil, and contains the expected substring.
func IsKilled ¶
IsKilled process the specified error and returns whether the process was killed or not.
func ParseCgroupPaths ¶
ParseCgroupPaths parses 'procCgroupData', which is output of '/proc/<pid>/cgroup', and returns a map which cgroup name as key and path as value.
func RandomTmpDirPath ¶
RandomTmpDirPath provides a temporary path with rand string appended. does not create or checks if it exists.
func ReadBody ¶
func ReadBody(b io.ReadCloser) ([]byte, error)
ReadBody read the specified ReadCloser content and returns it
func RemoveSpace ¶
RemoveSpace returns -1 if the specified runes is considered as a space (unicode) and the rune itself otherwise.
func RunCommandPipelineWithOutput ¶
RunCommandPipelineWithOutput runs the array of commands with the output of each pipelined with the following (like cmd1 | cmd2 | cmd3 would do). It returns the final output, the exitCode different from 0 and the error if something bad happened.
Types ¶
type ChannelBuffer ¶
type ChannelBuffer struct {
C chan []byte
}
ChannelBuffer holds a chan of byte array that can be populate in a goroutine.
func (*ChannelBuffer) ReadTimeout ¶
ReadTimeout reads the content of the channel in the specified byte array with the specified duration as timeout.