I have been using GstCheck to configure unit tests for an application and its various elements and I’ve reached a situation where being able to run the test with a more verbose log level would be helpful. It would also be fantastic if when running these tests via meson test that only test failures would actually be printed to the output log file, to keep it smaller.
My first inclination was to define an alternate GST_CHECK_MAIN macro to configure the ring buffer logger ahead of the gst_check_init() call and then only get those logs if the return from gst_check_run_suite() was non-zero:
#define GST_CHECK_MAIN(name) \
int main (int argc, char **argv) \
{ \
Suite *s; \
gint result = 0; \
\
gst_debug_remove_log_function (gst_debug_log_default); \
gst_debug_add_ring_buffer_logger (16384, 20); \
gst_check_init (&argc, &argv); \
\
s = name ## _suite (); \
result = gst_check_run_suite (s, # name, __FILE__); \
if (result) { \
gchar **messages = gst_debug_ring_buffer_logger_get_logs ();\
gchar *message = NULL; \
\
while ((message = *messages++)) { \
g_printerr ("%s", message); \
g_clear_pointer (&message, g_free); \
} \
} \
return result; \
}
However, this has two shortcomings. First, it’s printing the logs for all tests in every case in the entire suite if a single test fails (vs. only printing the logs from the failed case). Second, it only captures messages up until gst_check_init() redirects everything to private functions via g_log_set_handler(...) calls for various logging domains including ones from an internal array (log_domains).
This is an older test suite that predates some of my more recent things using Google Test, where I can make logging configuration changes like this prior to gst_init() and it all works as expected.
I’m currently using 1.22.6 and have not found an example gstcheck -based unit test that also configures something similar to the above with respect to logging, nor have I found any good results searching the internet, so I’m not confident in what questions I should even be asking at this point since these stdout/stderr default logging outputs are the root cause of making the test application run with entirely different results just by configuring the log level with GST_DEBUG.
- Is staying with GstCheck gaining providing a necessary benefit in terms of test stability, fidelity, etc. – something specific to gstreamer – over an alternative like Google Test (configuring logging, then calling
gst_init()andgst_deinit()myself)? - If GstCheck is providing some necessary benefit, has anyone found a way to tune the logging options to use the ring buffer, or some other performant solution, where the log level does not break tests?
Thank you all in advance for your suggestions.