disable TestInterval with -race test option

This commit is contained in:
Rene Zbinden 2016-04-02 10:15:14 +02:00 committed by Cameron Sparr
parent be3374a3ef
commit 46fff13341
2 changed files with 40 additions and 28 deletions

View File

@ -0,0 +1,40 @@
// +build +linux !race
package sysstat
import (
"os/exec"
"testing"
"time"
"github.com/influxdata/telegraf/testutil"
)
// TestInterval verifies that the correct interval is created. It is not
// run with -race option, because in that scenario interval between the two
// Gather calls is greater than wantedInterval.
func TestInterval(t *testing.T) {
// overwriting exec commands with mock commands
execCommand = fakeExecCommand
defer func() { execCommand = exec.Command }()
var acc testutil.Accumulator
s.interval = 0
wantedInterval := 3
err := s.Gather(&acc)
if err != nil {
t.Fatal(err)
}
time.Sleep(time.Duration(wantedInterval) * time.Second)
err = s.Gather(&acc)
if err != nil {
t.Fatal(err)
}
if s.interval != wantedInterval {
t.Errorf("wrong interval: got %d, want %d", s.interval, wantedInterval)
}
}

View File

@ -8,7 +8,6 @@ import (
"os/exec"
"path"
"testing"
"time"
"github.com/influxdata/telegraf/testutil"
)
@ -304,30 +303,3 @@ dell-xps 5 2016-03-25 16:18:10 UTC sdb %util 0.30
// some code here to check arguments perhaps?
os.Exit(0)
}
// TestGatherInterval checks that interval is correctly set.
func TestGatherInterval(t *testing.T) {
// overwriting exec commands with mock commands
execCommand = fakeExecCommand
defer func() { execCommand = exec.Command }()
var acc testutil.Accumulator
s.interval = 0
wantedInterval := 3
err := s.Gather(&acc)
if err != nil {
t.Fatal(err)
}
time.Sleep(time.Duration(wantedInterval) * time.Second)
err = s.Gather(&acc)
if err != nil {
t.Fatal(err)
}
if s.interval != wantedInterval {
t.Errorf("wrong interval: got %d, want %d", s.interval, wantedInterval)
}
}