• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NVIDIA / gpu-operator / 29513807383

16 Jul 2026 03:58PM UTC coverage: 32.688% (+0.9%) from 31.812%
29513807383

Pull #2571

github

karthikvetrivel
Add golden render tests for GPUCluster operand manifests

Signed-off-by: Karthik Vetrivel <kvetrivel@nvidia.com>
Pull Request #2571: Add GPUCluster CRD and controller for DRA-based stack

513 of 1343 new or added lines in 31 files covered. (38.2%)

5 existing lines in 4 files now uncovered.

4663 of 14265 relevant lines covered (32.69%)

0.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.05
/internal/driverroot/root.go
1
/*
2
# Copyright (c) NVIDIA CORPORATION.  All rights reserved.
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
*/
16

17
package driverroot
18

19
import (
20
        "fmt"
21
        "os"
22
        "path/filepath"
23
)
24

25
// Root represents a directory containing an NVIDIA driver installation.
26
type Root string
27

28
// GetDriverLibraryPath returns path to `libnvidia-ml.so.1` in the driver root.
29
// The folder for this file is also expected to be the location of other driver files.
30
func (r Root) GetDriverLibraryPath() (string, error) {
1✔
31
        return r.findFile("libnvidia-ml.so.1",
1✔
32
                "/usr/lib64",
1✔
33
                "/usr/lib/x86_64-linux-gnu",
1✔
34
                "/usr/lib/aarch64-linux-gnu",
1✔
35
                "/lib64",
1✔
36
                "/lib/x86_64-linux-gnu",
1✔
37
                "/lib/aarch64-linux-gnu",
1✔
38
        )
1✔
39
}
1✔
40

41
// GetNvidiaSMIPath returns path to the `nvidia-smi` executable in the driver root.
42
func (r Root) GetNvidiaSMIPath() (string, error) {
1✔
43
        return r.findFile("nvidia-smi", "/usr/bin", "/usr/sbin", "/bin", "/sbin")
1✔
44
}
1✔
45

46
// isDevRoot checks whether the specified root is a dev root.
47
// A dev root is defined as a root containing a /dev folder.
NEW
48
func (r Root) isDevRoot() bool {
×
49
        stat, err := os.Stat(filepath.Join(string(r), "dev"))
×
50
        if err != nil {
×
51
                return false
×
52
        }
×
53
        return stat.IsDir()
×
54
}
55

56
// GetDevRoot returns the dev root associated with the root.
57
// If the root is not a dev root, this defaults to "/".
NEW
58
func (r Root) GetDevRoot() string {
×
59
        if r.isDevRoot() {
×
60
                return string(r)
×
61
        }
×
62
        return "/"
×
63
}
64

65
// findFile searches the root for a specified file.
66
// A number of folders can be specified to search in addition to the root itself.
67
// If the file represents a symlink, this is resolved and the final path is returned.
68
func (r Root) findFile(name string, searchIn ...string) (string, error) {
1✔
69
        for _, d := range append([]string{"/"}, searchIn...) {
2✔
70
                l := filepath.Join(string(r), d, name)
1✔
71
                candidate, err := resolveLink(l)
1✔
72
                if err != nil {
2✔
73
                        continue
1✔
74
                }
75
                return candidate, nil
1✔
76
        }
77

78
        return "", fmt.Errorf("error locating %q", name)
1✔
79
}
80

81
// resolveLink finds the target of a symlink or the file itself in the
82
// case of a regular file.
83
// This is equivalent to running `readlink -f ${l}`.
84
func resolveLink(l string) (string, error) {
1✔
85
        resolved, err := filepath.EvalSymlinks(l)
1✔
86
        if err != nil {
2✔
87
                return "", fmt.Errorf("error resolving link '%s': %w", l, err)
1✔
88
        }
1✔
89
        return resolved, nil
1✔
90
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc