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

NVIDIA / nvrc / 20358693314

19 Dec 2025 03:18AM UTC coverage: 68.196% (+39.6%) from 28.618%
20358693314

Pull #84

github

web-flow
Merge d80170c79 into 5b8b670d9
Pull Request #84: NVRC complete code coverage

34 of 45 new or added lines in 6 files covered. (75.56%)

4 existing lines in 4 files now uncovered.

223 of 327 relevant lines covered (68.2%)

1.33 hits per line

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

66.67
/src/modprobe.rs
1
use crate::execute::foreground;
2
use anyhow::Result;
3

4
const MODPROBE: &str = "/sbin/modprobe";
5

6
/// Load a kernel module via modprobe.
7
/// Used to load GPU drivers (nvidia, nvidia-uvm) during init.
8
pub fn load(module: &str) -> Result<()> {
1✔
9
    foreground(MODPROBE, &[module])
2✔
10
}
11

12
/// Reload NVIDIA modules to pick up configuration changes.
13
/// Used after nvidia-smi adjusts GPU settings (clocks, power limits)
14
/// that require a module reload to take effect.
15
pub fn reload_nvidia_modules() -> Result<()> {
1✔
16
    foreground(MODPROBE, &["-r", "nvidia-uvm", "nvidia"])?;
1✔
NEW
17
    load("nvidia")?;
×
NEW
18
    load("nvidia-uvm")
×
19
}
20

21
#[cfg(test)]
22
mod tests {
23
    use super::*;
24
    use nix::unistd::Uid;
25
    use std::env;
26
    use std::process::Command;
27

28
    /// Re-run test as root via sudo if not already root
29
    fn require_root() {
30
        if Uid::effective().is_root() {
31
            return;
32
        }
33

34
        #[cfg(coverage)]
35
        panic!("coverage tests must run as root - use: sudo cargo llvm-cov");
36

37
        #[cfg(not(coverage))]
38
        {
39
            let args: Vec<String> = env::args().collect();
40
            match Command::new("sudo").args(&args).status() {
41
                Ok(status) => std::process::exit(status.code().unwrap_or(1)),
42
                Err(e) => panic!("failed to run sudo: {}", e),
43
            }
44
        }
45
    }
46

47
    // Test with real kernel modules commonly available on Linux.
48

49
    #[test]
50
    fn test_load_loop() {
51
        require_root();
52
        // 'loop' module is almost always available (loop devices)
53
        assert!(load("loop").is_ok());
54
    }
55

56
    #[test]
57
    fn test_load_dummy() {
58
        require_root();
59
        // 'dummy' creates a dummy network interface - safe to load
60
        assert!(load("dummy").is_ok());
61
    }
62

63
    #[test]
64
    fn test_load_nonexistent() {
65
        require_root();
66
        // Should fail for a module that doesn't exist
67
        assert!(load("nonexistent_module_xyz123").is_err());
68
    }
69

70
    #[test]
71
    fn test_reload_fails_without_hardware() {
72
        require_root();
73
        // Will fail: no nvidia modules on systems without NVIDIA
74
        let _ = reload_nvidia_modules();
75
    }
76
}
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