tests.test_hear_keyboard_interrupt
Test module for verifying keyboard interrupt handling in multicast operations.
This module contains test suites that verify proper handling of SIGINT signals,
ensuring clean shutdown and resource cleanup during keyboard interrupts.
Module Contents
Classes
Test suite for verifying keyboard interrupt (SIGINT) handling. |
Data
API
- tests.test_hear_keyboard_interrupt.__module__[source]
‘tests’
- class tests.test_hear_keyboard_interrupt.TestHearKeyboardInterrupt(methodName='runTest')[source][source]
Bases:
context.BasicUsageTestSuiteTest suite for verifying keyboard interrupt (SIGINT) handling.
This suite ensures that the multicast service properly handles SIGINT signals by cleaning up resources and exiting gracefully with the expected status code (130).
Initialization
Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- __module__[source]
‘tests.test_hear_keyboard_interrupt’
- STARTUP_DELAY_SECONDS: int[source]
1
Time to wait for server initialization before sending
SIGINT.Must be > 0 to ensure server is ready.
- PROCESS_TIMEOUT_SECONDS: int[source]
5
Maximum time to wait for process completion after
SIGINT.Should be sufficient for cleanup but not too long.
- EXPECTED_SIGINT_EXIT_CODE: int[source]
130
Expected exit code when process receives SIGINT.
130=128+SIGINT(2)as per POSIX convention.
- _build_hear_command(port: int, group: str = '224.0.0.1') list[str][source][source]
Build the command for running the multicast HEAR service.
Args: port (int): The port number to use group (str, optional): The multicast group. Defaults to “224.0.0.1”
Returns: list: The command arguments list
- test_hear_keyboard_interrupt() None[source][source]
Test proper handling of keyboard interrupts (SIGINT).
This test: 1. Starts a multicast server (with coverage tracking) 2. Waits for server initialization 3. Sends a SIGINT signal to simulate Ctrl+C 4. Verifies that the server exits with the expected status code
Success criteria: - Server must exit with status code 130 (standard SIGINT exit code) - Server must not exit with status code 2 (invalid arguments)