mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
tests: Add some basic MetaKmsUpdate unit tests
Mostly rudimentary sanity testing. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
This commit is contained in:
parent
bf398a5f84
commit
acd51a7e69
@ -30,6 +30,7 @@
|
||||
|
||||
MetaBarrierManagerNative *meta_backend_native_get_barrier_manager (MetaBackendNative *native);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaDevicePool * meta_backend_native_get_device_pool (MetaBackendNative *native);
|
||||
|
||||
#endif /* META_BACKEND_NATIVE_PRIVATE_H */
|
||||
|
@ -48,6 +48,7 @@ MetaLauncher * meta_backend_native_get_launcher (MetaBackendNative *native);
|
||||
|
||||
MetaUdev * meta_backend_native_get_udev (MetaBackendNative *native);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaKms * meta_backend_native_get_kms (MetaBackendNative *native);
|
||||
|
||||
const char * meta_backend_native_get_seat_id (MetaBackendNative *backend_native);
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include <glib-object.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "core/util-private.h"
|
||||
|
||||
typedef enum _MetaDeviceFileFlags
|
||||
{
|
||||
META_DEVICE_FILE_FLAG_NONE = 0,
|
||||
@ -54,10 +56,12 @@ uint32_t meta_device_file_has_tag (MetaDeviceFile *device_file,
|
||||
|
||||
MetaDeviceFile * meta_device_file_acquire (MetaDeviceFile *file);
|
||||
|
||||
META_EXPORT_TEST
|
||||
void meta_device_file_release (MetaDeviceFile *device_file);
|
||||
|
||||
MetaDevicePool * meta_device_file_get_pool (MetaDeviceFile *device_file);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaDeviceFile * meta_device_pool_open (MetaDevicePool *pool,
|
||||
const char *path,
|
||||
MetaDeviceFileFlags flags,
|
||||
|
@ -31,6 +31,7 @@ G_DECLARE_FINAL_TYPE (MetaDrmBufferDumb,
|
||||
META, DRM_BUFFER_DUMB,
|
||||
MetaDrmBuffer)
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaDrmBufferDumb * meta_drm_buffer_dumb_new (MetaDeviceFile *device,
|
||||
int width,
|
||||
int height,
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cogl/cogl.h"
|
||||
#include "core/util-private.h"
|
||||
|
||||
typedef enum _MetaDrmBufferFlags
|
||||
{
|
||||
@ -35,6 +36,7 @@ typedef enum _MetaDrmBufferFlags
|
||||
} MetaDrmBufferFlags;
|
||||
|
||||
#define META_TYPE_DRM_BUFFER (meta_drm_buffer_get_type ())
|
||||
META_EXPORT_TEST
|
||||
G_DECLARE_DERIVABLE_TYPE (MetaDrmBuffer,
|
||||
meta_drm_buffer,
|
||||
META, DRM_BUFFER,
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "backends/native/meta-kms-types.h"
|
||||
|
||||
#define META_TYPE_KMS_CONNECTOR (meta_kms_connector_get_type ())
|
||||
META_EXPORT_TEST
|
||||
G_DECLARE_FINAL_TYPE (MetaKmsConnector, meta_kms_connector,
|
||||
META, KMS_CONNECTOR, GObject)
|
||||
|
||||
@ -71,6 +72,7 @@ const char * meta_kms_connector_get_name (MetaKmsConnector *connector);
|
||||
gboolean meta_kms_connector_can_clone (MetaKmsConnector *connector,
|
||||
MetaKmsConnector *other_connector);
|
||||
|
||||
META_EXPORT_TEST
|
||||
const MetaKmsConnectorState * meta_kms_connector_get_current_state (MetaKmsConnector *connector);
|
||||
|
||||
gboolean meta_kms_connector_is_underscanning_supported (MetaKmsConnector *connector);
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <xf86drmMode.h>
|
||||
|
||||
#include "backends/native/meta-kms-types.h"
|
||||
#include "core/util-private.h"
|
||||
#include "meta/boxes.h"
|
||||
|
||||
typedef struct _MetaKmsCrtcState
|
||||
@ -54,6 +55,7 @@ typedef struct _MetaKmsCrtcGamma
|
||||
} MetaKmsCrtcGamma;
|
||||
|
||||
#define META_TYPE_KMS_CRTC (meta_kms_crtc_get_type ())
|
||||
META_EXPORT_TEST
|
||||
G_DECLARE_FINAL_TYPE (MetaKmsCrtc, meta_kms_crtc,
|
||||
META, KMS_CRTC,
|
||||
GObject)
|
||||
|
@ -23,14 +23,18 @@
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "backends/native/meta-kms-types.h"
|
||||
#include "core/util-private.h"
|
||||
|
||||
#define META_TYPE_KMS_DEVICE (meta_kms_device_get_type ())
|
||||
META_EXPORT_TEST
|
||||
G_DECLARE_FINAL_TYPE (MetaKmsDevice, meta_kms_device,
|
||||
META, KMS_DEVICE,
|
||||
GObject)
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaKms * meta_kms_device_get_kms (MetaKmsDevice *device);
|
||||
|
||||
META_EXPORT_TEST
|
||||
const char * meta_kms_device_get_path (MetaKmsDevice *device);
|
||||
|
||||
const char * meta_kms_device_get_driver_name (MetaKmsDevice *device);
|
||||
@ -47,15 +51,19 @@ gboolean meta_kms_device_prefers_shadow_buffer (MetaKmsDevice *device);
|
||||
|
||||
gboolean meta_kms_device_uses_monotonic_clock (MetaKmsDevice *device);
|
||||
|
||||
META_EXPORT_TEST
|
||||
GList * meta_kms_device_get_connectors (MetaKmsDevice *device);
|
||||
|
||||
META_EXPORT_TEST
|
||||
GList * meta_kms_device_get_crtcs (MetaKmsDevice *device);
|
||||
|
||||
GList * meta_kms_device_get_planes (MetaKmsDevice *device);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaKmsPlane * meta_kms_device_get_primary_plane_for (MetaKmsDevice *device,
|
||||
MetaKmsCrtc *crtc);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaKmsPlane * meta_kms_device_get_cursor_plane_for (MetaKmsDevice *device,
|
||||
MetaKmsCrtc *crtc);
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <xf86drmMode.h>
|
||||
|
||||
#include "backends/native/meta-kms-types.h"
|
||||
#include "core/util-private.h"
|
||||
|
||||
typedef enum _MetaKmsModeFlag
|
||||
{
|
||||
@ -37,6 +38,7 @@ const char * meta_kms_mode_get_name (MetaKmsMode *mode);
|
||||
|
||||
MetaKmsModeFlag meta_kms_mode_get_flags (MetaKmsMode *mode);
|
||||
|
||||
META_EXPORT_TEST
|
||||
const drmModeModeInfo * meta_kms_mode_get_drm_mode (MetaKmsMode *mode);
|
||||
|
||||
gboolean meta_kms_mode_equal (MetaKmsMode *mode,
|
||||
|
@ -124,33 +124,43 @@ void meta_kms_update_lock (MetaKmsUpdate *update);
|
||||
|
||||
void meta_kms_update_unlock (MetaKmsUpdate *update);
|
||||
|
||||
META_EXPORT_TEST
|
||||
gboolean meta_kms_update_is_locked (MetaKmsUpdate *update);
|
||||
|
||||
uint64_t meta_kms_update_get_sequence_number (MetaKmsUpdate *update);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaKmsDevice * meta_kms_update_get_device (MetaKmsUpdate *update);
|
||||
|
||||
void meta_kms_plane_assignment_set_rotation (MetaKmsPlaneAssignment *plane_assignment,
|
||||
uint64_t rotation);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaKmsPlaneAssignment * meta_kms_update_get_primary_plane_assignment (MetaKmsUpdate *update,
|
||||
MetaKmsCrtc *crtc);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaKmsPlaneAssignment * meta_kms_update_get_cursor_plane_assignment (MetaKmsUpdate *update,
|
||||
MetaKmsCrtc *crtc);
|
||||
|
||||
META_EXPORT_TEST
|
||||
GList * meta_kms_update_get_plane_assignments (MetaKmsUpdate *update);
|
||||
|
||||
META_EXPORT_TEST
|
||||
GList * meta_kms_update_get_mode_sets (MetaKmsUpdate *update);
|
||||
|
||||
META_EXPORT_TEST
|
||||
GList * meta_kms_update_get_page_flip_listeners (MetaKmsUpdate *update);
|
||||
|
||||
void meta_kms_update_drop_defunct_page_flip_listeners (MetaKmsUpdate *update);
|
||||
|
||||
META_EXPORT_TEST
|
||||
GList * meta_kms_update_get_connector_updates (MetaKmsUpdate *update);
|
||||
|
||||
META_EXPORT_TEST
|
||||
GList * meta_kms_update_get_crtc_gammas (MetaKmsUpdate *update);
|
||||
|
||||
META_EXPORT_TEST
|
||||
gboolean meta_kms_update_is_power_save (MetaKmsUpdate *update);
|
||||
|
||||
MetaKmsCustomPageFlip * meta_kms_update_take_custom_page_flip_func (MetaKmsUpdate *update);
|
||||
|
@ -89,8 +89,10 @@ GList * meta_kms_feedback_get_failed_planes (const MetaKmsFeedback *feedback);
|
||||
|
||||
const GError * meta_kms_feedback_get_error (const MetaKmsFeedback *feedback);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaKmsUpdate * meta_kms_update_new (MetaKmsDevice *device);
|
||||
|
||||
META_EXPORT_TEST
|
||||
void meta_kms_update_free (MetaKmsUpdate *update);
|
||||
|
||||
void meta_kms_update_set_underscanning (MetaKmsUpdate *update,
|
||||
@ -123,6 +125,7 @@ void meta_kms_plane_assignment_set_fb_damage (MetaKmsPlaneAssignment *plane_assi
|
||||
const int *rectangles,
|
||||
int n_rectangles);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaKmsPlaneAssignment * meta_kms_update_assign_plane (MetaKmsUpdate *update,
|
||||
MetaKmsCrtc *crtc,
|
||||
MetaKmsPlane *plane,
|
||||
@ -146,6 +149,7 @@ void meta_kms_update_set_custom_page_flip (MetaKmsUpdate *update,
|
||||
MetaKmsCustomPageFlipFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
META_EXPORT_TEST
|
||||
void meta_kms_plane_assignment_set_cursor_hotspot (MetaKmsPlaneAssignment *plane_assignment,
|
||||
int x,
|
||||
int y);
|
||||
|
@ -60,8 +60,10 @@ void meta_kms_discard_pending_page_flips (MetaKms *kms);
|
||||
|
||||
void meta_kms_notify_modes_set (MetaKms *kms);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaBackend * meta_kms_get_backend (MetaKms *kms);
|
||||
|
||||
META_EXPORT_TEST
|
||||
GList * meta_kms_get_devices (MetaKms *kms);
|
||||
|
||||
void meta_kms_resume (MetaKms *kms);
|
||||
|
@ -297,6 +297,17 @@ if have_native_tests
|
||||
install: have_installed_tests,
|
||||
install_dir: mutter_installed_tests_libexecdir,
|
||||
)
|
||||
|
||||
native_kms_update_tests = executable('mutter-native-kms-update-tests',
|
||||
sources: [
|
||||
'native-kms-updates.c',
|
||||
],
|
||||
include_directories: tests_includes,
|
||||
c_args: tests_c_args,
|
||||
dependencies: libmutter_test_dep,
|
||||
install: have_installed_tests,
|
||||
install_dir: mutter_installed_tests_libexecdir,
|
||||
)
|
||||
endif
|
||||
|
||||
stacking_tests = [
|
||||
@ -416,6 +427,7 @@ endif
|
||||
if have_kvm_tests or have_tty_tests
|
||||
privileged_tests = [
|
||||
[ 'kms-render', native_kms_render_tests ],
|
||||
[ 'kms-update', native_kms_update_tests ],
|
||||
]
|
||||
|
||||
if have_kvm_tests
|
||||
|
109
src/tests/native-kms-updates.c
Normal file
109
src/tests/native-kms-updates.c
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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 <gbm.h>
|
||||
|
||||
#include "backends/native/meta-backend-native-private.h"
|
||||
#include "backends/native/meta-device-pool.h"
|
||||
#include "backends/native/meta-drm-buffer-dumb.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-mode.h"
|
||||
#include "backends/native/meta-kms-update-private.h"
|
||||
#include "backends/native/meta-kms.h"
|
||||
#include "meta-test/meta-context-test.h"
|
||||
#include "meta/meta-backend.h"
|
||||
|
||||
static MetaContext *test_context;
|
||||
|
||||
static MetaKmsDevice *
|
||||
get_test_kms_device (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;
|
||||
|
||||
devices = meta_kms_get_devices (kms);
|
||||
g_assert_cmpuint (g_list_length (devices), ==, 1);
|
||||
return META_KMS_DEVICE (devices->data);
|
||||
}
|
||||
|
||||
static MetaKmsCrtc *
|
||||
get_test_crtc (MetaKmsDevice *device)
|
||||
{
|
||||
GList *crtcs;
|
||||
|
||||
crtcs = meta_kms_device_get_crtcs (device);
|
||||
g_assert_cmpuint (g_list_length (crtcs), ==, 1);
|
||||
|
||||
return META_KMS_CRTC (crtcs->data);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_test_kms_update_sanity (void)
|
||||
{
|
||||
MetaKmsDevice *device;
|
||||
MetaKmsCrtc *crtc;
|
||||
MetaKmsUpdate *update;
|
||||
|
||||
device = get_test_kms_device ();
|
||||
crtc = get_test_crtc (device);
|
||||
|
||||
update = meta_kms_update_new (device);
|
||||
g_assert (meta_kms_update_get_device (update) == device);
|
||||
g_assert_false (meta_kms_update_is_locked (update));
|
||||
g_assert_false (meta_kms_update_is_power_save (update));
|
||||
g_assert_null (meta_kms_update_get_primary_plane_assignment (update, crtc));
|
||||
g_assert_null (meta_kms_update_get_plane_assignments (update));
|
||||
g_assert_null (meta_kms_update_get_mode_sets (update));
|
||||
g_assert_null (meta_kms_update_get_page_flip_listeners (update));
|
||||
g_assert_null (meta_kms_update_get_connector_updates (update));
|
||||
g_assert_null (meta_kms_update_get_crtc_gammas (update));
|
||||
meta_kms_update_free (update);
|
||||
}
|
||||
|
||||
static void
|
||||
init_tests (void)
|
||||
{
|
||||
g_test_add_func ("/backends/native/kms/update/sanity",
|
||||
meta_test_kms_update_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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user