tests/unit/test-char: add unit tests for hub chardev backend
commitc9c05ed525d368c0771ccf1195613bdf49d1bd21
authorRoman Penyaev <r.peniaev@gmail.com>
Thu, 23 Jan 2025 08:53:23 +0000 (23 09:53 +0100)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 3 Feb 2025 09:57:08 +0000 (3 13:57 +0400)
tree78816d77ecec33721c622a613669af25b40e1fce
parentb66ed232383162dc52d6a1c996599541860d1f1a
tests/unit/test-char: add unit tests for hub chardev backend

This commit introduces a new test function `char_hub_test` to validate
the functionality and constraints of the "hub" chardev backend in QEMU.
The test includes multiple scenarios:

1. Invalid hub creation:
   - Creating a hub without defining `chardevs.N` (expects an error).
   - Creating a hub with an embedded multiplexer (`mux=on`) or a chardev
     already in use (expects errors).

2. Max backend limit:
   - Ensures the hub does not accept more backends than the maximum
     allowed, with appropriate error handling.

3. Valid hub creation and data aggregation:
   - Successfully creating a hub with two ring buffer backends.
   - Verifying data aggregation from backends to a frontend and vice versa.
   - Ensuring correct error handling for attempts to attach a hub multiple
     times or remove busy chardevs.

4. Extended EAGAIN simulation (non-Windows only):
   - Simulates a setup with three backends, including a pipe, to test
     EAGAIN handling and watcher behavior.
   - Verifies data flow and recovery in scenarios involving buffer
     overflows and drained pipes.

The test also ensures correct cleanup of chardevs in all cases, covering
both valid and invalid configurations.

Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
Reviewed-by: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org
Message-ID: <20250123085327.965501-4-r.peniaev@gmail.com>
tests/unit/test-char.c