Skip to content

hmon: add positive path unit tests for HMON FFI#83

Merged
pawelrutkaq merged 1 commit intoeclipse-score:mainfrom
qorix-group:arkjedrz_add-hmon-ffi-unit-tests
Feb 19, 2026
Merged

hmon: add positive path unit tests for HMON FFI#83
pawelrutkaq merged 1 commit intoeclipse-score:mainfrom
qorix-group:arkjedrz_add-hmon-ffi-unit-tests

Conversation

@arkjedrz
Copy link
Contributor

Only positive path is tested.
Negative path will require rework to avoid aborts.

@github-actions
Copy link

github-actions bot commented Feb 18, 2026

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.4.2) and connecting to it...
INFO: Invocation ID: f604f3bf-a701-4324-be3f-d48ac78162dc
Computing main repo mapping: 
Computing main repo mapping: 
WARNING: For repository 'rules_python', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'rules_cc', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'aspect_rules_lint', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'download_utils', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'googletest', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'score_rust_policies', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Loading: 0 packages loaded
    currently loading: 
Analyzing: target //:license-check (1 packages loaded, 0 targets configured)
Analyzing: target //:license-check (1 packages loaded, 0 targets configured)

Analyzing: target //:license-check (49 packages loaded, 9 targets configured)

Analyzing: target //:license-check (130 packages loaded, 433 targets configured)

Analyzing: target //:license-check (148 packages loaded, 3134 targets configured)

Analyzing: target //:license-check (148 packages loaded, 5805 targets configured)

Analyzing: target //:license-check (160 packages loaded, 7817 targets configured)

Analyzing: target //:license-check (160 packages loaded, 7817 targets configured)

Analyzing: target //:license-check (160 packages loaded, 7817 targets configured)

Analyzing: target //:license-check (161 packages loaded, 7941 targets configured)

INFO: Analyzed target //:license-check (165 packages loaded, 9955 targets configured).
[10 / 16] [Prepa] JavaToolchainCompileClasses external/rules_java+/toolchains/platformclasspath_classes ... (2 actions, 1 running)
[13 / 16] JavaToolchainCompileClasses external/rules_java+/toolchains/platformclasspath_classes; 0s disk-cache, processwrapper-sandbox
[14 / 16] JavaToolchainCompileBootClasspath external/rules_java+/toolchains/platformclasspath.jar; 0s disk-cache, processwrapper-sandbox
INFO: Found 1 target...
Target //:license.check.license_check up-to-date:
  bazel-bin/license.check.license_check
  bazel-bin/license.check.license_check.jar
INFO: Elapsed time: 24.341s, Critical Path: 2.78s
INFO: 16 processes: 12 internal, 3 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 16 total actions
INFO: Running command line: bazel-bin/license.check.license_check ./formatted.txt <args omitted>
usage: org.eclipse.dash.licenses.cli.Main [-batch <int>] [-cd <url>]
       [-confidence <int>] [-ef <url>] [-excludeSources <sources>] [-help] [-lic
       <url>] [-project <shortname>] [-repo <url>] [-review] [-summary <file>]
       [-timeout <seconds>] [-token <token>]

@github-actions
Copy link

The created documentation from the pull request is available at: docu-html

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds positive path unit tests for the Health Monitor FFI (Foreign Function Interface) layer. These tests verify that the C-compatible FFI functions work correctly for successful code paths. The tests cover builder creation, destruction, deadline monitor addition, health monitor building, deadline monitor retrieval, starting the health monitor, and resource cleanup.

Changes:

  • Added 7 unit tests covering positive paths for all HMON FFI functions
  • Tests verify handle creation, manipulation, and basic cleanup operations
  • Negative path testing is deferred due to abort behavior in error cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 138 to 139
fn test_health_monitor_builder_add_deadline_monitor_ok() {
let health_monitor_builder_handle = health_monitor_builder_create();
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test names in this repo appear to use descriptive snake_case without a test_ prefix or _ok suffix. Consider renaming this test accordingly to match existing conventions.

Copilot uses AI. Check for mistakes.
Comment on lines 153 to 154
fn test_health_monitor_builder_build_ok() {
let health_monitor_builder_handle = health_monitor_builder_create();
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test names in this repo appear to use descriptive snake_case without a test_ prefix or _ok suffix. Consider renaming this test accordingly to match existing conventions.

Copilot uses AI. Check for mistakes.
Comment on lines 164 to 165
fn test_health_monitor_get_deadline_monitor_ok() {
let health_monitor_builder_handle = health_monitor_builder_create();
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test names in this repo appear to use descriptive snake_case without a test_ prefix or _ok suffix. Consider renaming this test accordingly to match existing conventions.

Copilot uses AI. Check for mistakes.
Comment on lines 185 to 186
fn test_health_monitor_start_ok() {
let health_monitor_builder_handle = health_monitor_builder_create();
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test names in this repo appear to use descriptive snake_case without a test_ prefix or _ok suffix. Consider renaming this test accordingly to match existing conventions.

Copilot uses AI. Check for mistakes.
Comment on lines +186 to +194
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);
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests repeat the same FFI setup/teardown pattern (create builder, add deadline monitor, build, optionally get deadline monitor). Consider extracting a small helper (or RAII wrapper) to reduce duplication and make cleanup rules for consumed handles harder to get wrong as more cases are added.

Copilot uses AI. Check for mistakes.
@arkjedrz arkjedrz force-pushed the arkjedrz_add-hmon-ffi-unit-tests branch from 6ef7f1d to f41385b Compare February 19, 2026 09:55
@arkjedrz arkjedrz temporarily deployed to workflow-approval February 19, 2026 09:55 — with GitHub Actions Inactive
@arkjedrz arkjedrz temporarily deployed to workflow-approval February 19, 2026 09:55 — with GitHub Actions Inactive
use crate::IdentTag;

#[test]
fn test_health_monitor_builder_create_ok() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove test_ prefix

Only positive path is tested.
Negative path will require rework to avoid aborts.
@arkjedrz arkjedrz force-pushed the arkjedrz_add-hmon-ffi-unit-tests branch from f41385b to ab9e0e8 Compare February 19, 2026 11:33
@arkjedrz arkjedrz temporarily deployed to workflow-approval February 19, 2026 11:33 — with GitHub Actions Inactive
@arkjedrz arkjedrz temporarily deployed to workflow-approval February 19, 2026 11:33 — with GitHub Actions Inactive
@pawelrutkaq pawelrutkaq merged commit 997ffa1 into eclipse-score:main Feb 19, 2026
18 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +154 to +156
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());
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build calls repeat magic numbers for cycle durations (e.g., 200 and 100). Consider introducing local constants (e.g., SUPERVISOR_CYCLE_MS, INTERNAL_CYCLE_MS) so the units/intent are clearer and changes only need to be made in one place.

Copilot uses AI. Check for mistakes.
Comment on lines +184 to +204
#[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);

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);
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

health_monitor_start_ok starts a background thread; the subsequent destroy/join can block for up to internal_cycle_ms because the worker may be sleeping. To keep the unit test suite fast and reduce timing sensitivity, consider using much smaller cycle values here (still respecting the multiple-of invariant).

Copilot uses AI. Check for mistakes.
@arkjedrz arkjedrz deleted the arkjedrz_add-hmon-ffi-unit-tests branch February 19, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments