mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
tests/kms: Run tests with kernel/user thread too
This means each test is run 4 times: * with atomic mode setting using a kernel thread, * with atomic mode setting using a user thread, * with legacy mode setting using a kernel thread, and * with legacy mode setting using a user thread. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
This commit is contained in:
parent
f1356ce5d3
commit
ae48019cce
@ -23,6 +23,9 @@ $VM_ENV \
|
||||
if [ ! -v $MUTTER_DEBUG_FORCE_KMS_MODE ]; then
|
||||
VIRTME_ENV="$VIRTME_ENV MUTTER_DEBUG_FORCE_KMS_MODE=$MUTTER_DEBUG_FORCE_KMS_MODE"
|
||||
fi
|
||||
if [ ! -v $MUTTER_DEBUG_KMS_THREAD_TYPE ]; then
|
||||
VIRTME_ENV="$VIRTME_ENV MUTTER_DEBUG_KMS_THREAD_TYPE=$MUTTER_DEBUG_KMS_THREAD_TYPE"
|
||||
fi
|
||||
|
||||
if [[ "$(stat -c '%t:%T' -L /proc/$$/fd/0)" == "0:0" ]]; then
|
||||
mkfifo $XDG_RUNTIME_DIR/fake-stdin.$$
|
||||
|
@ -385,19 +385,34 @@ if have_native_tests
|
||||
|
||||
# KMS tests
|
||||
kms_test_variants = []
|
||||
kms_atomic_variables = {'MUTTER_DEBUG_FORCE_KMS_MODE': 'atomic'}
|
||||
kms_simple_variables = {'MUTTER_DEBUG_FORCE_KMS_MODE': 'simple'}
|
||||
kms_variants = [
|
||||
['atomic', kms_atomic_variables],
|
||||
['simple', kms_simple_variables],
|
||||
kms_mode_atomic_variables = {'MUTTER_DEBUG_FORCE_KMS_MODE': 'atomic'}
|
||||
kms_mode_simple_variables = {'MUTTER_DEBUG_FORCE_KMS_MODE': 'simple'}
|
||||
kms_thread_kernel_variables = {'MUTTER_DEBUG_KMS_THREAD_TYPE': 'kernel'}
|
||||
kms_thread_user_variables = {'MUTTER_DEBUG_KMS_THREAD_TYPE': 'user'}
|
||||
kms_mode_variants = [
|
||||
['atomic', kms_mode_atomic_variables],
|
||||
['simple', kms_mode_simple_variables],
|
||||
]
|
||||
kms_thread_variants = [
|
||||
['kernel-thread', kms_thread_kernel_variables],
|
||||
['user-thread', kms_thread_user_variables],
|
||||
]
|
||||
foreach variant: kms_variants
|
||||
name = variant[0]
|
||||
variables = variant[1]
|
||||
suffix = '-@0@'.format(name)
|
||||
|
||||
kms_test_env_variables = test_env_variables + variables
|
||||
kms_test_variants += [[suffix, kms_test_env_variables]]
|
||||
foreach kms_mode_variant: kms_mode_variants
|
||||
kms_mode_name = kms_mode_variant[0]
|
||||
kms_mode_variables = kms_mode_variant[1]
|
||||
|
||||
foreach kms_thread_variant: kms_thread_variants
|
||||
kms_thread_name = kms_thread_variant[0]
|
||||
kms_thread_variables = kms_thread_variant[1]
|
||||
suffix = '-@0@-@1@'.format(kms_thread_name, kms_mode_name)
|
||||
|
||||
kms_test_env_variables = \
|
||||
test_env_variables + \
|
||||
kms_mode_variables + \
|
||||
kms_thread_variables
|
||||
kms_test_variants += [[suffix, kms_test_env_variables]]
|
||||
endforeach
|
||||
endforeach
|
||||
|
||||
kms_test_cases = [
|
||||
@ -407,7 +422,7 @@ if have_native_tests
|
||||
'sources': [
|
||||
'native-kms-force-atomic-sanity.c',
|
||||
],
|
||||
'variants': [['', test_env_variables + kms_atomic_variables]],
|
||||
'variants': [['', test_env_variables + kms_mode_atomic_variables]],
|
||||
},
|
||||
{
|
||||
'name': 'kms-force-simple-sanity',
|
||||
@ -415,7 +430,23 @@ if have_native_tests
|
||||
'sources': [
|
||||
'native-kms-force-simple-sanity.c',
|
||||
],
|
||||
'variants': [['', test_env_variables + kms_simple_variables]],
|
||||
'variants': [['', test_env_variables + kms_mode_simple_variables]],
|
||||
},
|
||||
{
|
||||
'name': 'kms-force-kernel-thread-sanity',
|
||||
'suite': 'backends/native/kms',
|
||||
'sources': [
|
||||
'native-kms-force-kernel-thread-sanity.c',
|
||||
],
|
||||
'variants': [['', test_env_variables + kms_thread_kernel_variables]],
|
||||
},
|
||||
{
|
||||
'name': 'kms-force-user-thread-sanity',
|
||||
'suite': 'backends/native/kms',
|
||||
'sources': [
|
||||
'native-kms-force-user-thread-sanity.c',
|
||||
],
|
||||
'variants': [['', test_env_variables + kms_thread_user_variables]],
|
||||
},
|
||||
{
|
||||
'name': 'kms-render',
|
||||
|
78
src/tests/native-kms-force-kernel-thread-sanity.c
Normal file
78
src/tests/native-kms-force-kernel-thread-sanity.c
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.h"
|
||||
#include "backends/native/meta-thread-private.h"
|
||||
#include "meta-test/meta-context-test.h"
|
||||
|
||||
static MetaContext *test_context;
|
||||
|
||||
static gpointer
|
||||
assert_thread_equal (MetaThreadImpl *thread_impl,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
GThread *thread = user_data;
|
||||
|
||||
g_assert_true (thread != g_thread_self ());
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_test_kms_force_kernel_thread_sanity (void)
|
||||
{
|
||||
MetaBackend *backend = meta_context_get_backend (test_context);
|
||||
MetaKms *kms = meta_backend_native_get_kms (META_BACKEND_NATIVE (backend));
|
||||
|
||||
g_assert_cmpint (meta_thread_get_thread_type (META_THREAD (kms)), ==,
|
||||
META_THREAD_TYPE_KERNEL);
|
||||
meta_thread_run_impl_task_sync (META_THREAD (kms),
|
||||
assert_thread_equal, g_thread_self (),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
init_tests (void)
|
||||
{
|
||||
g_test_add_func ("/backends/native/kms/force-kernel-thread-sanity",
|
||||
meta_test_kms_force_kernel_thread_sanity);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (MetaContext) context = NULL;
|
||||
g_autoptr (GError) error = NULL;
|
||||
|
||||
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));
|
||||
|
||||
test_context = context;
|
||||
|
||||
init_tests ();
|
||||
|
||||
return meta_context_test_run_tests (META_CONTEXT_TEST (context),
|
||||
META_TEST_RUN_FLAG_CAN_SKIP);
|
||||
}
|
78
src/tests/native-kms-force-user-thread-sanity.c
Normal file
78
src/tests/native-kms-force-user-thread-sanity.c
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.h"
|
||||
#include "backends/native/meta-thread-private.h"
|
||||
#include "meta-test/meta-context-test.h"
|
||||
|
||||
static MetaContext *test_context;
|
||||
|
||||
static gpointer
|
||||
assert_thread_equal (MetaThreadImpl *thread_impl,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
GThread *thread = user_data;
|
||||
|
||||
g_assert_true (thread == g_thread_self ());
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_test_kms_force_user_thread_sanity (void)
|
||||
{
|
||||
MetaBackend *backend = meta_context_get_backend (test_context);
|
||||
MetaKms *kms = meta_backend_native_get_kms (META_BACKEND_NATIVE (backend));
|
||||
|
||||
g_assert_cmpint (meta_thread_get_thread_type (META_THREAD (kms)), ==,
|
||||
META_THREAD_TYPE_USER);
|
||||
meta_thread_run_impl_task_sync (META_THREAD (kms),
|
||||
assert_thread_equal, g_thread_self (),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
init_tests (void)
|
||||
{
|
||||
g_test_add_func ("/backends/native/kms/force-user-thread-sanity",
|
||||
meta_test_kms_force_user_thread_sanity);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (MetaContext) context = NULL;
|
||||
g_autoptr (GError) error = NULL;
|
||||
|
||||
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));
|
||||
|
||||
test_context = context;
|
||||
|
||||
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