Skip to content

Commit

Permalink
Fix darwin ping tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc committed Jun 22, 2016
1 parent d6951da commit 7825df4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/inputs/ping/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (p *Ping) args(url string) []string {
if p.Timeout > 0 {
switch runtime.GOOS {
case "darwin":
args = append(args, "-W", strconv.FormatFloat(p.Timeout/1000, 'f', 1, 64))
args = append(args, "-W", strconv.FormatFloat(p.Timeout*1000, 'f', 1, 64))
case "linux":
args = append(args, "-W", strconv.FormatFloat(p.Timeout, 'f', 1, 64))
default:
Expand Down
10 changes: 8 additions & 2 deletions plugins/inputs/ping/ping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ func TestArgs(t *testing.T) {
p.Timeout = 12.0
actual = p.args("www.google.com")
switch runtime.GOOS {
case "darwin", "freebsd":
case "darwin":
expected = []string{"-c", "2", "-n", "-s", "16", "-I", "eth0", "-W",
"12000.0", "www.google.com"}
case "freebsd":
expected = []string{"-c", "2", "-n", "-s", "16", "-I", "eth0", "-t",
"12.0", "www.google.com"}
default:
Expand All @@ -111,7 +114,10 @@ func TestArgs(t *testing.T) {
p.PingInterval = 1.2
actual = p.args("www.google.com")
switch runtime.GOOS {
case "darwin", "freebsd":
case "darwin":
expected = []string{"-c", "2", "-n", "-s", "16", "-I", "eth0", "-W",
"12000.0", "-i", "1.2", "www.google.com"}
case "freebsd":
expected = []string{"-c", "2", "-n", "-s", "16", "-I", "eth0", "-t",
"12.0", "-i", "1.2", "www.google.com"}
default:
Expand Down

0 comments on commit 7825df4

Please sign in to comment.