-
Notifications
You must be signed in to change notification settings - Fork 14
hmon: add positive path unit tests for HMON FFI #83
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,3 +113,94 @@ extern "C" fn health_monitor_destroy(handle: FFIHandle) { | |
| let _ = Box::from_raw(handle as *mut HealthMonitor); | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use crate::deadline::ffi::{deadline_monitor_builder_create, deadline_monitor_cpp_destroy}; | ||
| use crate::ffi::{ | ||
| health_monitor_builder_add_deadline_monitor, health_monitor_builder_build, health_monitor_builder_create, | ||
| health_monitor_builder_destroy, health_monitor_destroy, health_monitor_get_deadline_monitor, | ||
| health_monitor_start, | ||
| }; | ||
| use crate::IdentTag; | ||
|
|
||
| #[test] | ||
| fn health_monitor_builder_create_ok() { | ||
| let health_monitor_builder_handle = health_monitor_builder_create(); | ||
| assert!(!health_monitor_builder_handle.is_null()); | ||
arkjedrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Clean-up. | ||
| // NOTE: `health_monitor_builder_destroy` positive path is already tested here. | ||
| health_monitor_builder_destroy(health_monitor_builder_handle); | ||
| } | ||
|
|
||
| #[test] | ||
| fn health_monitor_builder_add_deadline_monitor_ok() { | ||
| let health_monitor_builder_handle = health_monitor_builder_create(); | ||
| let deadline_monitor_tag = IdentTag::new("deadline_monitor"); | ||
| let deadline_monitor_builder_handle = deadline_monitor_builder_create(); | ||
| health_monitor_builder_add_deadline_monitor( | ||
| health_monitor_builder_handle, | ||
| &deadline_monitor_tag as *const IdentTag, | ||
| deadline_monitor_builder_handle, | ||
| ); | ||
arkjedrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Clean-up. | ||
| health_monitor_builder_destroy(health_monitor_builder_handle); | ||
| } | ||
|
|
||
| #[test] | ||
| fn health_monitor_builder_build_ok() { | ||
| let health_monitor_builder_handle = health_monitor_builder_create(); | ||
| let health_monitor_handle = health_monitor_builder_build(health_monitor_builder_handle, 200, 100); | ||
| assert!(!health_monitor_handle.is_null()); | ||
|
Comment on lines
+154
to
+156
|
||
|
|
||
| // Clean-up. | ||
| // NOTE: `health_monitor_destroy` positive path is already tested here. | ||
| health_monitor_destroy(health_monitor_handle); | ||
| } | ||
|
|
||
| #[test] | ||
| fn health_monitor_get_deadline_monitor_ok() { | ||
| let health_monitor_builder_handle = health_monitor_builder_create(); | ||
| let deadline_monitor_tag = IdentTag::new("deadline_monitor"); | ||
| let deadline_monitor_builder_handle = deadline_monitor_builder_create(); | ||
| health_monitor_builder_add_deadline_monitor( | ||
| health_monitor_builder_handle, | ||
| &deadline_monitor_tag as *const IdentTag, | ||
| deadline_monitor_builder_handle, | ||
| ); | ||
| let health_monitor_handle = health_monitor_builder_build(health_monitor_builder_handle, 200, 100); | ||
|
|
||
| let deadline_monitor_handle = | ||
| health_monitor_get_deadline_monitor(health_monitor_handle, &deadline_monitor_tag as *const IdentTag); | ||
| assert!(!deadline_monitor_handle.is_null()); | ||
|
|
||
| // Clean-up. | ||
| deadline_monitor_cpp_destroy(deadline_monitor_handle); | ||
| health_monitor_destroy(health_monitor_handle); | ||
| } | ||
|
|
||
| #[test] | ||
| fn health_monitor_start_ok() { | ||
| let health_monitor_builder_handle = health_monitor_builder_create(); | ||
| let deadline_monitor_tag = IdentTag::new("deadline_monitor"); | ||
| let deadline_monitor_builder_handle = deadline_monitor_builder_create(); | ||
| health_monitor_builder_add_deadline_monitor( | ||
| health_monitor_builder_handle, | ||
| &deadline_monitor_tag as *const IdentTag, | ||
| deadline_monitor_builder_handle, | ||
| ); | ||
| let health_monitor_handle = health_monitor_builder_build(health_monitor_builder_handle, 200, 100); | ||
|
Comment on lines
+186
to
+194
|
||
|
|
||
| let deadline_monitor_handle = | ||
| health_monitor_get_deadline_monitor(health_monitor_handle, &deadline_monitor_tag as *const IdentTag); | ||
| assert!(!deadline_monitor_handle.is_null()); | ||
|
|
||
| health_monitor_start(health_monitor_handle); | ||
|
|
||
| // Clean-up. | ||
| deadline_monitor_cpp_destroy(deadline_monitor_handle); | ||
| health_monitor_destroy(health_monitor_handle); | ||
|
Comment on lines
+184
to
+204
|
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.