| 
									
										
										
										
											2023-02-08 18:12:00 +01:00
										 |  |  | /* PipeWire */ | 
					
						
							|  |  |  | /* SPDX-FileCopyrightText: Copyright © 2019 Wim Taymans */ | 
					
						
							|  |  |  | /* SPDX-License-Identifier: MIT */ | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | #include "pwtest.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-18 11:40:50 +10:00
										 |  |  | #include <spa/utils/string.h>
 | 
					
						
							| 
									
										
										
										
											2019-12-19 13:15:10 +01:00
										 |  |  | #include <spa/support/dbus.h>
 | 
					
						
							|  |  |  | #include <spa/support/cpu.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | #include <pipewire/pipewire.h>
 | 
					
						
							| 
									
										
										
										
											2019-12-11 10:57:10 +01:00
										 |  |  | #include <pipewire/global.h>
 | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define TEST_FUNC(a,b,func)	\
 | 
					
						
							|  |  |  | do {				\ | 
					
						
							|  |  |  | 	a.func = b.func;	\ | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_ptr_eq(SPA_PTRDIFF(&a.func, &a), SPA_PTRDIFF(&b.func, &b)); \ | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | } while(0) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | PWTEST(context_abi) | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	struct pw_context_events ev; | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	struct { | 
					
						
							|  |  |  | 		uint32_t version; | 
					
						
							|  |  |  | 		void (*destroy) (void *data); | 
					
						
							|  |  |  | 		void (*free) (void *data); | 
					
						
							| 
									
										
										
										
											2019-12-11 11:21:43 +01:00
										 |  |  | 		void (*check_access) (void *data, struct pw_impl_client *client); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 		void (*global_added) (void *data, struct pw_global *global); | 
					
						
							|  |  |  | 		void (*global_removed) (void *data, struct pw_global *global); | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	} test = { PW_VERSION_CONTEXT_EVENTS, NULL }; | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pw_init(0, NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	TEST_FUNC(ev, test, destroy); | 
					
						
							|  |  |  | 	TEST_FUNC(ev, test, free); | 
					
						
							|  |  |  | 	TEST_FUNC(ev, test, check_access); | 
					
						
							|  |  |  | 	TEST_FUNC(ev, test, global_added); | 
					
						
							|  |  |  | 	TEST_FUNC(ev, test, global_removed); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_int_eq(PW_VERSION_CONTEXT_EVENTS, 0); | 
					
						
							|  |  |  | 	pwtest_int_eq(sizeof(ev), sizeof(test)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-12 09:24:58 +10:00
										 |  |  | 	pw_deinit(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	return PWTEST_PASS; | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | static void context_destroy_error(void *data) | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_fail_if_reached(); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | static void context_free_error(void *data) | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_fail_if_reached(); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-12-11 11:21:43 +01:00
										 |  |  | static void context_check_access_error(void *data, struct pw_impl_client *client) | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_fail_if_reached(); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | static void context_global_added_error(void *data, struct pw_global *global) | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_fail_if_reached(); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | static void context_global_removed_error(void *data, struct pw_global *global) | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_fail_if_reached(); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | static const struct pw_context_events context_events_error = | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	PW_VERSION_CONTEXT_EVENTS, | 
					
						
							|  |  |  | 	.destroy = context_destroy_error, | 
					
						
							|  |  |  | 	.free = context_free_error, | 
					
						
							|  |  |  | 	.check_access = context_check_access_error, | 
					
						
							|  |  |  | 	.global_added = context_global_added_error, | 
					
						
							|  |  |  | 	.global_removed = context_global_removed_error, | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int destroy_count = 0; | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | static void context_destroy_count(void *data) | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	destroy_count++; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | static int free_count = 0; | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | static void context_free_count(void *data) | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	free_count++; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | static int global_removed_count = 0; | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | static void context_global_removed_count(void *data, struct pw_global *global) | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	global_removed_count++; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | static int context_foreach_count = 0; | 
					
						
							|  |  |  | static int context_foreach(void *data, struct pw_global *global) | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	context_foreach_count++; | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | static int context_foreach_error(void *data, struct pw_global *global) | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	context_foreach_count++; | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	return -1; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | PWTEST(context_create) | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct pw_main_loop *loop; | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	struct pw_context *context; | 
					
						
							| 
									
										
										
										
											2021-10-22 19:04:47 +03:00
										 |  |  | 	struct spa_hook listener = { { NULL }, }; | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	struct pw_context_events context_events = context_events_error; | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	int res; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pw_init(0, NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	loop = pw_main_loop_new(NULL); | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_ptr_notnull(loop); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	context = pw_context_new(pw_main_loop_get_loop(loop), | 
					
						
							| 
									
										
										
										
											2019-12-06 17:12:07 +01:00
										 |  |  | 			pw_properties_new( | 
					
						
							| 
									
										
										
										
											2021-02-11 17:54:21 +01:00
										 |  |  | 				PW_KEY_CONFIG_NAME, "null", | 
					
						
							| 
									
										
										
										
											2019-12-06 17:12:07 +01:00
										 |  |  | 				NULL), 12); | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_ptr_notnull(context); | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	pw_context_add_listener(context, &listener, &context_events, context); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* check main loop */ | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_ptr_eq(pw_context_get_main_loop(context), pw_main_loop_get_loop(loop)); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	/* check user data */ | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_ptr_notnull(pw_context_get_user_data(context)); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* iterate globals */ | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_int_eq(context_foreach_count, 0); | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	res = pw_context_for_each_global(context, context_foreach, context); | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_int_eq(res, 0); | 
					
						
							| 
									
										
										
										
											2021-06-14 17:30:27 +02:00
										 |  |  | 	pwtest_int_eq(context_foreach_count, 2); | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	res = pw_context_for_each_global(context, context_foreach_error, context); | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_int_eq(res, -1); | 
					
						
							| 
									
										
										
										
											2021-06-14 17:30:27 +02:00
										 |  |  | 	pwtest_int_eq(context_foreach_count, 3); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* check destroy */ | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	context_events.destroy = context_destroy_count; | 
					
						
							|  |  |  | 	context_events.free = context_free_count; | 
					
						
							|  |  |  | 	context_events.global_removed = context_global_removed_count; | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_int_eq(destroy_count, 0); | 
					
						
							|  |  |  | 	pwtest_int_eq(free_count, 0); | 
					
						
							|  |  |  | 	pwtest_int_eq(global_removed_count, 0); | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	pw_context_destroy(context); | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_int_eq(destroy_count, 1); | 
					
						
							|  |  |  | 	pwtest_int_eq(free_count, 1); | 
					
						
							| 
									
										
										
										
											2021-06-14 17:30:27 +02:00
										 |  |  | 	pwtest_int_eq(global_removed_count, 2); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	pw_main_loop_destroy(loop); | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-12 09:24:58 +10:00
										 |  |  | 	pw_deinit(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	return PWTEST_PASS; | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | PWTEST(context_properties) | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct pw_main_loop *loop; | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	struct pw_context *context; | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	const struct pw_properties *props; | 
					
						
							| 
									
										
										
										
											2021-10-22 19:04:47 +03:00
										 |  |  | 	struct spa_hook listener = { { NULL }, }; | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	struct pw_context_events context_events = context_events_error; | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	struct spa_dict_item items[3]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pw_init(0, NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	loop = pw_main_loop_new(NULL); | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	context = pw_context_new(pw_main_loop_get_loop(loop), | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 			pw_properties_new("foo", "bar", | 
					
						
							|  |  |  | 					  "biz", "fuzz", | 
					
						
							|  |  |  | 					  NULL), | 
					
						
							|  |  |  | 			0); | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_ptr_notnull(context); | 
					
						
							|  |  |  | 	pwtest_ptr_null(pw_context_get_user_data(context)); | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	pw_context_add_listener(context, &listener, &context_events, context); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	props = pw_context_get_properties(context); | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_ptr_notnull(props); | 
					
						
							|  |  |  | 	pwtest_str_eq(pw_properties_get(props, "foo"), "bar"); | 
					
						
							|  |  |  | 	pwtest_str_eq(pw_properties_get(props, "biz"), "fuzz"); | 
					
						
							|  |  |  | 	pwtest_str_eq(pw_properties_get(props, "buzz"), NULL); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* remove foo */ | 
					
						
							|  |  |  | 	items[0] = SPA_DICT_ITEM_INIT("foo", NULL); | 
					
						
							|  |  |  | 	/* change biz */ | 
					
						
							|  |  |  | 	items[1] = SPA_DICT_ITEM_INIT("biz", "buzz"); | 
					
						
							|  |  |  | 	/* add buzz */ | 
					
						
							|  |  |  | 	items[2] = SPA_DICT_ITEM_INIT("buzz", "frizz"); | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	pw_context_update_properties(context, &SPA_DICT_INIT(items, 3)); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_ptr_eq(props, pw_context_get_properties(context)); | 
					
						
							|  |  |  | 	pwtest_str_eq(pw_properties_get(props, "foo"), NULL); | 
					
						
							|  |  |  | 	pwtest_str_eq(pw_properties_get(props, "biz"), "buzz"); | 
					
						
							|  |  |  | 	pwtest_str_eq(pw_properties_get(props, "buzz"), "frizz"); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	spa_hook_remove(&listener); | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	pw_context_destroy(context); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	pw_main_loop_destroy(loop); | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-12 09:24:58 +10:00
										 |  |  | 	pw_deinit(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	return PWTEST_PASS; | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | PWTEST(context_support) | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-06-27 17:47:13 +02:00
										 |  |  | 	static const char * const types[] = { | 
					
						
							| 
									
										
										
										
											2019-06-06 16:40:15 +02:00
										 |  |  | 		SPA_TYPE_INTERFACE_DataSystem, | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 		SPA_TYPE_INTERFACE_DataLoop, | 
					
						
							| 
									
										
										
										
											2019-06-06 16:40:15 +02:00
										 |  |  | 		SPA_TYPE_INTERFACE_System, | 
					
						
							| 
									
										
										
										
											2019-06-06 15:20:43 +02:00
										 |  |  | 		SPA_TYPE_INTERFACE_Loop, | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 		SPA_TYPE_INTERFACE_LoopUtils, | 
					
						
							|  |  |  | 		SPA_TYPE_INTERFACE_Log, | 
					
						
							| 
									
										
										
										
											2022-02-03 18:52:54 +01:00
										 |  |  | #ifdef HAVE_DBUS
 | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 		SPA_TYPE_INTERFACE_DBus, | 
					
						
							| 
									
										
										
										
											2021-10-09 15:00:04 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 		SPA_TYPE_INTERFACE_CPU | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2021-06-27 17:47:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	struct pw_main_loop *loop; | 
					
						
							|  |  |  | 	struct pw_context *context; | 
					
						
							|  |  |  | 	const struct spa_support *support; | 
					
						
							|  |  |  | 	uint32_t n_support; | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	size_t i; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pw_init(0, NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	loop = pw_main_loop_new(NULL); | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	context = pw_context_new(pw_main_loop_get_loop(loop), NULL, 0); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	support = pw_context_get_support(context, &n_support); | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_ptr_notnull(support); | 
					
						
							|  |  |  | 	pwtest_int_gt(n_support, 0U); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	for (i = 0; i < SPA_N_ELEMENTS(types); i++) { | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 		pwtest_ptr_notnull(spa_support_find(support, n_support, types[i])); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-10 18:19:56 +01:00
										 |  |  | 	pw_context_destroy(context); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 	pw_main_loop_destroy(loop); | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-12 09:24:58 +10:00
										 |  |  | 	pw_deinit(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	return PWTEST_PASS; | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | PWTEST_SUITE(context) | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	pwtest_add(context_abi, PWTEST_NOARG); | 
					
						
							|  |  |  | 	pwtest_add(context_create, PWTEST_NOARG); | 
					
						
							|  |  |  | 	pwtest_add(context_properties, PWTEST_NOARG); | 
					
						
							|  |  |  | 	pwtest_add(context_support, PWTEST_NOARG); | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-04 11:15:04 +10:00
										 |  |  | 	return PWTEST_PASS; | 
					
						
							| 
									
										
										
										
											2019-01-08 17:38:34 +01:00
										 |  |  | } |