Skip to content

test(fit): add score_time clock integration test - #300

Open
clanghans wants to merge 1 commit into
eclipse-score:mainfrom
etas-contrib:feature/score-time-integration-test
Open

test(fit): add score_time clock integration test#300
clanghans wants to merge 1 commit into
eclipse-score:mainfrom
etas-contrib:feature/score-time-integration-test

Conversation

@clanghans

Copy link
Copy Markdown

What

Adds a feature integration test (FIT) for the score_time clock library.
score_time is already pinned in known_good.json (and the generated
bazel_common/score_modules_target_sw.MODULE.bazel), but so far it had no
integration test coverage. This adds one following the existing FIT pattern
(C++ scenario binary + pytest driver).

Scope

Three C++ scenarios exercise the public Clock<Tag> API and self-validate,
throwing (process exit 101) on failure:

  • time.system_clock_nowSystemClock::Now() tracks the host system clock
    within a generous tolerance (catches an epoch-zero stub / unlinked backend).
  • time.steady_clock_now — two SteadyClock::Now() readings are monotonic.
  • time.high_res_steady_clock_nowHighResSteadyClock::Now() is non-zero and
    monotonic.

Each scenario emits its reading as a structured JSON log line. The pytest FIT
case (tests/time/test_clock_now.py) drives each scenario and asserts the exit
code plus the emitted reading. score_time is C++ only, so the tests are
parametrized with version=["cpp"].

Deferred (not in this PR): VehicleTime (requires explicit Init()), and the
time_daemon / time_slave / ts_client processes (better suited to ITF/QEMU tests).

Files

  • feature_integration_tests/test_scenarios/cpp/src/scenarios/time/ — new scenarios + group mod.cpp
  • feature_integration_tests/test_scenarios/cpp/src/internals/time/clock_log.h — small JSON log helper
  • feature_integration_tests/test_scenarios/cpp/src/scenarios/mod.cpp — register the time group
  • feature_integration_tests/test_scenarios/cpp/BUILD — add the three @score_time clock deps
  • feature_integration_tests/test_cases/tests/time/test_clock_now.py — pytest FIT case

Verification

  • bazel build --config=linux-x86_64 //feature_integration_tests/test_scenarios/cpp:cpp_test_scenarios — builds with the score_time deps.
  • Ran each scenario binary directly — exit 0 with valid readings.
  • bazel test --config=linux-x86_64 //feature_integration_tests/test_cases:fit_cpp — all tests pass (6 new time tests + existing suite).
  • Python (ruff) and Starlark (buildifier) format checks pass.

Add a feature integration test for the score_time clock library, which was
already pinned in known_good.json but had no test coverage.

Three C++ scenarios exercise the public Clock API and self-validate:
- system_clock_now: reading tracks the host system clock within tolerance
- steady_clock_now: two readings are monotonic
- high_res_steady_clock_now: reading is non-zero and monotonic

A pytest FIT case drives each scenario and asserts the exit code plus the
emitted reading. Wire the scenarios into the root group and add the score_time
clock deps to the cpp_test_scenarios binary.

@PiotrKorkus PiotrKorkus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

good for basic smoke tests

did you consider any feature reqs? could you add the mapping?

I would suggest adding a scenario where we do a couple of ticks in a loop, assert all are not decreasing, then sleep for some known duration and compare again next tick.

pytestmark = pytest.mark.parametrize("version", ["cpp"], scope="class")


class ClockScenario(FitScenario):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

redundant? should be possible to use FitScenario directly

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