mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-10-31 16:32:18 +01:00 
			
		
		
		
	tests: Connect to GMemoryMonitor signals earlier
It might be possible for the `low-memory-warning` signal to be emitted (by the GLib worker thread) before the test has connected to it, which could cause the tests to loop forever. Potentially fixes https://gitlab.gnome.org/pwithnall/glib/-/jobs/5322491, though I have not been able to reproduce the race locally. Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
		| @@ -65,11 +65,10 @@ test_event (const void *data) | ||||
|                           "poll-interval-ms", 50, | ||||
|                           "mem-free-ratio", test_data->simulated_mem_free_ratio, | ||||
|                           NULL); | ||||
|   g_initable_init (G_INITABLE (monitor), NULL, &local_error); | ||||
|   g_assert_no_error (local_error); | ||||
|  | ||||
|   warning_id = g_signal_connect (monitor, "low-memory-warning", | ||||
|                                  G_CALLBACK (memory_monitor_signal_cb), &warning_level); | ||||
|   g_initable_init (G_INITABLE (monitor), NULL, &local_error); | ||||
|   g_assert_no_error (local_error); | ||||
|  | ||||
|   while (warning_level == -1) | ||||
|     g_main_context_iteration (NULL, TRUE); | ||||
|   | ||||
| @@ -84,6 +84,8 @@ test_receive_signals (SetupData *setup, gconstpointer data) | ||||
|   monitor = g_object_new (G_TYPE_MEMORY_MONITOR_PSI, | ||||
|                           "proc-path", setup->mock_proc_path, | ||||
|                           NULL); | ||||
|   warning_id = g_signal_connect (monitor, "low-memory-warning", | ||||
|                                  G_CALLBACK (memory_monitor_psi_signal_cb), &warning_level); | ||||
|   g_initable_init (G_INITABLE (monitor), NULL, &local_error); | ||||
|   g_assert_no_error (local_error); | ||||
|  | ||||
| @@ -93,9 +95,6 @@ test_receive_signals (SetupData *setup, gconstpointer data) | ||||
|                        &local_error); | ||||
|   g_assert_no_error (local_error); | ||||
|  | ||||
|   warning_id = g_signal_connect (monitor, "low-memory-warning", | ||||
|                                  G_CALLBACK (memory_monitor_psi_signal_cb), &warning_level); | ||||
|  | ||||
|   while (warning_level == -1) | ||||
|     g_main_context_iteration (NULL, TRUE); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user