From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Subject: [Patch v3 7/7] Test harness for new printk formatting
Date: Tue, 5 Nov 2013 14:38:44 +0000 [thread overview]
Message-ID: <1383662324-3397-8-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1383662324-3397-1-git-send-email-andrew.cooper3@citrix.com>
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
next prev parent reply other threads:[~2013-11-05 14:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-05 14:38 [PATCH v3 0/7] Printk symbol specifier Andrew Cooper
2013-11-05 14:38 ` [Patch v3 1/7] common/vsprintf: Refactor string() out of vsnprintf() Andrew Cooper
2013-11-05 14:38 ` [Patch v3 2/7] common/vsprintf: Refactor pointer() " Andrew Cooper
2013-11-05 14:38 ` [Patch v3 3/7] common/vsprintf: Add %ps and %pS format specifier support Andrew Cooper
2013-11-05 14:38 ` [Patch v3 4/7] x86: Replace print_symbol() with new %ps/%pS format Andrew Cooper
2013-11-05 14:38 ` [Patch v3 5/7] arm: " Andrew Cooper
2013-11-05 14:38 ` [Patch v3 6/7] common/symbols: Remove print_symbol() and associated infrastructure Andrew Cooper
2013-11-05 14:38 ` Andrew Cooper [this message]
2013-11-05 15:04 ` [PATCH v3 0/7] Printk symbol specifier Jan Beulich
2013-11-06 17:48 ` Andrew Cooper
2013-11-11 17:20 ` Keir Fraser
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1383662324-3397-8-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).