diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22edab2..3e144cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,9 @@ jobs: - uses: actions/checkout@v4 - name: Install protobuf-compiler - run: sudo apt-get install protobuf-compiler + run: | + sudo apt-get update + sudo apt-get install protobuf-compiler - uses: bazelbuild/setup-bazelisk@v3 diff --git a/.gitignore b/.gitignore index 1065de2..ee7af05 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,4 @@ __pycache__/ /.coverage target +.clwb/ diff --git a/Cargo.lock b/Cargo.lock index b645ab2..a681164 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -288,9 +288,9 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" [[package]] name = "console" -version = "0.16.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b430743a6eb14e9764d4260d4c0d8123087d504eeb9c48f2b2a5e810dd369df4" +checksum = "03e45a4a8926227e4197636ba97a9fc9b00477e9f4bd711395687c5f0734bec4" dependencies = [ "encode_unicode", "libc 0.2.177", @@ -339,6 +339,7 @@ dependencies = [ "feo-time", "feo-tracing", "postcard", + "score_log", "serde", "serde_json", "tracing", @@ -451,9 +452,10 @@ dependencies = [ "feo-com", "feo-time", "feo-tracing", - "libc 1.0.0-alpha.1", + "libc 1.0.0-alpha.3", "mio", "postcard", + "score_log", "serde", ] @@ -464,6 +466,7 @@ dependencies = [ "iceoryx2", "nix", "rand", + "score_log", ] [[package]] @@ -481,7 +484,9 @@ version = "0.1.0" name = "feo-time" version = "0.1.0" dependencies = [ + "score_log", "serde", + "stdout_logger", "time", ] @@ -499,6 +504,8 @@ dependencies = [ "postcard", "prost", "rand", + "score_log", + "stdout_logger", "tokio", ] @@ -506,8 +513,9 @@ dependencies = [ name = "feo-tracing" version = "0.1.0" dependencies = [ - "libc 1.0.0-alpha.1", + "libc 1.0.0-alpha.3", "postcard", + "score_log", "serde", "tracing", "tracing-subscriber", @@ -884,9 +892,9 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.18.3" +version = "0.18.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9375e112e4b463ec1b1c6c011953545c65a30164fbab5b581df32b3abf0dcb88" +checksum = "25470f23803092da7d239834776d653104d551bc4d7eacaf31e6837854b8e9eb" dependencies = [ "console", "portable-atomic", @@ -904,6 +912,7 @@ dependencies = [ "ipc-channel", "log", "nix", + "score_log", "serde", ] @@ -1009,9 +1018,9 @@ checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" [[package]] name = "libc" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7222002e5385b4d9327755661e3847c970e8fbf9dea6da8c57f16e8cfbff53a8" +checksum = "e136bfa874086c78f34d6eba98c423fefe464ce57f38164d16893ba8ed358e70" [[package]] name = "libloading" @@ -1067,7 +1076,9 @@ dependencies = [ "feo-time", "feo-tracing", "postcard", + "score_log", "serde", + "stdout_logger", "tracing", ] @@ -1206,9 +1217,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "portable-atomic" -version = "1.11.1" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" [[package]] name = "portable-atomic-util" @@ -1479,6 +1490,31 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "score_log" +version = "0.0.1" +source = "git+https://github.com/eclipse-score/baselibs_rust.git?rev=1b9f2786cd746ae9745dd2e81bf9073b4185a5e2#1b9f2786cd746ae9745dd2e81bf9073b4185a5e2" +dependencies = [ + "score_log_fmt", + "score_log_fmt_macro", +] + +[[package]] +name = "score_log_fmt" +version = "0.0.1" +source = "git+https://github.com/eclipse-score/baselibs_rust.git?rev=1b9f2786cd746ae9745dd2e81bf9073b4185a5e2#1b9f2786cd746ae9745dd2e81bf9073b4185a5e2" + +[[package]] +name = "score_log_fmt_macro" +version = "0.0.1" +source = "git+https://github.com/eclipse-score/baselibs_rust.git?rev=1b9f2786cd746ae9745dd2e81bf9073b4185a5e2#1b9f2786cd746ae9745dd2e81bf9073b4185a5e2" +dependencies = [ + "proc-macro2", + "quote", + "score_log_fmt", + "syn", +] + [[package]] name = "semver" version = "1.0.27" @@ -1551,10 +1587,11 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.6" +version = "1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" dependencies = [ + "errno", "libc 0.2.177", ] @@ -1595,6 +1632,14 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "stdout_logger" +version = "0.0.1" +source = "git+https://github.com/eclipse-score/baselibs_rust.git?rev=1b9f2786cd746ae9745dd2e81bf9073b4185a5e2#1b9f2786cd746ae9745dd2e81bf9073b4185a5e2" +dependencies = [ + "score_log", +] + [[package]] name = "strsim" version = "0.11.1" @@ -1646,8 +1691,10 @@ dependencies = [ "feo-time", "feo-tracing", "ipc-channel", - "libc 1.0.0-alpha.1", + "libc 1.0.0-alpha.3", + "score_log", "serde", + "stdout_logger", "tracing", ] @@ -1826,9 +1873,9 @@ checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" [[package]] name = "unit-prefix" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "323402cff2dd658f39ca17c789b502021b3f18707c91cdf22e3838e1b4023817" +checksum = "81e544489bf3d8ef66c953931f56617f423cd4b5494be343d9b9d3dda037b9a3" [[package]] name = "utf8parse" diff --git a/Cargo.toml b/Cargo.toml index 9ffb1b1..01a25a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,16 +2,16 @@ members = [ "examples/rust/cycle-benchmark", "examples/rust/mini-adas", - "feo", - "feo-com", - "feo-cpp-build", - "feo-cpp-macros", - "feo-time", - "feo-tracer", - "feo-tracing", - "perfetto-model", - "tests/rust/feo_tests/test_agent", + "src/feo", + "src/feo-com", + "src/feo-cpp-build", + "src/feo-cpp-macros", + "src/feo-time", + "src/feo-tracing", + "src/perfetto-model", + "src/feo-tracer", "tests/rust/feo_tests", + "tests/rust/feo_tests/test_agent", ] resolver = "2" @@ -20,6 +20,14 @@ version = "0.1.0" edition = "2024" [workspace.dependencies] +feo = { path = "src/feo" } +feo-com = { path = "src/feo-com" } +feo-cpp-build = { path = "src/feo-cpp-build" } +feo-cpp-macros = { path = "src/feo-cpp-macros" } +feo-time = { path = "src/feo-time" } +feo-tracing = { path = "src/feo-tracing" } +perfetto-model = { path = "src/perfetto-model" } + anyhow = "1.0.99" argh = "0.1.13" async-stream = "0.3.6" @@ -28,12 +36,6 @@ cc = "1.2.34" console = "0.16.0" clap = { version = "4.5.50", features = ["derive"] } env_logger = "0.11.8" -feo = { path = "feo", default-features = false } -feo-com = { path = "feo-com" } -feo-cpp-build = { path = "feo-cpp-build" } -feo-cpp-macros = { path = "feo-cpp-macros" } -feo-time = { path = "feo-time" } -feo-tracing = { path = "feo-tracing" } ctrlc = { version = "3.4.4", features = ["termination"] } futures = "0.3.31" human_bytes = "0.4.3" @@ -43,18 +45,18 @@ indicatif-log-bridge = "0.2.3" libc = "1.0.0-alpha.1" log = { version = "0.4.27" } mio = { version = "1.0.4", features = ["net", "os-poll"] } -nix = { version = "0.30.1", features = ["fs", "mman", "signal"] } -perfetto-model = { path = "perfetto-model" } +nix = { version = "0.30.1", features = ["fs", "mman", "signal", "process"] } postcard = "1.1.3" prost = "0.14.1" prost-build = "0.14.1" rand = "0.9.2" -serde = "1.0.219" +serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.143" socket2 = "0.6.0" time = { version = "0.3.47", features = ["formatting", "macros", "serde"] } tokio = { version = "1.47.1", features = [ "rt", + "rt-multi-thread", "macros", "sync", "net", @@ -68,6 +70,9 @@ tracing = { version = "0.1.41", features = [ ], default-features = false } tracing-subscriber = { version = "0.3.20", default-features = false } ipc-channel = "0.20.2" +score_log = { git = "https://github.com/eclipse-score/baselibs_rust.git", rev = "1b9f2786cd746ae9745dd2e81bf9073b4185a5e2" } +stdout_logger = { git = "https://github.com/eclipse-score/baselibs_rust.git", rev = "1b9f2786cd746ae9745dd2e81bf9073b4185a5e2" } + [profile.profiling] inherits = "release" debug = true diff --git a/MODULE.bazel b/MODULE.bazel index 7aed7aa..d57f7dc 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -33,6 +33,22 @@ git_override( bazel_dep(name = "rules_rust", version = "0.67.0") bazel_dep(name = "rules_rust_prost", version = "0.67.0") +# score_crates 0.0.6 only enables ["fs", "mman"] for nix, but feo_tests also needs +# ["signal", "process"]. Define a local crate repository with the full feature set. +crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate") +crate.spec( + features = [ + "fs", + "mman", + "process", + "signal", + ], + package = "nix", + version = "0.30.1", +) +crate.from_specs(name = "feo_crates") +use_repo(crate, "feo_crates") + # Protobuf # Repo_name override is needed here for compatibility with WORKSPACE (e.g.for rules_rust_prost) # Newer protobuf versions generate warnings during compilation which will cause the build failure due @@ -42,7 +58,7 @@ bazel_dep(name = "protobuf", version = "30.2", repo_name = "com_google_protobuf" bazel_dep(name = "rules_proto", version = "7.1.0") # Tooling -bazel_dep(name = "aspect_rules_lint", version = "1.5.3") +bazel_dep(name = "aspect_rules_lint", version = "2.0.0") bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2") bazel_dep(name = "googletest", version = "1.17.0") bazel_dep(name = "score_docs_as_code", version = "3.0.0") @@ -82,7 +98,7 @@ bazel_dep(name = "score_rust_policies", version = "0.0.5", dev_dependency = True register_toolchains("//toolchain/prost:prost_toolchain") # Python toolchain -bazel_dep(name = "rules_python", version = "1.4.1") +bazel_dep(name = "rules_python", version = "1.8.3") PYTHON_VERSION = "3.12" diff --git a/examples/rust/cycle-benchmark/Cargo.toml b/examples/rust/cycle-benchmark/Cargo.toml index e640476..b42a6bc 100644 --- a/examples/rust/cycle-benchmark/Cargo.toml +++ b/examples/rust/cycle-benchmark/Cargo.toml @@ -16,6 +16,7 @@ tracing = { workspace = true } postcard = { workspace = true, features = ["experimental-derive"] } serde = { workspace = true } serde_json = { workspace = true } +score_log = { workspace = true } [build-dependencies] diff --git a/examples/rust/cycle-benchmark/src/bin/cycle_bench.rs b/examples/rust/cycle-benchmark/src/bin/cycle_bench.rs index 843f2e6..85d2050 100644 --- a/examples/rust/cycle-benchmark/src/bin/cycle_bench.rs +++ b/examples/rust/cycle-benchmark/src/bin/cycle_bench.rs @@ -21,7 +21,7 @@ const DEFAULT_FEO_CYCLE_TIME: Duration = Duration::from_millis(5); fn main() { // Uncomment one or both of the following lines for benchmarking with logging/tracing - // feo_logger::init(feo_log::LevelFilter::Debug, true, true); + // feo_logger::init(score_log::LevelFilter::Debug, true, true); // feo_tracing::init(feo_tracing::LevelFilter::TRACE); let params = Params::from_args(); diff --git a/examples/rust/mini-adas/Cargo.toml b/examples/rust/mini-adas/Cargo.toml index 1fffed0..4b90158 100644 --- a/examples/rust/mini-adas/Cargo.toml +++ b/examples/rust/mini-adas/Cargo.toml @@ -21,6 +21,8 @@ feo-time = { workspace = true } feo-tracing = { workspace = true } postcard = { workspace = true, features = ["experimental-derive"] } serde = { workspace = true, optional = true } +score_log = { workspace = true } +stdout_logger = { workspace = true } tracing = { workspace = true } [build-dependencies] @@ -29,7 +31,7 @@ feo-cpp-build = { workspace = true } [features] com_iox2 = ["feo-com/ipc_iceoryx2"] com_linux_shm = ["feo-com/ipc_linux_shm"] -default = ["com_iox2", "signalling_relayed_tcp"] +default = ["com_linux_shm", "signalling_relayed_tcp"] signalling_direct_mpsc = [] signalling_direct_tcp = [] signalling_direct_unix = [] diff --git a/src/feo-com/Cargo.toml b/src/feo-com/Cargo.toml index d6e27bb..9add7d6 100644 --- a/src/feo-com/Cargo.toml +++ b/src/feo-com/Cargo.toml @@ -7,6 +7,7 @@ edition = "2024" iceoryx2 = { workspace = true, optional = true } nix = { workspace = true, optional = true } rand = { workspace = true, optional = true } +score_log = { workspace = true } [features] default = ["ipc_linux_shm"] diff --git a/src/feo-com/src/iox2/mod.rs b/src/feo-com/src/iox2/mod.rs index e940315..414f1a5 100644 --- a/src/feo-com/src/iox2/mod.rs +++ b/src/feo-com/src/iox2/mod.rs @@ -22,7 +22,6 @@ use alloc::format; use core::fmt; use core::mem::MaybeUninit; use core::ops::{Deref, DerefMut}; -use feo_log::{error, info}; use iceoryx2::config::Config; use iceoryx2::node::{Node, NodeBuilder, NodeState}; use iceoryx2::port::publisher::Publisher; @@ -32,6 +31,7 @@ use iceoryx2::sample::Sample; use iceoryx2::sample_mut::SampleMut; use iceoryx2::sample_mut_uninit::SampleMutUninit; use iceoryx2::service::ipc; +use score_log::{error, info}; use std::process; /// Initialize topic with the given number of writers (publishers) and readers (subscribers). diff --git a/src/feo-time/Cargo.toml b/src/feo-time/Cargo.toml index 3808946..c9cf0fe 100644 --- a/src/feo-time/Cargo.toml +++ b/src/feo-time/Cargo.toml @@ -6,3 +6,11 @@ edition = "2024" [dependencies] time = { workspace = true } serde = { workspace = true } +score_log = { workspace = true } + +[dev-dependencies] +stdout_logger = { workspace = true } + +[features] +default = ["std"] +std = ["serde/std"] diff --git a/src/feo-time/src/lib.rs b/src/feo-time/src/lib.rs index 194d28c..ddc00e0 100644 --- a/src/feo-time/src/lib.rs +++ b/src/feo-time/src/lib.rs @@ -73,6 +73,7 @@ pub struct Duration(pub core::time::Duration); impl Duration { pub const ZERO: Duration = Duration(core::time::Duration::ZERO); + pub const MAX: Duration = Duration(core::time::Duration::MAX); pub fn as_secs(&self) -> u64 { self.0.as_secs() @@ -82,6 +83,10 @@ impl Duration { self.0.subsec_nanos() } + pub fn subsec_micros(&self) -> u32 { + self.0.subsec_micros() + } + #[allow(dead_code)] pub const fn from_secs(secs: u64) -> Self { Self(core::time::Duration::from_secs(secs)) @@ -590,7 +595,7 @@ impl Add for SystemTime { /// This function may panic if the resulting point in time cannot be represented by the /// underlying data structure. See [`SystemTime::checked_add`] for a version without panic. fn add(self, dur: Duration) -> SystemTime { - SystemTime(self.0.add(dur.into())) + SystemTime(self.0.add(dur.0)) } } @@ -604,7 +609,7 @@ impl Sub for SystemTime { type Output = SystemTime; fn sub(self, dur: Duration) -> SystemTime { - SystemTime(self.0.sub(dur.into())) + SystemTime(self.0.sub(dur.0)) } } diff --git a/src/feo-tracer/Cargo.toml b/src/feo-tracer/Cargo.toml index 876dc18..625dbcf 100644 --- a/src/feo-tracer/Cargo.toml +++ b/src/feo-tracer/Cargo.toml @@ -14,4 +14,6 @@ perfetto-model = { workspace = true } postcard = { workspace = true } prost = { workspace = true } rand = { workspace = true } -tokio = { workspace = true, features = ["rt-multi-thread"] } +score_log = { workspace = true } +stdout_logger = { workspace = true } +tokio = { workspace = true } diff --git a/src/feo-tracing/Cargo.toml b/src/feo-tracing/Cargo.toml index 027d2d7..7c40126 100644 --- a/src/feo-tracing/Cargo.toml +++ b/src/feo-tracing/Cargo.toml @@ -9,3 +9,4 @@ postcard = { workspace = true } serde = { workspace = true } tracing = { workspace = true } tracing-subscriber = { workspace = true } +score_log = { workspace = true } diff --git a/src/feo/Cargo.toml b/src/feo/Cargo.toml index b988704..f8cf20f 100644 --- a/src/feo/Cargo.toml +++ b/src/feo/Cargo.toml @@ -7,6 +7,7 @@ edition = "2024" feo-com = { workspace = true } feo-time = { workspace = true } feo-tracing = { workspace = true } +score_log = { workspace = true } libc = { workspace = true } mio = { workspace = true } postcard = { workspace = true, features = [ diff --git a/src/feo/src/recording/recorder.rs b/src/feo/src/recording/recorder.rs index bd3ec4a..0462230 100644 --- a/src/feo/src/recording/recorder.rs +++ b/src/feo/src/recording/recorder.rs @@ -291,13 +291,12 @@ impl MaxSize for DataDescriptionRecord<'_> { mod test { use super::*; use alloc::string::String; - use core::time::Duration; #[test] fn test_max_size_for_data_description_record() { let s = String::from_utf8(vec![b'a'; TOPIC_TYPENAME_MAX_SIZE]).expect("valid string"); let record = DataDescriptionRecord { - timestamp: Timestamp(Duration::MAX), + timestamp: Timestamp(feo_time::Duration::MAX), data_size: usize::MAX, type_name: &s, topic: &s, diff --git a/src/feo/src/recording/registry.rs b/src/feo/src/recording/registry.rs index 2ace242..27761b5 100644 --- a/src/feo/src/recording/registry.rs +++ b/src/feo/src/recording/registry.rs @@ -16,7 +16,6 @@ use crate::recording::transcoder::{ComRecTranscoderBuilder, RecordingTranscoder} use alloc::borrow::ToOwned as _; use alloc::boxed::Box; use feo_com::interface::ActivityInput; -use score_log::fmt::ScoreDebug; use serde::Serialize; use std::collections::HashMap; @@ -52,7 +51,9 @@ impl TypeRegistry { /// This method will panic if /// - a type with identical type id (i.e. the same type) has already been registered /// - the explicitly or implicitly provided type name is not unique - pub fn add( + pub fn add< + T: Serialize + postcard::experimental::max_size::MaxSize + core::fmt::Debug + score_log::fmt::ScoreDebug + 'static, + >( &mut self, type_name: Option<&'static str>, input_builder: impl Fn(&str) -> Box> + Clone + Send + 'static, @@ -144,23 +145,25 @@ macro_rules! register_types { #[test] fn test_type_registry() { + use score_log::ScoreDebug; + #[derive(Debug)] // Dummy input implementation for the test struct DummyInput; - impl ActivityInput for DummyInput { + impl ActivityInput for DummyInput { fn read(&self) -> Result, feo_com::interface::Error> { todo!() } } - #[derive(Debug, serde::Serialize, postcard::experimental::max_size::MaxSize)] + #[derive(Debug, serde::Serialize, postcard::experimental::max_size::MaxSize, ScoreDebug)] struct TestType1 {} - #[derive(Debug, serde::Serialize, postcard::experimental::max_size::MaxSize)] + #[derive(Debug, serde::Serialize, postcard::experimental::max_size::MaxSize, ScoreDebug)] struct TestType2 {} - #[derive(Debug, serde::Serialize, postcard::experimental::max_size::MaxSize)] + #[derive(Debug, serde::Serialize, postcard::experimental::max_size::MaxSize, ScoreDebug)] struct TestType3 {} let mut registry = TypeRegistry::default(); diff --git a/src/feo/src/timestamp.rs b/src/feo/src/timestamp.rs index 4e08a87..9858fbc 100644 --- a/src/feo/src/timestamp.rs +++ b/src/feo/src/timestamp.rs @@ -64,7 +64,7 @@ pub fn initialize_from(sync_info: SyncInfo) { let time_info_now = time_info_now(); // Calculate the startup time of the primary agent - let startup_time = std::time::SystemTime::UNIX_EPOCH + sync_info.since_epoch.into(); + let startup_time = std::time::SystemTime::UNIX_EPOCH + core::time::Duration::from(sync_info.since_epoch); // Calculate the time elapsed since the startup of the primary agent; // assumption is that system clocks are synchronized (but monotonic clocks can be unsynchronized). diff --git a/src/perfetto-model/build.rs b/src/perfetto-model/build.rs index f436844..a8fe7ad 100644 --- a/src/perfetto-model/build.rs +++ b/src/perfetto-model/build.rs @@ -12,5 +12,7 @@ // ******************************************************************************* fn main() -> std::io::Result<()> { + println!("cargo:rustc-check-cfg=cfg(cargo_build)"); + println!("cargo:rustc-cfg=cargo_build"); prost_build::compile_protos(&["protos/perfetto_trace.proto"], &["protos"]).map(drop) } diff --git a/src/perfetto-model/src/lib.rs b/src/perfetto-model/src/lib.rs index 338dbb9..8427c73 100644 --- a/src/perfetto-model/src/lib.rs +++ b/src/perfetto-model/src/lib.rs @@ -10,4 +10,18 @@ // // SPDX-License-Identifier: Apache-2.0 // ******************************************************************************* + +#[cfg(cargo_build)] +mod perfetto_proto { + pub mod perfetto { + pub mod protos { + include!(concat!(env!("OUT_DIR"), "/perfetto.protos.rs")); + } + } +} + +#[cfg(not(cargo_build))] +pub use perfetto_proto::perfetto::protos::*; + +#[cfg(cargo_build)] pub use perfetto_proto::perfetto::protos::*; diff --git a/tests/rust/feo_tests/BUILD b/tests/rust/feo_tests/BUILD index 191fb1f..cd05add 100644 --- a/tests/rust/feo_tests/BUILD +++ b/tests/rust/feo_tests/BUILD @@ -23,11 +23,11 @@ rust_test( data = ["//tests/rust/feo_tests/test_agent"], edition = "2024", deps = [ + "@feo_crates//:nix", "@score_crates//:clap", "@score_crates//:env_logger", "@score_crates//:ipc_channel", "@score_crates//:log", - "@score_crates//:nix", "@score_crates//:serde", ], ) diff --git a/tests/rust/feo_tests/Cargo.toml b/tests/rust/feo_tests/Cargo.toml index 451f519..4f9928d 100644 --- a/tests/rust/feo_tests/Cargo.toml +++ b/tests/rust/feo_tests/Cargo.toml @@ -9,4 +9,5 @@ ipc-channel = { workspace = true } serde = { workspace = true } nix = { workspace = true } log = { workspace = true } +score_log = { workspace = true } env_logger = { workspace = true } diff --git a/tests/rust/feo_tests/src/lib.rs b/tests/rust/feo_tests/src/lib.rs index dde6f02..90ee026 100644 --- a/tests/rust/feo_tests/src/lib.rs +++ b/tests/rust/feo_tests/src/lib.rs @@ -31,7 +31,10 @@ mod monitor; fn aquire_lock() -> MutexGuard<'static, ()> { static MUTEX: Mutex<()> = Mutex::new(()); let _ = env_logger::try_init(); - MUTEX.lock().unwrap() + match MUTEX.lock() { + Ok(guard) => guard, + Err(poisoned) => poisoned.into_inner(), + } } #[derive(Parser)] @@ -253,9 +256,22 @@ pub const TEST_AGENT_PATH: &str = "./tests/rust/feo_tests/test_agent/test_agent" impl Default for Cli { fn default() -> Self { - Self { - test_agent: PathBuf::from(TEST_AGENT_PATH), + let mut test_agent = PathBuf::from(TEST_AGENT_PATH); + if !test_agent.exists() { + // Fallback for cargo. Find the workspace root. + let mut current = std::env::current_dir().unwrap(); + loop { + let candidate = current.join("target/debug/test_agent"); + if candidate.exists() { + test_agent = candidate; + break; + } + if !current.pop() { + break; + } + } } + Self { test_agent } } } diff --git a/tests/rust/feo_tests/test_agent/Cargo.toml b/tests/rust/feo_tests/test_agent/Cargo.toml index 4210695..8f7a31f 100644 --- a/tests/rust/feo_tests/test_agent/Cargo.toml +++ b/tests/rust/feo_tests/test_agent/Cargo.toml @@ -4,8 +4,9 @@ version = "0.1.0" edition = "2024" [features] -com_iox2 = [] -com_linux_shm = [] +default = ["com_linux_shm"] +com_iox2 = ["feo-com/ipc_iceoryx2"] +com_linux_shm = ["feo-com/ipc_linux_shm"] [dependencies] feo = { workspace = true } @@ -18,3 +19,5 @@ libc = { workspace = true } clap = { workspace = true } ipc-channel = { workspace = true } serde = { workspace = true } +score_log = { workspace = true } +stdout_logger = { workspace = true }