[vlc-devel] [PATCH 2/2] test: libvlc: Added a formatted log callback test

Jérémy VIGNELLES jeremy.vignelles at dev3i.fr
Fri May 17 10:05:01 CEST 2019


---
 test/libvlc/core.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/test/libvlc/core.c b/test/libvlc/core.c
index 703a2f2962..a199454fec 100644
--- a/test/libvlc/core.c
+++ b/test/libvlc/core.c
@@ -96,6 +96,32 @@ static void test_audio_output (void)
     libvlc_release (vlc);
 }
 
+static void formatted_log_callback(void *data, int level, const libvlc_log_t *ctx,
+                              const char *message)
+{
+    if(!strncmp(message, "VLC media player", 16))
+    {
+        (*(bool*)data) = true;
+    }
+    (void)data; (void) level; (void)ctx;
+}
+
+static void test_formatted_logs (void)
+{
+    libvlc_instance_t *vlc = libvlc_new (0, NULL);
+    assert (vlc != NULL);
+
+    bool vlc_log_received = false;
+    libvlc_log_preformatted_context_t *data = libvlc_log_preformatted_context_new(vlc, 0, formatted_log_callback, &vlc_log_received);
+    assert (data != NULL);
+
+    libvlc_log_set_preformatted(vlc, data);
+
+    assert(vlc_log_received);
+    libvlc_log_preformatted_context_release(vlc, data);
+    libvlc_release (vlc);
+}
+
 int main (void)
 {
     test_init();
@@ -103,6 +129,7 @@ int main (void)
     test_core (test_defaults_args, test_defaults_nargs);
     test_audiovideofilterlists (test_defaults_args, test_defaults_nargs);
     test_audio_output ();
+    test_formatted_logs ();
 
     return 0;
 }
-- 
2.21.0.windows.1



More information about the vlc-devel mailing list