Skip to content

gtestutils: Ensure test_data is freed even if a test is skipped

Philip Withnall requested to merge pwithnall/glib:param-leak into main

It’s reasonable for the main() function in a test suite to pass ownership of some test data to g_test_add_data_func_full(), along with a GDestroyNotify, and rely on GTest to free the data after all tests have been run.

Unfortunately that only worked if the test was run, and not skipped before its test function was called. This could happen if, for example, it had /subprocess in its path.

Fix that by always freeing the test data. This required reworking how tests are skipped, slightly, to bring all the logic for that within test_case_run(), so that it could always handle the memory management.

Signed-off-by: Philip Withnall

Helps: #3248 (closed)

Merge request reports