Skip to content

Commit

Permalink
Fix test on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
LandonTClipp committed Oct 2, 2024
1 parent cd27c4a commit c053088
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions plugins/inputs/nvidia_smi/nvidia_smi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"os"
"path/filepath"
"runtime"
"testing"
"time"

Expand All @@ -16,6 +17,16 @@ import (
)

func TestOnStartupError(t *testing.T) {
var binPath string
var nvidiaSMIArgs []string
if runtime.GOOS == "windows" {
binPath = `C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe`
nvidiaSMIArgs = []string{"-Command", "exit 1"}
} else {
binPath = "/bin/bash"
nvidiaSMIArgs = []string{"-c", "exit 1"}
}

tests := []struct {
ProbeOnStartup bool
}{
Expand All @@ -28,11 +39,11 @@ func TestOnStartupError(t *testing.T) {
}
for _, tt := range tests {
plugin := &NvidiaSMI{
BinPath: "/bin/bash",
BinPath: binPath,
ProbeOnStartup: tt.ProbeOnStartup,
Timeout: config.Duration(time.Second),
Log: &testutil.Logger{},
nvidiaSMIArgs: []string{"-c", "exit 9"},
nvidiaSMIArgs: nvidiaSMIArgs,
}
model := models.NewRunningInput(plugin, &models.InputConfig{
Name: "nvidia_smi",
Expand Down

0 comments on commit c053088

Please sign in to comment.