Skip to content

Commit

Permalink
Merge pull request #225 from embassy-rs/esp-hil
Browse files Browse the repository at this point in the history
Refactor l2cap hil test
  • Loading branch information
lulf authored Jan 9, 2025
2 parents a7a524f + 7928ca7 commit 0c6ad54
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 289 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
- name: Test
env:
RUST_LOG: trace
RUST_TEST_THREADS: 1
run: |
cd host
cargo test --features log --test '*' -- --nocapture
Expand All @@ -90,7 +91,7 @@ jobs:
example-tests:
runs-on: self-hosted
needs: [build]
needs: [build, integration-tests]
steps:
- uses: actions/checkout@v4
- name: Checkout
Expand All @@ -117,6 +118,7 @@ jobs:
- name: Test
env:
RUST_LOG: info
RUST_TEST_THREADS: 1
run: |
cd examples/tests
find .
Expand Down
3 changes: 1 addition & 2 deletions examples/esp32/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions examples/nrf-sdc/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions examples/rp-pico-w/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions examples/serial-hci/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 23 additions & 10 deletions examples/tests/src/probe/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use probe_rs::flashing::Format;
use probe_rs::probe::list::Lister;
use probe_rs::probe::DebugProbeSelector;
use probe_rs::{Permissions, Session};
Expand Down Expand Up @@ -32,11 +33,17 @@ pub struct ProbeSelector {
targets: Vec<(AtomicBool, TargetConfig)>,
}

#[derive(Debug)]
pub struct Target<'d> {
config: TargetConfig,
taken: &'d AtomicBool,
}

pub struct Firmware {
pub data: Vec<u8>,
pub format: Format,
}

impl ProbeSelector {
fn new(config: ProbeConfig) -> Self {
let mut targets = Vec::new();
Expand Down Expand Up @@ -71,18 +78,21 @@ impl ProbeSelector {
}

impl<'d> Target<'d> {
pub fn flash(self, elf: Vec<u8>) -> Result<TargetRunner<'d>, anyhow::Error> {
pub fn flash(self, fw: Firmware) -> Result<TargetRunner<'d>, anyhow::Error> {
let probe = self.config.probe.clone();
let p: DebugProbeSelector = probe.try_into()?;
log::info!("Debug probe selector created");
let t = probe_rs::config::get_target_by_name(&self.config.chip)?;
log::info!("Target created");

let lister = Lister::new();
log::info!("Opening probe");
let probe = lister.open(p)?;

let perms = Permissions::new().allow_erase_all();
log::info!("Attaching probe");
let mut session = probe.attach(t, perms)?;
let opts = run::Options { do_flash: true };
let mut flasher = run::Flasher::new(elf, opts);
let mut flasher = run::Flasher::new(fw);
flasher.flash(&mut session)?;
Ok(TargetRunner {
_target: self,
Expand Down Expand Up @@ -112,12 +122,15 @@ impl<'d> TargetRunner<'d> {
})
.await
.unwrap();
result

//let mut res = String::new();
//for entry in entries {
// writeln!(&mut res, "{} - {}", entry.level, entry.message).unwrap();
//}
//(ok, res.into_bytes())
match result {
Ok(halted) => {
if halted {
Err(anyhow::anyhow!("Firmware stopped"))
} else {
Ok(())
}
}
Err(e) => Err(e.into()),
}
}
}
Loading

0 comments on commit 0c6ad54

Please sign in to comment.