Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ci tests #48

Merged
merged 73 commits into from
Jan 10, 2025
Merged
Changes from 1 commit
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
5401d82
cold start tests are now generic
ScottGibb Dec 18, 2024
4287836
setting register tests now generic
ScottGibb Dec 18, 2024
0bdc57b
updated CI to use Linux Tests
ScottGibb Dec 18, 2024
e6027ae
fixed markdown lint issue
ScottGibb Dec 18, 2024
89a460b
refactored into test crate
ScottGibb Dec 18, 2024
33219f9
updated CI and tests documentation
ScottGibb Dec 18, 2024
5fca42c
restructured tests and now use common folder. Paths work and can call…
ScottGibb Dec 18, 2024
8109336
added breaking changes. Cant seem to get the i2c shared bus to work i…
ScottGibb Dec 18, 2024
060689b
reverted change
ScottGibb Dec 18, 2024
498f4ba
fixed bus mutex example
ScottGibb Dec 18, 2024
dd93838
fixed readme links
ScottGibb Dec 18, 2024
fb47816
added first stab at esp test harness
ScottGibb Dec 18, 2024
cb5356e
Attempting to pass i2c
ScottGibb Dec 19, 2024
c49d893
rearranging dependencies
ScottGibb Dec 19, 2024
026f8a1
cargo test runs but cant link rust-lld
ScottGibb Dec 19, 2024
d7f5790
Start from scratch
ScottGibb Dec 19, 2024
340bc55
removed old workspace
ScottGibb Dec 19, 2024
b79013f
test framework works using
ScottGibb Dec 19, 2024
e93d7df
removed unecessary log feature
ScottGibb Dec 19, 2024
4396642
removed extra dependancies
ScottGibb Dec 19, 2024
2e9f9b0
doc changes
ScottGibb Dec 19, 2024
9398465
added first esp32 i2c test
ScottGibb Dec 19, 2024
8d58422
removed unused aliases
ScottGibb Dec 19, 2024
7f9e625
restructured tests to make reusable tests
ScottGibb Dec 20, 2024
ea16514
Seperated workspaces as the MCU environemnts might have different loc…
ScottGibb Dec 20, 2024
e486a48
removed them from library workspace
ScottGibb Dec 20, 2024
620d21e
removed unecessary noise
ScottGibb Dec 20, 2024
a22d536
Updated docs
ScottGibb Dec 20, 2024
2d3d492
updated examples
ScottGibb Dec 20, 2024
e495fd6
cold_start_tests confirmed working
ScottGibb Dec 20, 2024
9e1d09f
added setting_register_tests
ScottGibb Dec 20, 2024
4b2cc49
added CI updated tests
ScottGibb Dec 20, 2024
3c3fb7e
Fixed broken links
ScottGibb Dec 20, 2024
800199a
updated lint checks for new tests directory
ScottGibb Dec 20, 2024
955bb53
moved esp32c3 example
ScottGibb Dec 20, 2024
8bb6a76
fixed workflows
ScottGibb Dec 20, 2024
037afee
fixed rust analyser
ScottGibb Dec 20, 2024
2baa216
Fixed Links
ScottGibb Dec 20, 2024
f8de629
addressing clippy warning
ScottGibb Dec 20, 2024
44c55de
Updated docs
ScottGibb Dec 20, 2024
d79c452
added probe-rs to pipeline
ScottGibb Dec 20, 2024
3def8c8
[MegaLinter] Apply linters automatic fixes (#49)
ScottGibb Dec 20, 2024
dc4d4e6
fixing install
ScottGibb Dec 20, 2024
4269f75
Added missing dependencies
ScottGibb Dec 20, 2024
24552be
removing bininstall
ScottGibb Dec 20, 2024
36daeef
debugging
ScottGibb Dec 20, 2024
3e40daf
adding probe-rs
ScottGibb Dec 20, 2024
4f71aeb
Added back in tests
ScottGibb Dec 20, 2024
3c65820
[MegaLinter] Apply linters automatic fixes (#50)
ScottGibb Dec 20, 2024
80d1dc3
fixed apt in workflow
ScottGibb Dec 20, 2024
469ad2d
fixed mut and imports
ScottGibb Dec 20, 2024
351639a
fixed public
ScottGibb Dec 20, 2024
1d46129
added probe specifics
ScottGibb Dec 20, 2024
0473c00
added probe reset
ScottGibb Dec 20, 2024
e9800e3
updating probe-rs install
ScottGibb Dec 23, 2024
c7372c1
fixing cmd
ScottGibb Dec 23, 2024
eb1b5c2
cahnging runner to use debian instead of ubuntu
ScottGibb Dec 23, 2024
8dff4d0
swapping to bookworm
ScottGibb Dec 23, 2024
623d4a6
tagging bookworm docker version
ScottGibb Dec 23, 2024
8e7b07b
tagged version
ScottGibb Dec 23, 2024
fed0b47
added missing installs
ScottGibb Dec 23, 2024
8a9b071
Splitting tests up
ScottGibb Dec 23, 2024
cd62a45
adding missing source
ScottGibb Dec 23, 2024
53b3a1f
correcting order
ScottGibb Dec 23, 2024
47ef3b5
disabled faulty test
ScottGibb Dec 23, 2024
86ce346
fixed comment string
ScottGibb Dec 23, 2024
a2f834c
removed duplicated project
ScottGibb Jan 6, 2025
734642f
added config variable
ScottGibb Jan 6, 2025
df236c3
fixed double quoting
ScottGibb Jan 6, 2025
624cbe7
formatting
ScottGibb Jan 6, 2025
8500b07
added short readme
ScottGibb Jan 7, 2025
c80e9af
updated broken link
ScottGibb Jan 8, 2025
dd2ff55
reduced boiler plate
ScottGibb Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactored into test crate
ScottGibb committed Dec 18, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
sirtoobii Tobias Bossert
commit 89a460bb8deb1aa6056b7f6df2027d8655eacdd3
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -45,4 +45,5 @@ members = [
"examples/esp32-c3",
"utils",
"./",
]
"tests",
]
2 changes: 1 addition & 1 deletion examples/esp32-c3/Cargo.toml
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ esp-backtrace = { version = "0.14.0", features = [
esp-hal = { version = "0.22.0", features = ["esp32c3"] }
esp-println = { version = "0.12.0", features = ["esp32c3", "log"] }
log = { version = "0.4.21" }
tmag5273 = { path = "../../", features = ["log"] }
tmag5273 = { path = "../../" }

# [profile.dev]
# # Rust debug is too slow.
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -42,9 +42,6 @@
#![no_std]
mod config;

#[cfg(test)]
mod tests;

pub mod registers;
pub mod types;
pub use config::*;
16 changes: 16 additions & 0 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "tests"
version = "0.1.0"
edition = "2021"

[dependencies]
embedded-hal = "1.0.0"
arbitrary-int = "1.2.7"
tmag5273 = { path = "../" }
utils = { path = "../utils", default-features = false }

[features]
default = ["std"]

std = ["utils/std"]
rpi = ["utils/rpi"]
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//! This test suite is for the SparkFun breakout board for the TMAG5273 sensor on Mac OS.
//! It tests from a cold boot in which the configuration registers should be at their defaults

use crate::*;
use registers::*;
use tmag5273::*;
use types::*;

const SENSOR_PART: DeviceVersion = DeviceVersion::TMAG5273B1;

macro_rules! test_default_register {
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use crate::*;
use registers::*;
use tmag5273::*;
use types::*;

const SENSOR_PART: DeviceVersion = DeviceVersion::TMAG5273B1;

/// Helper macro to clear a register to its default value
macro_rules! reset_register {
@@ -19,7 +23,7 @@ pub fn generic_test_is_connected<I2C>(i2c: I2C)
where
I2C: embedded_hal::i2c::I2c,
{
let mut mag_sensor = TMag5273::new(i2c, DeviceVersion::TMAG5273B1).unwrap();
let mut mag_sensor = TMag5273::new(i2c, SENSOR_PART).unwrap();
let is_connected = mag_sensor.is_connected();
assert!(is_connected);
}
@@ -28,16 +32,16 @@ pub fn generic_test_create_tmag5273<I2C>(i2c: I2C)
where
I2C: embedded_hal::i2c::I2c,
{
let mag_sensor = TMag5273::new(i2c, DeviceVersion::TMAG5273B1);
let mag_sensor = TMag5273::new(i2c, SENSOR_PART);
assert!(mag_sensor.is_ok());
}

pub fn generic_test_set_reset_device_config_1_register<I2C>(i2c: I2C)
where
I2C: embedded_hal::i2c::I2c,
{
let mut mag_sensor = TMag5273::new(i2c, DeviceVersion::TMAG5273B1)
.expect("Failed to create mag sensor instance");
let mut mag_sensor =
TMag5273::new(i2c, SENSOR_PART).expect("Failed to create mag sensor instance");
reset_register!(DeviceConfig1Register, mag_sensor);

let new_device_config_1 = DeviceConfig1Register::builder()
@@ -65,8 +69,8 @@ pub fn generic_test_reset_device_config_2_register<I2C>(i2c: I2C)
where
I2C: embedded_hal::i2c::I2c,
{
let mut mag_sensor = TMag5273::new(i2c, DeviceVersion::TMAG5273B1)
.expect("Failed to create mag sensor instance");
let mut mag_sensor =
TMag5273::new(i2c, SENSOR_PART).expect("Failed to create mag sensor instance");
reset_register!(DeviceConfig2Register, mag_sensor);

let new_device_config_2 = DeviceConfig2Register::builder()
@@ -100,7 +104,7 @@ where

// // Set the new I2C Address Register

// let mut mag_sensor = TMag5273::new(i2c, DeviceVersion::TMAG5273B1).unwrap();
// let mut mag_sensor = TMag5273::new(i2c, SENSOR_PART).unwrap();

// let new_i2c_address_register = I2cAddressRegister::builder()
// .with_i2c_address_update_enabled(true)
@@ -117,7 +121,7 @@ where
// // Connect to the sensor on the new address

// let mut mag_sensor =
// TMag5273::new_with_address(i2c, new_address, DeviceVersion::TMAG5273B1).unwrap();
// TMag5273::new_with_address(i2c, new_address, SENSOR_PART).unwrap();

// // Check that the Sensor is connected with the new address
// assert!(mag_sensor.is_connected());
@@ -138,15 +142,15 @@ where

// // Check if the device is back to normal address now

// let mut mag_sensor = TMag5273::new(i2c, DeviceVersion::TMAG5273B1).unwrap();
// let mut mag_sensor = TMag5273::new(i2c, SENSOR_PART).unwrap();
// assert!(mag_sensor.is_connected());
// }

pub fn generic_test_set_reset_int_config_1_register<I2C>(i2c: I2C)
where
I2C: embedded_hal::i2c::I2c,
{
let mut mag_sensor = TMag5273::new(i2c, DeviceVersion::TMAG5273B1).unwrap();
let mut mag_sensor = TMag5273::new(i2c, SENSOR_PART).unwrap();
reset_register!(InterruptConfigRegister, mag_sensor);

let new_int_config_1 = InterruptConfigRegister::builder()
@@ -176,8 +180,8 @@ pub fn generic_test_set_reset_sensor_config_1_register<I2C>(i2c: I2C)
where
I2C: embedded_hal::i2c::I2c,
{
let mut mag_sensor = TMag5273::new(i2c, DeviceVersion::TMAG5273B1)
.expect("Failed to create mag sensor instance");
let mut mag_sensor =
TMag5273::new(i2c, SENSOR_PART).expect("Failed to create mag sensor instance");
reset_register!(SensorConfig1Register, mag_sensor);

// Set the new Sensor Config 1 Register
@@ -208,8 +212,8 @@ pub fn generic_test_set_reset_sensor_config_2_register<I2C>(i2c: I2C)
where
I2C: embedded_hal::i2c::I2c,
{
let mut mag_sensor = TMag5273::new(i2c, DeviceVersion::TMAG5273B1)
.expect("Failed to create mag sensor instance");
let mut mag_sensor =
TMag5273::new(i2c, SENSOR_PART).expect("Failed to create mag sensor instance");
reset_register!(SensorConfig2Register, mag_sensor);

let new_sensor_config_2 = SensorConfig2Register::builder()
@@ -239,8 +243,8 @@ where
{
// Put the device in a known state

let mut mag_sensor = TMag5273::new(i2c, DeviceVersion::TMAG5273B1)
.expect("Failed to create mag sensor instance");
let mut mag_sensor =
TMag5273::new(i2c, SENSOR_PART).expect("Failed to create mag sensor instance");
reset_register!(TConfigRegister, mag_sensor);

let temp_threshold = 54;
3 changes: 3 additions & 0 deletions src/tests/mod.rs → tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[cfg(test)]
mod generic_cold_start_tests;
#[cfg(test)]
mod generic_setting_registers_tests;
#[cfg(test)]
pub mod linux;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::tests::generic_cold_start_tests::*;
use crate::generic_cold_start_tests::*;
use utils::setup_i2c;

#[test]
fn test_device_id() {
let i2c = setup_i2c().unwrap();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::tests::generic_setting_registers_tests::*;
use crate::generic_setting_registers_tests::*;
use utils::setup_i2c;

#[test]