diff options
author | Simon McVittie <smcv@collabora.com> | 2022-09-05 10:54:25 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2022-09-05 10:54:25 +0100 |
commit | ab33ebefc5ca34486509e3a87591ad2e883b9549 (patch) | |
tree | 96284201c8cf83ef8d50243cb753b24d8da6717d /subprojects/dbus-gmain/tests | |
parent | f83a62c27203553c04c375ff663d9d99273670c9 (diff) | |
parent | 93e8fced640e29bd6fbcc066a6c854a8dd74f8ab (diff) | |
download | dbus-python-ab33ebefc5ca34486509e3a87591ad2e883b9549.tar.gz |
Merge dbus-gmain commit '93e8fced640e29bd6fbcc066a6c854a8dd74f8ab'
Diffstat (limited to 'subprojects/dbus-gmain/tests')
9 files changed, 169 insertions, 6 deletions
diff --git a/subprojects/dbus-gmain/tests/30574.c b/subprojects/dbus-gmain/tests/30574.c index bcc1276..6fe2b90 100644 --- a/subprojects/dbus-gmain/tests/30574.c +++ b/subprojects/dbus-gmain/tests/30574.c @@ -54,12 +54,14 @@ set_reply (DBusPendingCall * pending, void *user_data) } static DBusMessage * -send_and_allow_reentry (DBusConnection * bus, DBusMessage * message, +send_and_allow_reentry (DBusConnection *conn, DBusMessage *message, dbus_bool_t switch_after_send) { DBusPendingCall *pending; SpiReentrantCallClosure closure; + g_assert (conn == bus); + closure.loop = g_main_loop_new (main_context, FALSE); DBUS_GMAIN_FUNCTION_NAME (set_up_connection) (bus, (switch_after_send ? NULL : @@ -114,7 +116,7 @@ send_test_message (dbus_bool_t switch_after_send) } int -main(int argc, const char *argv[]) +main (G_GNUC_UNUSED int argc, G_GNUC_UNUSED const char *argv[]) { DBusError error; diff --git a/subprojects/dbus-gmain/tests/meson.build b/subprojects/dbus-gmain/tests/meson.build new file mode 100644 index 0000000..8344ee2 --- /dev/null +++ b/subprojects/dbus-gmain/tests/meson.build @@ -0,0 +1,66 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: MIT + +testlib = static_library( + 'testutils', + 'util.c', + dependencies: [ + dbus_dep, + glib_dep, + ], +) + +test_thread_server = executable( + 'test-thread-server', + 'test-thread-server.c', + dependencies: [ + dbus_gmain_dep, + dbus_dep, + glib_dep, + gthread_dep, + ], + link_with: testlib, +) + +test_thread_client = executable( + 'test-thread-client', + 'test-thread-client.c', + dependencies: [ + dbus_gmain_dep, + dbus_dep, + glib_dep, + gthread_dep, + ], + link_with: testlib, +) + +test_cases = ['30574'] + +foreach test_case : test_cases + exe = executable( + 'test-' + test_case, + test_case + '.c', + dependencies: [ + dbus_gmain_dep, + dbus_dep, + glib_dep, + ], + link_with: testlib, + ) + test( + test_case, + dbus_run_session, + args: [ + '--', + exe, + ], + ) +endforeach + +test( + 'use-as-subproject', + find_program('python3'), + args: [ + files('use-as-subproject.py'), + ], +) diff --git a/subprojects/dbus-gmain/tests/test-thread-server.c b/subprojects/dbus-gmain/tests/test-thread-server.c index 54f43b6..df821fb 100644 --- a/subprojects/dbus-gmain/tests/test-thread-server.c +++ b/subprojects/dbus-gmain/tests/test-thread-server.c @@ -158,7 +158,7 @@ filter_test_message (DBusConnection *connection, static DBusHandlerResult filter_disconnect (DBusConnection *connection, DBusMessage *message, - void *user_data) + G_GNUC_UNUSED void *user_data) { if (!dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")) @@ -171,9 +171,9 @@ filter_disconnect (DBusConnection *connection, } static void -new_connection_callback (DBusServer *server, - DBusConnection *new_connection, - void *user_data) +new_connection_callback (G_GNUC_UNUSED DBusServer *server, + DBusConnection *new_connection, + G_GNUC_UNUSED void *user_data) { ThreadTestData * data; diff --git a/subprojects/dbus-gmain/tests/test-thread.h b/subprojects/dbus-gmain/tests/test-thread.h index 8c78fba..74371f4 100644 --- a/subprojects/dbus-gmain/tests/test-thread.h +++ b/subprojects/dbus-gmain/tests/test-thread.h @@ -1 +1,5 @@ +/* + * Copyright 2006 Red Hat, Inc. + * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later + */ #define N_TEST_THREADS 5 diff --git a/subprojects/dbus-gmain/tests/use-as-subproject.py b/subprojects/dbus-gmain/tests/use-as-subproject.py new file mode 100644 index 0000000..3f45c5b --- /dev/null +++ b/subprojects/dbus-gmain/tests/use-as-subproject.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: MIT + +import os +import shutil +import subprocess +import tempfile + +HERE = os.path.dirname(os.path.abspath(__file__)) + +if __name__ == '__main__': + if shutil.which('meson') is None: + print('SKIP: meson not found in PATH') + raise SystemExit(0) + + with tempfile.TemporaryDirectory() as temp: + shutil.copytree( + os.path.join(HERE, 'use-as-subproject'), + os.path.join(temp, 'src'), + ) + os.makedirs(os.path.join(temp, 'src', 'subprojects'), exist_ok=True) + os.symlink( + os.path.dirname(HERE), + os.path.join(temp, 'src', 'subprojects', 'dbus-gmain'), + ) + subprocess.run( + ['meson', os.path.join(temp, 'src'), os.path.join(temp, 'build')], + check=True, + ) + subprocess.run( + ['meson', 'compile', '-C', os.path.join(temp, 'build')], + check=True, + ) diff --git a/subprojects/dbus-gmain/tests/use-as-subproject/.gitignore b/subprojects/dbus-gmain/tests/use-as-subproject/.gitignore new file mode 100644 index 0000000..348f6b5 --- /dev/null +++ b/subprojects/dbus-gmain/tests/use-as-subproject/.gitignore @@ -0,0 +1,5 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: MIT + +/_build/ +/subprojects/ diff --git a/subprojects/dbus-gmain/tests/use-as-subproject/README b/subprojects/dbus-gmain/tests/use-as-subproject/README new file mode 100644 index 0000000..d0f10fd --- /dev/null +++ b/subprojects/dbus-gmain/tests/use-as-subproject/README @@ -0,0 +1,8 @@ +This is a simple example of a project that uses dbus-gmain as a subproject. +The intention is that if this project can successfully build and use it +as a subproject, then so could dbus-glib and dbus-python. + +<!-- +Copyright 2022 Collabora Ltd. +SPDX-License-Identifier: MIT +--> diff --git a/subprojects/dbus-gmain/tests/use-as-subproject/meson.build b/subprojects/dbus-gmain/tests/use-as-subproject/meson.build new file mode 100644 index 0000000..65f651a --- /dev/null +++ b/subprojects/dbus-gmain/tests/use-as-subproject/meson.build @@ -0,0 +1,30 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: MIT + +project( + 'use-dbus-gmain-as-subproject', + 'c', + version : '0', + meson_version : '>=0.49.0', +) + +redefine_function_declaration = 'ret DBUS_GMAIN_FUNCTION_NAME (name) (__VA_ARGS__)' +redefine_function_name = '_my_ ## name' + +add_project_arguments( + '-DDBUS_GMAIN_FUNCTION(ret, name, ...)=' + redefine_function_declaration, + '-DDBUS_GMAIN_FUNCTION_NAME(name)=' + redefine_function_name, + language: 'c', +) + +dbus_gmain = subproject( + 'dbus-gmain', + default_options: [ + 'redefine_function_declaration=' + redefine_function_declaration, + 'redefine_function_name=' + redefine_function_name, + 'tests=false', + ], +) +dbus_gmain_dep = dbus_gmain.get_variable('dbus_gmain_dep') + +executable('use-dbus-gmain', 'use-dbus-gmain.c', dependencies: dbus_gmain_dep) diff --git a/subprojects/dbus-gmain/tests/use-as-subproject/use-dbus-gmain.c b/subprojects/dbus-gmain/tests/use-as-subproject/use-dbus-gmain.c new file mode 100644 index 0000000..21bf8e9 --- /dev/null +++ b/subprojects/dbus-gmain/tests/use-as-subproject/use-dbus-gmain.c @@ -0,0 +1,14 @@ +/* + * Copyright 2022 Collabora Ltd. + * SPDX-License-Identifier: MIT + */ + +#include <dbus-gmain/dbus-gmain.h> + +int +main (void) +{ + DBusConnection *conn = dbus_bus_get (DBUS_BUS_SESSION, NULL); + _my_set_up_connection (conn, NULL); + return 0; +} |