From ca085e97232e0b13ca3515b2a01b46851654aefd Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 27 Apr 2020 12:02:18 -0700 Subject: [PATCH] Remove Windows nested job object detection. According to https://docs.microsoft.com/en-us/windows/win32/procthread/nested-jobs nested jobs have been supported since Windows 8. This code isn't particularly safe with multiple test threads running at once because it modifies the job object of the test itself. --- tests/testsuite/death.rs | 44 ---------------------------------------- 1 file changed, 44 deletions(-) diff --git a/tests/testsuite/death.rs b/tests/testsuite/death.rs index 39ad914a6b3..eb8d572193a 100644 --- a/tests/testsuite/death.rs +++ b/tests/testsuite/death.rs @@ -8,52 +8,8 @@ use std::thread; use cargo_test_support::{project, slow_cpu_multiplier}; -#[cfg(unix)] -fn enabled() -> bool { - true -} - -// On Windows support for these tests is only enabled through the usage of job -// objects. Support for nested job objects, however, was added in recent-ish -// versions of Windows, so this test may not always be able to succeed. -// -// As a result, we try to add ourselves to a job object here -// can succeed or not. -#[cfg(windows)] -fn enabled() -> bool { - use winapi::um::{handleapi, jobapi, jobapi2, processthreadsapi}; - - unsafe { - // If we're not currently in a job, then we can definitely run these - // tests. - let me = processthreadsapi::GetCurrentProcess(); - let mut ret = 0; - let r = jobapi::IsProcessInJob(me, 0 as *mut _, &mut ret); - assert_ne!(r, 0); - if ret == ::winapi::shared::minwindef::FALSE { - return true; - } - - // If we are in a job, then we can run these tests if we can be added to - // a nested job (as we're going to create a nested job no matter what as - // part of these tests. - // - // If we can't be added to a nested job, then these tests will - // definitely fail, and there's not much we can do about that. - let job = jobapi2::CreateJobObjectW(0 as *mut _, 0 as *const _); - assert!(!job.is_null()); - let r = jobapi2::AssignProcessToJobObject(job, me); - handleapi::CloseHandle(job); - r != 0 - } -} - #[cargo_test] fn ctrl_c_kills_everyone() { - if !enabled() { - return; - } - let listener = TcpListener::bind("127.0.0.1:0").unwrap(); let addr = listener.local_addr().unwrap();