plugins: update to spec version 1.0.0

Signed-off-by: Dan Williams <dcbw@redhat.com>
This commit is contained in:
Dan Williams
2020-09-30 10:40:15 -05:00
parent 9e2430bb80
commit 7d8c767622
53 changed files with 350 additions and 373 deletions

View File

@ -17,13 +17,24 @@ package testutils
import (
"bytes"
"fmt"
"net"
"os/exec"
"strconv"
"syscall"
)
// Ping shells out to the `ping` command. Returns nil if successful.
func Ping(saddr, daddr string, isV6 bool, timeoutSec int) error {
func Ping(saddr, daddr string, timeoutSec int) error {
ip := net.ParseIP(saddr)
if ip == nil {
return fmt.Errorf("failed to parse IP %q", saddr)
}
bin := "ping6"
if ip.To4() != nil {
bin = "ping"
}
args := []string{
"-c", "1",
"-W", strconv.Itoa(timeoutSec),
@ -31,11 +42,6 @@ func Ping(saddr, daddr string, isV6 bool, timeoutSec int) error {
daddr,
}
bin := "ping"
if isV6 {
bin = "ping6"
}
cmd := exec.Command(bin, args...)
var stderr bytes.Buffer
cmd.Stderr = &stderr