]> xenbits.xensource.com Git - people/royger/xen-test-framework.git/commitdiff
Use vsnprintf() to provide full formatting capabilities to the console
authorAndrew Cooper <andrew.cooper3@citrix.com>
Sun, 12 Apr 2015 01:55:01 +0000 (02:55 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 28 Sep 2015 13:53:02 +0000 (14:53 +0100)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
common/console.c
include/xtf/console.h
tests/example/main.c

index fe2551b22851f8ca828d22b71b190a94ac2138c6..34cb89d77255ec38607c27543049913dbc4a4acc 100644 (file)
@@ -81,12 +81,25 @@ void init_pv_console(xencons_interface_t *ring, evtchn_port_t port)
     register_console_callback(pv_console_write);
 }
 
-void printk(const char *fmt, ...)
+void vprintk(const char *fmt, va_list args)
 {
+    static char buf[2048];
     unsigned int i;
+    int rc;
+
+    rc = vsnprintf(buf, sizeof(buf), fmt, args);
 
     for ( i = 0; i < nr_cons_cb; ++i )
-        output_fns[i](fmt, strlen(fmt));
+        output_fns[i](buf, rc);
+}
+
+void printk(const char *fmt, ...)
+{
+    va_list args;
+
+    va_start(args, fmt);
+    vprintk(fmt, args);
+    va_end(args);
 }
 
 /*
index e85236b8c0f4eb60a0e19be5169fbaa7b8f95a3a..2a93c06d85d4681ab1463fa64b9e9f20c5991f22 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef XTF_CONSOLE_H
 #define XTF_CONSOLE_H
 
+#include <xtf/libc.h>
 #include <xtf/compiler.h>
 
 #include <xen/event_channel.h>
@@ -21,6 +22,7 @@ void register_console_callback(cons_output_cb cb);
 void init_pv_console(xencons_interface_t *ring,
                      evtchn_port_t port);
 
+void vprintk(const char *fmt, va_list args) __printf(1, 0);
 void printk(const char *fmt, ...) __printf(1, 2);
 
 #endif /* XTF_CONSOLE_H */
index beb74de68395d2e687b342d70b2beedc56b4b0fd..6e2c53d5b36b2e86a95df7c7bc4facd7e1a195b4 100644 (file)
@@ -1,7 +1,9 @@
 #include <xtf/test.h>
+#include <xtf/console.h>
 
 void test_main(void)
 {
+    printk("Hello World\n");
 }
 
 /*