iceoryx2_bb_testing/lib.rs
1// Copyright (c) 2023 Contributors to the Eclipse Foundation
2//
3// See the NOTICE file(s) distributed with this work for additional
4// information regarding copyright ownership.
5//
6// This program and the accompanying materials are made available under the
7// terms of the Apache Software License 2.0 which is available at
8// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
9// which is available at https://opensource.org/licenses/MIT.
10//
11// SPDX-License-Identifier: Apache-2.0 OR MIT
12
13//! Testing utilities and helpers.
14//!
15//! These utilities may leverage components in the building blocks layer of
16//! the architecture.
17//!
18//! Components from [`iceoryx2_pal_testing`] are re-exported for convenience
19//! of use in upper layers.
20
21#![cfg_attr(not(feature = "std"), no_std)]
22#![warn(clippy::alloc_instead_of_core)]
23#![warn(clippy::std_instead_of_alloc)]
24#![warn(clippy::std_instead_of_core)]
25
26extern crate alloc;
27
28pub use iceoryx2_pal_testing::*;
29pub mod abandon_tracker;
30pub mod allocator;
31pub mod instantiate_conformance_tests_macro;
32pub mod lifetime_tracker;
33pub mod test_harness;
34
35pub use inventory;
36#[cfg(feature = "std")]
37pub use libtest_mimic;
38
39/// Default number of test threads for the custom test harness.
40///
41/// Tests using [`iceoryx2_pal_testing::lifetime_tracker::LifetimeTracker`] rely on global mutable state that is not
42/// safe to access concurrently. Serial execution is required unless the caller
43/// explicitly overrides this via `--test-threads`.
44#[cfg(feature = "std")]
45pub const DEFAULT_TEST_THREADS: usize = 1;
46
47pub enum RunMode {
48 Normal,
49 Ignore(Option<&'static str>),
50 ExpectPanic(Option<&'static str>),
51}
52
53pub enum RequiresStd {
54 No,
55 Yes(Option<&'static str>),
56}
57
58pub struct TestCase {
59 pub module: &'static str,
60 pub name: &'static str,
61 pub test_fn: fn(),
62 pub run_mode: RunMode,
63 pub requires_std: RequiresStd,
64}
65inventory::collect!(TestCase);
66
67pub mod internal {
68 #[cfg(any(target_os = "linux", target_os = "nto"))]
69 pub use iceoryx2_pal_posix::posix::abort;
70 pub use iceoryx2_pal_print::cout;
71 pub use iceoryx2_pal_print::coutln;
72}