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

NVIDIA / nvrc / 20354255911

18 Dec 2025 11:14PM UTC coverage: 28.618% (-4.0%) from 32.588%
20354255911

Pull #83

github

web-flow
Merge d10d69857 into 1bf141c3d
Pull Request #83: Ambush Multiple Agent Code Inspection

71 of 149 new or added lines in 8 files covered. (47.65%)

3 existing lines in 2 files now uncovered.

87 of 304 relevant lines covered (28.62%)

0.61 hits per line

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

0.0
/src/execute.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// Copyright (c) NVIDIA CORPORATION
3

4
use anyhow::{anyhow, Context, Result};
5
use std::process::{Child, Command, Stdio};
6

7
use crate::kmsg::kmsg;
8

NEW
9
pub fn foreground(command: &str, args: &[&str]) -> Result<()> {
×
NEW
10
    debug!("{} {}", command, args.join(" "));
×
11

NEW
12
    let kmsg_file = kmsg().context("Failed to open kmsg device")?;
×
NEW
13
    let status = Command::new(command)
×
NEW
14
        .args(args)
×
NEW
15
        .stdout(Stdio::from(kmsg_file.try_clone().unwrap()))
×
NEW
16
        .stderr(Stdio::from(kmsg_file))
×
17
        .status()
NEW
18
        .context(format!("failed to execute {command}"))?;
×
19

NEW
20
    if !status.success() {
×
NEW
21
        return Err(anyhow!("{} failed with status: {}", command, status));
×
22
    }
NEW
23
    Ok(())
×
24
}
25

NEW
26
pub fn background(command: &str, args: &[&str]) -> Result<Child> {
×
NEW
27
    debug!("{} {}", command, args.join(" "));
×
NEW
28
    let kmsg_file = kmsg().context("Failed to open kmsg device")?;
×
NEW
29
    Command::new(command)
×
NEW
30
        .args(args)
×
NEW
31
        .stdout(Stdio::from(kmsg_file.try_clone().unwrap()))
×
NEW
32
        .stderr(Stdio::from(kmsg_file))
×
33
        .spawn()
NEW
34
        .with_context(|| format!("Failed to start {}", command))
×
35
}
36

37
#[cfg(test)]
38
mod tests {
39
    use std::process::{Command, Stdio};
40

41
    fn run_foreground(command: &str, args: &[&str]) -> std::io::Result<bool> {
42
        let status = Command::new(command)
43
            .args(args)
44
            .stdout(Stdio::null())
45
            .stderr(Stdio::null())
46
            .status()?;
47
        Ok(status.success())
48
    }
49

50
    fn run_background(command: &str, args: &[&str]) -> std::io::Result<std::process::Child> {
51
        Command::new(command)
52
            .args(args)
53
            .stdout(Stdio::null())
54
            .stderr(Stdio::null())
55
            .spawn()
56
    }
57

58
    #[test]
59
    fn test_foreground_success() {
60
        let result = run_foreground("/bin/true", &[]);
61
        assert!(result.is_ok());
62
        assert!(result.unwrap());
63
    }
64

65
    #[test]
66
    fn test_foreground_failure() {
67
        let result = run_foreground("/bin/false", &[]);
68
        assert!(result.is_ok());
69
        assert!(!result.unwrap()); // exit code 1
70
    }
71

72
    #[test]
73
    fn test_foreground_not_found() {
74
        let result = run_foreground("/nonexistent/command", &[]);
75
        assert!(result.is_err());
76
    }
77

78
    #[test]
79
    fn test_foreground_with_args() {
80
        let result = run_foreground("/bin/sh", &["-c", "exit 0"]);
81
        assert!(result.is_ok());
82
        assert!(result.unwrap());
83

84
        let result = run_foreground("/bin/sh", &["-c", "exit 42"]);
85
        assert!(result.is_ok());
86
        assert!(!result.unwrap());
87
    }
88

89
    #[test]
90
    fn test_background_spawns() {
91
        let result = run_background("/bin/sleep", &["0.1"]);
92
        assert!(result.is_ok());
93
        let mut child = result.unwrap();
94
        let status = child.wait().unwrap();
95
        assert!(status.success());
96
    }
97

98
    #[test]
99
    fn test_background_not_found() {
100
        let result = run_background("/nonexistent/command", &[]);
101
        assert!(result.is_err());
102
    }
103

104
    #[test]
105
    fn test_background_check_later() {
106
        let result = run_background("/bin/sh", &["-c", "exit 7"]);
107
        assert!(result.is_ok());
108
        let mut child = result.unwrap();
109
        let status = child.wait().unwrap();
110
        assert!(!status.success());
111
        assert_eq!(status.code(), Some(7));
112
    }
113
}
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