Exemplo n.º 1
0
func (r CommandMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Command, error) {
	sysres := sys.NewCommand(sr, sys, config)
	res, err := NewCommand(sysres, config)
	if err != nil {
		return nil, err
	}
	r[res.ID()] = res
	return res, nil
}
Exemplo n.º 2
0
func (r CommandMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Command, system.Command, bool) {
	sysres := sys.NewCommand(sr, sys)
	res := NewCommand(sysres)
	if e, _ := sysres.Exists(); e != true {
		return res, sysres, false
	}
	r[res.ID()] = res
	return res, sysres, true
}
Exemplo n.º 3
0
func (r CommandMap) AppendSysResourceIfExists(sr string, sys *system.System) (*Command, system.Command, bool) {
	sysres := sys.NewCommand(sr, sys, util.Config{})
	// FIXME: Do we want to be silent about errors?
	res, _ := NewCommand(sysres, util.Config{})
	if e, _ := sysres.Exists(); e != true {
		return res, sysres, false
	}
	r[res.ID()] = res
	return res, sysres, true
}
Exemplo n.º 4
0
func (r CommandMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*Command, error) {
	sysres := sys.NewCommand(sr, sys, config)
	res, err := NewCommand(sysres, config)
	if err != nil {
		return nil, err
	}
	if old_res, ok := r[res.ID()]; ok {
		res.Title = old_res.Title
		res.Meta = old_res.Meta
	}
	r[res.ID()] = res
	return res, nil
}
Exemplo n.º 5
0
func (c *Command) Validate(sys *system.System) []TestResult {
	syscommand := sys.NewCommand(c.Command, sys)

	var results []TestResult

	results = append(results, ValidateValue(c, "exit-status", c.ExitStatus, syscommand.ExitStatus))
	if len(c.Stdout) > 0 {
		results = append(results, ValidateContains(c, "stdout", c.Stdout, syscommand.Stdout))
	}
	if len(c.Stderr) > 0 {
		results = append(results, ValidateContains(c, "stderr", c.Stderr, syscommand.Stderr))
	}

	return results
}
Exemplo n.º 6
0
func (c *Command) Validate(sys *system.System) []TestResult {
	skip := false
	if c.Timeout == 0 {
		c.Timeout = 10000
	}
	sysCommand := sys.NewCommand(c.Command, sys, util.Config{Timeout: c.Timeout})

	var results []TestResult
	cExitStatus := deprecateAtoI(c.ExitStatus, fmt.Sprintf("%s: command.exit-status", c.Command))
	results = append(results, ValidateValue(c, "exit-status", cExitStatus, sysCommand.ExitStatus, skip))
	if len(c.Stdout) > 0 {
		results = append(results, ValidateContains(c, "stdout", c.Stdout, sysCommand.Stdout, skip))
	}
	if len(c.Stderr) > 0 {
		results = append(results, ValidateContains(c, "stderr", c.Stderr, sysCommand.Stderr, skip))
	}
	return results
}
Exemplo n.º 7
0
func (c *Command) Validate(sys *system.System) []TestResult {
	if c.Timeout == 0 {
		c.Timeout = 10000
	}
	sysCommand := sys.NewCommand(c.Command, sys, util.Config{Timeout: c.Timeout})

	var results []TestResult

	results = append(results, ValidateValue(c, "exit-status", c.ExitStatus, sysCommand.ExitStatus))

	if len(c.Stdout) > 0 {
		results = append(results, ValidateContains(c, "stdout", c.Stdout, sysCommand.Stdout))
	}
	if len(c.Stderr) > 0 {
		results = append(results, ValidateContains(c, "stderr", c.Stderr, sysCommand.Stderr))
	}

	return results
}
Exemplo n.º 8
0
func (r CommandMap) AppendSysResource(sr string, sys *system.System) (*Command, system.Command) {
	sysres := sys.NewCommand(sr, sys)
	res := NewCommand(sysres)
	r[res.ID()] = res
	return res, sysres
}