Closed lkoba closed 2 years ago
That shouldn't happen, as we have a patch for pthread rwlocks for esp-idf 4.3. If you enable the native
feature of esp-idf-sys, and use esp-idf 4.4 by putting the following in .cargo/config.toml
:
ESP_IDF_VERSION = { value = "branch:release/v4.4" }
That should fix this, but I'm not sure how it happens in the first place. Any ideas @ivmarkov?
@lkoba Is esp_idf_sys::link_patches()
being called from your tests?
No. After adding it there was some progress, I'm getting a different error now.
main.rs
use esp_idf_sys as _;
fn main() {
esp_idf_sys::link_patches();
println!("Hello, world!");
}
#[cfg(test)]
mod tests {
#[test]
fn one() {
esp_idf_sys::link_patches();
assert_eq!(2 + 2, 4);
}
}
Running cargo test
now outputs:
Compiling rust-probando-tests v0.1.0 (/workdir/rust-probando-tests)
Finished test [optimized + debuginfo] target(s) in 1.81s
Running unittests (target/xtensa-esp32-espidf/debug/deps/rust_probando_tests-b7454db5234f6fbd)
/workdir/rust-probando-tests/target/xtensa-esp32-espidf/debug/deps/rust_probando_tests-b7454db5234f6fbd: 1: Syntax error: "(" unexpected
error: test failed, to rerun pass '--bin rust-probando-tests'
I'm taking a step back and trying to understand what you are trying to achieve here with the tests. The key here is that you are cross-compiling. In other words, the binary (your main
function) is not complied and cannot run on the host platform:
esp-idf-sys
, esp-idf-svc
, etcetera) then by definition you cannot "run" these tests on the host platform either, as the host platform is not an ESP. So you need a way to "plug" an emulator or a real board into the cargo test
capabilities and somehow instruct cargo to (a) compile these tests for ESP and (b) run them inside the emulator. I don't think any of these capabilities are available today with stock cargo test
.So to summarize, I don't think you can do (1) with cargo test
. You can do (2) with cargo test
, but only for your platform-independent code, and you need to isolate it in another crate. This link might shed some light here - and - it also seems to contain info how you can do on-target testing using probe-run and stuff: https://ferrous-systems.com/blog/test-embedded-app/
The link you sent is exactly what I was looking for. Thanks!
cargo test
fails both on cmake and cargo projects:Is this a local issue on my installation? Which is the recommended way to test an app developed with this template?
Right now I'm moving all the code that doesn't interact with ESP-IDF functions to a different crate and run tests there.