[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [Patch v3 7/7] Test harness for new printk formatting



Not intended for committing
---
 xen/arch/x86/irq.c |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index a47d4f6..046230f 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -2485,3 +2485,63 @@ bool_t hvm_domain_use_pirq(const struct domain *d, const 
struct pirq *pirq)
     return is_hvm_domain(d) && pirq &&
            pirq->arch.hvm.emuirq != IRQ_UNBOUND; 
 }
+
+static void test_printk(unsigned char key)
+{
+    char buffer[28] = { ' ' };
+    unsigned i, t;
+
+    printk("'%c' pressed - In %s()\n", key, __func__);
+    printk("Some symbols: '%ps' '%pS'\n", _p(printk), _p(printk));
+    printk("More symbols: '%ps' '%pS'\n", _p(test_printk), _p(test_printk));
+    printk("Invalid: '%ps' '%pS'\n", _p(0x20), _p(0x20));
+    printk("Partial: '%ps' '%pS'\n", _p(((unsigned long)test_printk + 0x20)),
+           _p(((unsigned long)test_printk + 0x20)));
+
+    /* Use 's as guards */
+    buffer[0] = '\''; buffer[sizeof buffer - 1] = '\0';
+
+    for ( i = 6; i < sizeof(buffer) - 2; ++i )
+    {
+        t = snprintf(&buffer[1], i, "%pS", _p(test_printk));
+
+        if ( buffer[i] == '\0' )
+            buffer[i] = '\'';
+
+        printk("Test %.2u byte buffer %s\n", i, buffer);
+
+        if ( t < i )
+            break;
+    }
+
+    memset(&buffer[1], ' ', sizeof buffer - 2);
+    buffer[sizeof buffer - 1] = '\0';
+
+    for ( i = 6; i < sizeof(buffer) - 2; ++i )
+    {
+        t = snprintf(&buffer[1], i, "%ps", _p(((unsigned long)test_printk + 
0x20)));
+
+        if ( buffer[i] == '\0' )
+            buffer[i] = '\'';
+
+        printk("Test %.2u byte buffer %s\n", i, buffer);
+
+        if ( t < i )
+            break;
+    }
+
+    printk("Testing pointer: '%ps' '%pS'\n", dom0, dom0);
+}
+
+static struct keyhandler test_printk_keyhandler = {
+    .diagnostic = 1,
+    .u.fn = test_printk,
+    .desc = "Test new printk formatting options"
+};
+
+static int __init setup_test_printk(void)
+{
+    register_keyhandler('6', &test_printk_keyhandler);
+    return 0;
+}
+__initcall(setup_test_printk);
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.