[PATCH i-g-t v3 13/41] lib/vkms: Test encoder default files
Louis Chauvet
louis.chauvet at bootlin.com
Wed Jul 16 09:28:25 UTC 2025
Le 15/07/2025 à 12:24, José Expósito a écrit :
> Add a helper to create a encoder and a test checking that the default
> files and directories are created.
>
> Signed-off-by: José Expósito <jose.exposito89 at gmail.com>
Reviewed-by: Louis Chauvet <louis.chauvet at bootlin.com>
> ---
> lib/igt_vkms.c | 27 +++++++++++++++++++++++++++
> lib/igt_vkms.h | 4 ++++
> tests/vkms/vkms_configfs.c | 29 +++++++++++++++++++++++++++++
> 3 files changed, 60 insertions(+)
>
> diff --git a/lib/igt_vkms.c b/lib/igt_vkms.c
> index 0a14f9af7..ed28adf9b 100644
> --- a/lib/igt_vkms.c
> +++ b/lib/igt_vkms.c
> @@ -258,6 +258,21 @@ void igt_vkms_get_crtc_writeback_path(igt_vkms_t *dev, const char *name,
> VKMS_FILE_CRTC_WRITEBACK, path, len);
> }
>
> +/**
> + * igt_vkms_get_encoder_path:
> + * @dev: Device containing the encoder
> + * @name: Encoder name
> + * @path: Output path
> + * @len: Maximum @path length
> + *
> + * Returns the encoder path.
> + */
> +void igt_vkms_get_encoder_path(igt_vkms_t *dev, const char *name, char *path,
> + size_t len)
> +{
> + get_pipeline_item_path(dev, VKMS_PIPELINE_ITEM_ENCODER, name, path, len);
> +}
> +
> /**
> * igt_vkms_device_create:
> * @name: VKMS device name
> @@ -527,3 +542,15 @@ void igt_vkms_crtc_set_writeback_enabled(igt_vkms_t *dev, const char *name,
>
> write_bool(path, writeback);
> }
> +
> +/**
> + * igt_vkms_device_add_encoder:
> + * @dev: Device to add the encoder to
> + * @name: Encoder name
> + *
> + * Add a new encoder to the VKMS device.
> + */
> +void igt_vkms_device_add_encoder(igt_vkms_t *dev, const char *name)
> +{
> + add_pipeline_item(dev, VKMS_PIPELINE_ITEM_ENCODER, name);
> +}
> diff --git a/lib/igt_vkms.h b/lib/igt_vkms.h
> index 90cfde77a..aa6ff513d 100644
> --- a/lib/igt_vkms.h
> +++ b/lib/igt_vkms.h
> @@ -31,6 +31,8 @@ void igt_vkms_get_crtc_path(igt_vkms_t *dev, const char *name, char *path,
> size_t len);
> void igt_vkms_get_crtc_writeback_path(igt_vkms_t *dev, const char *name,
> char *path, size_t len);
> +void igt_vkms_get_encoder_path(igt_vkms_t *dev, const char *name, char *path,
> + size_t len);
>
> igt_vkms_t *igt_vkms_device_create(const char *name);
> void igt_vkms_device_destroy(igt_vkms_t *dev);
> @@ -48,4 +50,6 @@ bool igt_vkms_crtc_is_writeback_enabled(igt_vkms_t *dev, const char *name);
> void igt_vkms_crtc_set_writeback_enabled(igt_vkms_t *dev, const char *name,
> bool writeback);
>
> +void igt_vkms_device_add_encoder(igt_vkms_t *dev, const char *name);
> +
> #endif /* __IGT_VKMS_H__ */
> diff --git a/tests/vkms/vkms_configfs.c b/tests/vkms/vkms_configfs.c
> index 860a06f41..8939ef611 100644
> --- a/tests/vkms/vkms_configfs.c
> +++ b/tests/vkms/vkms_configfs.c
> @@ -406,6 +406,34 @@ static void test_crtc_valid_values(void)
> igt_vkms_device_destroy(dev);
> }
>
> +/**
> + * SUBTEST: encoder-default-files
> + * Description: Test that creating a encoder creates the default files and
> + * directories.
> + */
> +
> +static void test_encoder_default_files(void)
> +{
> + igt_vkms_t *dev;
> + char path[PATH_MAX];
> +
> + const char *dirs[] = {
> + "possible_crtcs",
> + };
> +
> + dev = igt_vkms_device_create(__func__);
> + igt_assert(dev);
> +
> + igt_vkms_device_add_encoder(dev, "encoder0");
> + igt_vkms_get_encoder_path(dev, "encoder0", path, sizeof(path));
> +
> + assert_default_files(path,
> + NULL, 0,
> + dirs, ARRAY_SIZE(dirs));
> +
> + igt_vkms_device_destroy(dev);
> +}
> +
> igt_main
> {
> struct {
> @@ -423,6 +451,7 @@ igt_main
> { "crtc-default-values", test_crtc_default_values },
> { "crtc-wrong-values", test_crtc_wrong_values },
> { "crtc-valid-values", test_crtc_valid_values },
> + { "encoder-default-files", test_encoder_default_files },
> };
>
> igt_fixture {
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
More information about the igt-dev
mailing list