blob: d17d2ef676d7491a687947dac00984faeef96e28 [file] [log] [blame]
Adam Snaider9121b302023-12-14 15:30:54 -08001use std::sync::Once;
Adam Snaiderc8b7e752023-09-14 14:27:53 -07002
3autocxx::include_cpp! (
4#include "aos/testing/tmpdir.h"
5
6safety!(unsafe)
7
8generate!("aos::testing::SetTestShmBase")
9);
10
11// TODO(Brian): Should we provide a proc macro attribute that handles calling this?
12/// Initializes things for a test.
13///
14/// # Panics
15///
16/// Panics if non-test initialization has already been performed.
17pub fn test_init() {
Adam Snaider9121b302023-12-14 15:30:54 -080018 static ONCE: Once = Once::new();
19 ONCE.call_once(|| {
20 aos_init::internal::init();
21 ffi::aos::testing::SetTestShmBase();
22 env_logger::builder().is_test(true).init();
23 // TODO(Brian): Do we want any of the other stuff that `:gtest_main` has?
24 });
Adam Snaiderc8b7e752023-09-14 14:27:53 -070025}