40 lines
767 B
Go
40 lines
767 B
Go
package platform
|
|
|
|
import "testing"
|
|
|
|
func TestShouldKillWorkerProcess(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
exe string
|
|
base string
|
|
want bool
|
|
}{
|
|
{
|
|
name: "nvbandwidth executable",
|
|
exe: "/usr/libexec/datacenter-gpu-manager-4/plugins/cuda13/nvbandwidth",
|
|
base: "nvbandwidth",
|
|
want: true,
|
|
},
|
|
{
|
|
name: "dcgmi executable",
|
|
exe: "/usr/bin/dcgmi",
|
|
base: "dcgmi",
|
|
want: true,
|
|
},
|
|
{
|
|
name: "unrelated process",
|
|
exe: "/usr/bin/bash",
|
|
base: "bash",
|
|
want: false,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := shouldKillWorkerProcess(tt.exe, tt.base); got != tt.want {
|
|
t.Fatalf("shouldKillWorkerProcess(%q, %q)=%v want %v", tt.exe, tt.base, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|