Skip to content

Introduce a counting process as a test utility - #587

Open
cameron-craig-etas wants to merge 1 commit into
eclipse-score:mainfrom
etas-contrib:feature/counting-process
Open

Introduce a counting process as a test utility#587
cameron-craig-etas wants to merge 1 commit into
eclipse-score:mainfrom
etas-contrib:feature/counting-process

Conversation

@cameron-craig-etas

@cameron-craig-etas cameron-craig-etas commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

#588

This PR introduces a "counting" process that optionally posts to a named semaphore, and also optionally report running. This is a useful testing utility for occasions where we would like to wait for a number of processes to be started.

I've tested this locally:

  • Tested that the semaphore is created and posted to correctly:
    $ bazel build //tests/utils/test_helper:counting_process
    $ bazel-bin/tests/utils/test_helper/counting_process  -p /namedsem
    $ stat -c '%a %n' /dev/shm/sem.namedsem
    644 /dev/shm/sem.namedsem
    $ ./bin/python3 -c "import posix_ipc; sem = posix_ipc.Semaphore('/namedsem'); print('Value:', sem.value)"
    Value: 1
    $ bazel-bin/tests/utils/test_helper/counting_process  -p /namedsem
    Value: 2
    
  • Tested that report_running is called when configured.
    bazel-bin/tests/utils/test_helper/counting_process -r
    mw::log initialization error: Error No logging configuration files could be found. occurred with context information: Failed to load configuration files. Fallback to console logging.
    2026/09/03 11:38:32.1912871 130631703 000 ECU1 NONE LM log error verbose 3 [Lifecycle client] FD  111  is invalid for kRunning report
    
  • Tested that the help option works:
    $ bazel-bin/tests/utils/test_helper/counting_process --help
    Usage: ./counting_process [--help|-h] [--report-running|-r] [--post-to-semaphore|-p]
    $ bazel-bin/tests/utils/test_helper/counting_process -h
    Usage: ./counting_process [--help|-h] [--report-running|-r] [--post-to-semaphore|-p]
    
  • Tested that an error is printed if no arguments are passed.
    $ bazel-bin/tests/utils/test_helper/counting_process
    Invalid arguments! Must provide at least one option.
    
  • Tested that invalid or missing arguments are handled:
    $ bazel-bin/tests/utils/test_helper/counting_process -j
    bazel-bin/tests/utils/test_helper/counting_process: invalid option -- 'j'
    Invalid or missing argument.
    $ bazel-bin/tests/utils/test_helper/counting_process -p
    bazel-bin/tests/utils/test_helper/counting_process: option requires an argument -- 'p'
    Invalid or missing argument.
    
  • Test that invalid sem names are rejected
    $ bazel-bin/tests/utils/test_helper/counting_process -p sem
    Invalid semaphore name! POSIX named semaphores must start with '/'
    

@cameron-craig-etas
cameron-craig-etas marked this pull request as ready for review September 3, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant