diff options
| author | Allen Webb <allenwebb@google.com> | 2020-06-23 14:11:17 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-06-23 14:11:17 +0000 |
| commit | cf11c6da73277a09ebaccd1cb7dbf27e0eb500f0 (patch) | |
| tree | 2abc5d67948c10abd34e524a1168aa0c749924dd | |
| parent | e4d2ad6e0fe52ae223e90fdb357e2669172f9d4d (diff) | |
| parent | 4345ae1e9ebd17e0d238ef2690557c8024802edd (diff) | |
| download | platform_external_minijail-cf11c6da73277a09ebaccd1cb7dbf27e0eb500f0.tar.gz platform_external_minijail-cf11c6da73277a09ebaccd1cb7dbf27e0eb500f0.tar.bz2 platform_external_minijail-cf11c6da73277a09ebaccd1cb7dbf27e0eb500f0.zip | |
rust/minijail: Make sure spawned jobs termininate during unit tests. am: afb7a139a6 am: 4345ae1e9e
Original change: https://android-review.googlesource.com/c/platform/external/minijail/+/1344773
Change-Id: Ib944c55a496891bb79dfb4cb07b4ed9dff5ea2f3
| -rw-r--r-- | rust/minijail/src/lib.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/rust/minijail/src/lib.rs b/rust/minijail/src/lib.rs index 3741a1d9..d9f273eb 100644 --- a/rust/minijail/src/lib.rs +++ b/rust/minijail/src/lib.rs @@ -699,6 +699,8 @@ fn is_single_threaded() -> io::Result<bool> { #[cfg(test)] mod tests { + use std::process::exit; + use super::*; #[test] @@ -722,8 +724,8 @@ mod tests { j.parse_seccomp_filters(Path::new("src/test_filter.policy")) .unwrap(); j.use_seccomp_filter(); - unsafe { - j.fork(None).unwrap(); + if unsafe { j.fork(None).unwrap() } == 0 { + exit(0); } } @@ -742,6 +744,7 @@ mod tests { if j.fork(Some(&fds)).unwrap() == 0 { assert!(libc::close(second) < 0); // Should fail as second should be closed already. assert_eq!(libc::close(first), 0); // Should succeed as first should be untouched. + exit(0); } } } @@ -751,8 +754,8 @@ mod tests { fn chroot() { let mut j = Minijail::new().unwrap(); j.enter_chroot(Path::new(".")).unwrap(); - unsafe { - j.fork(None).unwrap(); + if unsafe { j.fork(None).unwrap() } == 0 { + exit(0); } } @@ -761,8 +764,8 @@ mod tests { fn namespace_vfs() { let mut j = Minijail::new().unwrap(); j.namespace_vfs(); - unsafe { - j.fork(None).unwrap(); + if unsafe { j.fork(None).unwrap() } == 0 { + exit(0); } } |
