From ec371ec7c840f31d9d34899fe025b324a72622f1 Mon Sep 17 00:00:00 2001 From: Christian Burke Date: Sun, 6 Mar 2022 10:13:33 -0800 Subject: [PATCH] More granular use of `serial` in devices/bpf.rs Also move extraneous `use` statement. --- crates/libcgroups/src/v2/devices/bpf.rs | 54 +++++++++---------- .../libcgroups/src/v2/devices/controller.rs | 2 - 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/crates/libcgroups/src/v2/devices/bpf.rs b/crates/libcgroups/src/v2/devices/bpf.rs index 628f14881a..ad5049a219 100644 --- a/crates/libcgroups/src/v2/devices/bpf.rs +++ b/crates/libcgroups/src/v2/devices/bpf.rs @@ -142,15 +142,15 @@ pub mod prog { #[cfg(test)] mod tests { - use serial_test::serial; - use super::prog; use crate::v2::devices::mocks::{mock_libbpf_sys, mock_libc}; use errno::{set_errno, Errno}; use libc::{ENOSPC, ENOSYS}; + use serial_test::serial; + #[test] - #[serial] // mock contexts are shared + #[serial(libbpf_sys)] // mock contexts are shared fn test_bpf_load() { // eBPF uses 64-bit instructions let instruction_zero: &[u8] = &[0x0, 0x0, 0x0, 0x0]; @@ -172,7 +172,23 @@ mod tests { } #[test] - #[serial] // mock contexts are shared + #[serial(libbpf_sys)] // mock contexts are shared + fn test_bpf_attach() { + // arrange + let attach = mock_libbpf_sys::bpf_prog_attach_context(); + + // expect + attach.expect().once().returning(|_, _, _, _| 0); + + // act + let r = prog::attach(0, 0); + + // assert + assert!(r.is_ok()); + } + + #[test] + #[serial(libbpf_sys)] // mock contexts are shared fn test_bpf_load_error() { // eBPF uses 64-bit instructions let instruction_zero: &[u8] = &[0x0, 0x0, 0x0, 0x0]; @@ -194,7 +210,7 @@ mod tests { } #[test] - #[serial] // mock contexts are shared + #[serial(libbpf_sys)] // mock contexts are shared fn test_bpf_query() { // arrange let query = mock_libbpf_sys::bpf_prog_query_context(); @@ -240,7 +256,7 @@ mod tests { } #[test] - #[serial] // mock contexts are shared + #[serial(libbpf_sys)] // mock contexts are shared fn test_bpf_query_recoverable_error() { // arrange let query = mock_libbpf_sys::bpf_prog_query_context(); @@ -286,7 +302,7 @@ mod tests { } #[test] - #[serial] // mock contexts are shared + #[serial(libbpf_sys)] // mock contexts are shared fn test_bpf_query_other_error() { // arrange let query = mock_libbpf_sys::bpf_prog_query_context(); @@ -315,7 +331,7 @@ mod tests { } #[test] - #[serial] // mock contexts are shared + #[serial(libbpf_sys)] // mock contexts are shared fn test_bpf_detach2() { // arrange let detach2 = mock_libbpf_sys::bpf_prog_detach2_context(); @@ -331,7 +347,7 @@ mod tests { } #[test] - #[serial] // mock contexts are shared + #[serial(libbpf_sys)] // mock contexts are shared fn test_bpf_detach2_error() { // arrange let detach2 = mock_libbpf_sys::bpf_prog_detach2_context(); @@ -347,23 +363,7 @@ mod tests { } #[test] - #[serial] // mock contexts are shared - fn test_bpf_attach() { - // arrange - let attach = mock_libbpf_sys::bpf_prog_attach_context(); - - // expect - attach.expect().once().returning(|_, _, _, _| 0); - - // act - let r = prog::attach(0, 0); - - // assert - assert!(r.is_ok()); - } - - #[test] - #[serial] // mock contexts are shared + #[serial(libc)] // mock contexts are shared fn test_bump_memlock_rlimit() { // arrange let setrlimit = mock_libc::setrlimit_context(); @@ -379,7 +379,7 @@ mod tests { } #[test] - #[serial] // mock contexts are shared + #[serial(libc)] // mock contexts are shared fn test_bump_memlock_rlimit_error() { // arrange let setrlimit = mock_libc::setrlimit_context(); diff --git a/crates/libcgroups/src/v2/devices/controller.rs b/crates/libcgroups/src/v2/devices/controller.rs index 28bdeeb4ff..f3592a883d 100644 --- a/crates/libcgroups/src/v2/devices/controller.rs +++ b/crates/libcgroups/src/v2/devices/controller.rs @@ -101,8 +101,6 @@ impl Devices { #[cfg(test)] mod tests { - use serial_test::serial; - use super::*; use crate::test::setup; use serial_test::serial;