Skip to content

Introduce a waiting process as a test utility - #589

Merged
MaciejKaszynski merged 3 commits into
eclipse-score:mainfrom
etas-contrib:feature/waiting-process
Sep 7, 2026
Merged

Introduce a waiting process as a test utility#589
MaciejKaszynski merged 3 commits into
eclipse-score:mainfrom
etas-contrib:feature/waiting-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 "waiting" process that goes hand-in-hand with the "counting" process being introduced in /pull/587. The process takes some required arguments to configure the semaphore name, and the expected count. Optionally, this process can be used to start from zero, which deletes the named semaphore before starting.

I've tested this locally:

  • Tested that the semaphore is created and posted to correctly
$ bazel build //tests/utils/test_helper:waiting_process
$ bazel-bin/tests/utils/test_helper/waiting_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 errors are reported when arguments are missing
    $ bazel-bin/tests/utils/test_helper/waiting_process
    Invalid arguments! Must provide at least one option.
    
    $ bazel-bin/tests/utils/test_helper/waiting_process -n /namedsem
    Invalid arguments! An expected count must be provided.
    
    $ bazel-bin/tests/utils/test_helper/waiting_process -c
    $ bazel-bin/tests/utils/test_helper/waiting_process: option requires an argument -- 'c'
    Invalid or missing argument.
    
    $ bazel-bin/tests/utils/test_helper/waiting_process -c 10
    Invalid arguments! Must provide at least one option.
    
    $ bazel-bin/tests/utils/test_helper/waiting_process -p
    $ bazel-bin/tests/utils/test_helper/waiting_process: invalid option -- 'p'
    Invalid or missing argument.
    
    $ bazel-bin/tests/utils/test_helper/waiting_process -z
    Invalid arguments! A semaphore name must be passed if starting from zero.
    
  • Tested that the process waits until the expected count is reached
    $ bazel-bin/tests/utils/test_helper/waiting_process -n /sem -c 10
    (post 10 times using counting_procees)...
    echo $?
    0
    
  • Tested that the semaphore is deleted if passing -z
    $ bazel-bin/tests/utils/test_helper/counting_process -p /sem # Create sem
    $ file /dev/shm/sem.sem # Check exists
    /dev/shm/sem.sem: data
    $ bazel-bin/tests/utils/test_helper/waiting_process -z -n /sem # Delete
    $ file /dev/shm/sem.sem # Check deleted
    /dev/shm/sem.sem: cannot open `/dev/shm/sem.sem' (No such file or directory)
    
  • Tested that the help option works
    $ bazel-bin/tests/utils/test_helper/waiting_process -h
    Usage: ./wait_for_semaphore --semaphore-name <semaphore_name> --expected-count <expected_count> [--timeout-seconds <timeout in seconds>] [--start-from-zero]
    $ bazel-bin/tests/utils/test_helper/waiting_process --help
    Usage: ./wait_for_semaphore --semaphore-name <semaphore_name> --expected-count <expected_count> [--timeout-seconds <timeout in seconds>] [--start-from-zero]
    
  • Test that interger parsing can fail
    $ bazel-bin/tests/utils/test_helper/waiting_process -c k
    Could not parse expected-count as integer: k
    

@cameron-craig-etas
cameron-craig-etas marked this pull request as ready for review September 3, 2026 13:43
Comment thread tests/utils/test_helper/waiting_process.cpp Outdated
Comment thread tests/utils/test_helper/waiting_process.cpp Outdated
Comment thread tests/utils/test_helper/waiting_process.cpp Outdated
Comment thread tests/utils/test_helper/waiting_process.cpp Outdated

@paulquiring paulquiring 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.

I left some suggestions how to improve the error handling parsing the options. The suggestions do not indicate hard bugs.

@MaciejKaszynski
MaciejKaszynski merged commit 4aff147 into eclipse-score:main Sep 7, 2026
16 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in LCM - Lifecycle & Health FT Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants