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

Jérémy VIGNELLES jeremy.vignelles at dev3i.fr
Mon May 20 22:58:41 CEST 2019


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

diff --git a/test/libvlc/core.c b/test/libvlc/core.c
index 703a2f2..d8df81f 100644
--- a/test/libvlc/core.c
+++ b/test/libvlc/core.c
@@ -96,6 +96,29 @@ 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_set_preformatted(vlc, LIBVLC_DEBUG, formatted_log_callback, &vlc_log_received);
+
+    assert(vlc_log_received);
+    libvlc_release (vlc);
+}
+
 int main (void)
 {
     test_init();
@@ -103,6 +126,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.20.1



More information about the vlc-devel mailing list