package discovery import ( "reflect" "testing" ) func TestGPUProcessesAreListedByIndexNotUUID(t *testing.T) { gpus := "0, GPU-aaa\n1, GPU-bbb\n2, GPU-ccc\n" // Two processes on GPU 1, one on GPU 2, and a GPU this list has never // heard of, which is dropped rather than guessed at. apps := "GPU-bbb, 4100\nGPU-ccc, 4200\nGPU-bbb, 4300\nGPU-zzz, 9999\n" got := parseGPUProcesses(gpus, apps) want := map[int][]int{1: {4100, 4300}, 2: {4200}} if !reflect.DeepEqual(got, want) { t.Errorf("got %v, want %v", got, want) } if got := parseGPUProcesses(gpus, ""); len(got) != 0 { t.Errorf("no compute apps should be no GPU in use: %v", got) } }