Skip to content

Commit 474b19e

Browse files
committed
Add a basic test for --background
1 parent 24818d6 commit 474b19e

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/exec/use_pty/parent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub(in crate::exec) fn exec_pty(
6060
// `policy_init_session`.
6161
// FIXME (ogsudo): initializes ttyblock sigset here by calling `init_ttyblock`
6262

63-
// Fetch the parent process group so we can signals to it.
63+
// Fetch the parent process group so we can send signals to it.
6464
let parent_pgrp = getpgrp();
6565

6666
// Set all the IO streams for the command to the follower side of the pty.

test-framework/sudo-compliance-tests/src/sudo.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ mod apparmor;
33
mod child_process;
44
mod cli;
55
mod env_reset;
6+
mod flag_background;
67
mod flag_chdir;
78
mod flag_group;
89
mod flag_help;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use sudo_test::{Command, Env};
2+
3+
use crate::SUDOERS_ALL_ALL_NOPASSWD;
4+
5+
#[test]
6+
fn runs_in_background() {
7+
let env = Env(SUDOERS_ALL_ALL_NOPASSWD).build();
8+
9+
Command::new("sudo")
10+
.args([
11+
"-b",
12+
"sh",
13+
"-c",
14+
"touch /tmp/barrier1; until [ -f /tmp/barrier2 ]; do sleep 0.1; done; touch /tmp/barrier3",
15+
])
16+
.output(&env)
17+
.assert_success();
18+
19+
Command::new("sh")
20+
.args([
21+
"-c",
22+
"until [ -f /tmp/barrier1 ]; do sleep 0.1; done
23+
touch /tmp/barrier2
24+
until [ -f /tmp/barrier3 ]; do sleep 0.1; done",
25+
])
26+
.output(&env)
27+
.assert_success();
28+
}

0 commit comments

Comments
 (0)