MCPcopy
hub / github.com/NVIDIA/k8s-device-plugin / buildLabelMapFromOutput

Function buildLabelMapFromOutput

cmd/gpu-feature-discovery/main_test.go:497–516  ·  view source on GitHub ↗
(output []byte)

Source from the content-addressed store, hash-verified

495}
496
497func buildLabelMapFromOutput(output []byte) (map[string]string, error) {
498 labels := make(map[string]string)
499
500 lines := strings.Split(strings.TrimRight(string(output), "\n"), "\n")
501 for _, line := range lines {
502 split := strings.Split(line, "=")
503 if len(split) != 2 {
504 return nil, fmt.Errorf("unexpected format in line: '%v'", line)
505 }
506 key := split[0]
507 value := split[1]
508
509 if v, ok := labels[key]; ok {
510 return nil, fmt.Errorf("duplicate label '%v': %v (overwrites %v)", key, v, value)
511 }
512 labels[key] = value
513 }
514
515 return labels, nil
516}
517
518func checkResult(result []byte, expectedOutputPath string, isVGPU bool) error {
519 expected, err := os.ReadFile(expectedOutputPath)

Callers 6

TestMigStrategyNoneFunction · 0.85
TestMigStrategySingleFunction · 0.85
TestMigStrategyMixedFunction · 0.85
TestRunSleepFunction · 0.85

Calls 1

SplitMethod · 0.45

Tested by

no test coverage detected