Add a function for check if command exist

Use this function to check if command exist before execute it
in our test.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
This commit is contained in:
Yiqiao Pu
2018-04-11 15:04:25 +08:00
parent d6d7edb841
commit f1a4867bcd
2 changed files with 21 additions and 13 deletions

View File

@ -612,3 +612,13 @@ func WaitContainerReady(p *PodmanTest, id string, expStr string, timeout int, st
s.WaitWithDefaultTimeout()
}
}
//IsCommandAvaible check if command exist
func IsCommandAvailable(command string) bool {
check := exec.Command("bash", "-c", strings.Join([]string{"command -v", command}, " "))
err := check.Run()
if err != nil {
return false
}
return true
}