1
0
Fork 0

tests: Add KMS device tests

As other KMS tests, depends on being DRM master and vkms being loaded.

Currently consists of a sanity check that checks for the expected set of
connectors, CRTCs, planes, etc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
This commit is contained in:
Jonas Ådahl 2021-06-23 10:10:35 +02:00 committed by Marge Bot
parent 23a530cb09
commit 43a1ba3432
6 changed files with 131 additions and 0 deletions

View file

@ -61,6 +61,7 @@ typedef struct _MetaKmsConnectorState
MetaMonitorTransform panel_orientation_transform;
} MetaKmsConnectorState;
META_EXPORT_TEST
MetaKmsDevice * meta_kms_connector_get_device (MetaKmsConnector *connector);
uint32_t meta_kms_connector_get_connector_type (MetaKmsConnector *connector);

View file

@ -60,6 +60,7 @@ G_DECLARE_FINAL_TYPE (MetaKmsCrtc, meta_kms_crtc,
META, KMS_CRTC,
GObject)
META_EXPORT_TEST
MetaKmsDevice * meta_kms_crtc_get_device (MetaKmsCrtc *crtc);
const MetaKmsCrtcState * meta_kms_crtc_get_current_state (MetaKmsCrtc *crtc);

View file

@ -37,6 +37,7 @@ MetaKms * meta_kms_device_get_kms (MetaKmsDevice *device);
META_EXPORT_TEST
const char * meta_kms_device_get_path (MetaKmsDevice *device);
META_EXPORT_TEST
const char * meta_kms_device_get_driver_name (MetaKmsDevice *device);
const char * meta_kms_device_get_driver_description (MetaKmsDevice *device);
@ -49,6 +50,7 @@ gboolean meta_kms_device_get_cursor_size (MetaKmsDevice *device,
gboolean meta_kms_device_prefers_shadow_buffer (MetaKmsDevice *device);
META_EXPORT_TEST
gboolean meta_kms_device_uses_monotonic_clock (MetaKmsDevice *device);
META_EXPORT_TEST
@ -57,6 +59,7 @@ GList * meta_kms_device_get_connectors (MetaKmsDevice *device);
META_EXPORT_TEST
GList * meta_kms_device_get_crtcs (MetaKmsDevice *device);
META_EXPORT_TEST
GList * meta_kms_device_get_planes (MetaKmsDevice *device);
META_EXPORT_TEST

View file

@ -38,10 +38,12 @@ enum _MetaKmsPlaneType
G_DECLARE_FINAL_TYPE (MetaKmsPlane, meta_kms_plane,
META, KMS_PLANE, GObject)
META_EXPORT_TEST
MetaKmsDevice * meta_kms_plane_get_device (MetaKmsPlane *plane);
uint32_t meta_kms_plane_get_id (MetaKmsPlane *plane);
META_EXPORT_TEST
MetaKmsPlaneType meta_kms_plane_get_plane_type (MetaKmsPlane *plane);
gboolean meta_kms_plane_is_transform_handled (MetaKmsPlane *plane,
@ -55,6 +57,7 @@ GArray * meta_kms_plane_copy_drm_format_list (MetaKmsPlane *plane);
gboolean meta_kms_plane_is_format_supported (MetaKmsPlane *plane,
uint32_t format);
META_EXPORT_TEST
gboolean meta_kms_plane_is_usable_with (MetaKmsPlane *plane,
MetaKmsCrtc *crtc);

View file

@ -298,6 +298,17 @@ if have_native_tests
install_dir: mutter_installed_tests_libexecdir,
)
native_kms_device_tests = executable('mutter-native-kms-device',
sources: [
'native-kms-device.c',
],
include_directories: tests_includes,
c_args: tests_c_args,
dependencies: libmutter_test_dep,
install: have_installed_tests,
install_dir: mutter_installed_tests_libexecdir,
)
native_kms_update_tests = executable('mutter-native-kms-update-tests',
sources: [
'meta-kms-test-utils.c',
@ -429,6 +440,7 @@ endif
if have_kvm_tests or have_tty_tests
privileged_tests = [
[ 'kms-render', native_kms_render_tests ],
[ 'kms-device', native_kms_device_tests ],
[ 'kms-update', native_kms_update_tests ],
]

View file

@ -0,0 +1,111 @@
/*
* Copyright (C) 2021 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*/
#include "config.h"
#include "backends/native/meta-backend-native-private.h"
#include "backends/native/meta-kms-connector.h"
#include "backends/native/meta-kms-crtc.h"
#include "backends/native/meta-kms-device.h"
#include "backends/native/meta-kms-plane.h"
#include "backends/native/meta-kms.h"
#include "meta-test/meta-context-test.h"
static MetaContext *test_context;
static void
meta_test_kms_device_sanity (void)
{
MetaBackend *backend = meta_context_get_backend (test_context);
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
MetaKms *kms = meta_backend_native_get_kms (backend_native);
GList *devices;
MetaKmsDevice *device;
GList *connectors;
MetaKmsConnector *connector;
GList *crtcs;
MetaKmsCrtc *crtc;
GList *planes;
MetaKmsPlane *primary_plane;
MetaKmsPlane *cursor_plane;
devices = meta_kms_get_devices (kms);
g_assert_cmpuint (g_list_length (devices), ==, 1);
device = META_KMS_DEVICE (devices->data);
g_assert (meta_kms_device_get_kms (device) == kms);
g_assert_cmpstr (meta_kms_device_get_driver_name (device), ==, "vkms");
g_assert_true (meta_kms_device_uses_monotonic_clock (device));
connectors = meta_kms_device_get_connectors (device);
g_assert_cmpuint (g_list_length (connectors), ==, 1);
connector = META_KMS_CONNECTOR (connectors->data);
g_assert (meta_kms_connector_get_device (connector) == device);
crtcs = meta_kms_device_get_crtcs (device);
g_assert_cmpuint (g_list_length (crtcs), ==, 1);
crtc = META_KMS_CRTC (crtcs->data);
g_assert (meta_kms_crtc_get_device (crtc) == device);
planes = meta_kms_device_get_planes (device);
g_assert_cmpuint (g_list_length (planes), ==, 2);
primary_plane = meta_kms_device_get_primary_plane_for (device, crtc);
g_assert_nonnull (primary_plane);
cursor_plane = meta_kms_device_get_cursor_plane_for (device, crtc);
g_assert_nonnull (cursor_plane);
g_assert (cursor_plane != primary_plane);
g_assert_nonnull (g_list_find (planes, primary_plane));
g_assert_nonnull (g_list_find (planes, cursor_plane));
g_assert (meta_kms_plane_get_device (primary_plane) == device);
g_assert (meta_kms_plane_get_device (cursor_plane) == device);
g_assert_true (meta_kms_plane_is_usable_with (primary_plane, crtc));
g_assert_true (meta_kms_plane_is_usable_with (cursor_plane, crtc));
g_assert_cmpint (meta_kms_plane_get_plane_type (primary_plane),
==,
META_KMS_PLANE_TYPE_PRIMARY);
g_assert_cmpint (meta_kms_plane_get_plane_type (cursor_plane),
==,
META_KMS_PLANE_TYPE_CURSOR);
}
static void
init_tests (void)
{
g_test_add_func ("/backends/native/kms/device/sanity",
meta_test_kms_device_sanity);
}
int
main (int argc,
char **argv)
{
g_autoptr (MetaContext) context = NULL;
g_autoptr (GError) error = NULL;
context = test_context =
meta_create_test_context (META_CONTEXT_TEST_TYPE_VKMS,
META_CONTEXT_TEST_FLAG_NO_X11);
g_assert (meta_context_configure (context, &argc, &argv, NULL));
init_tests ();
return meta_context_test_run_tests (META_CONTEXT_TEST (context),
META_TEST_RUN_FLAG_CAN_SKIP);
}