From: Petr Mladek <pmladek@suse.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>
Cc: "Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Sergey Senozhatsky" <sergey.senozhatsky.work@gmail.com>,
linux-kernel@vger.kernel.org,
"Uwe Kleine-König" <uwe@kleine-koenig.org>,
"Ilya Dryomov" <idryomov@gmail.com>,
"Kees Cook" <keescook@chromium.org>,
"Tobin C . Harding" <me@tobin.cc>,
"Petr Mladek" <pmladek@suse.com>
Subject: [PATCH 2/3] lib/test_printf: Fix structure of basic pointer tests
Date: Thu, 27 Feb 2020 14:01:22 +0100 [thread overview]
Message-ID: <20200227130123.32442-3-pmladek@suse.com> (raw)
In-Reply-To: <20200227130123.32442-1-pmladek@suse.com>
The pointer formatting tests have been originally split by
the %p modifiers. For example, the function dentry() tested
%pd and %pD handling.
There were recently added tests that do not fit into
the existing structure, namely:
+ hashed pointer testing
+ null and invalid pointer handling with various modifiers
Reshuffle these tests to follow the original structure.
For completeness, add a test for "%px" with some "random" pointer
value. Note that it can't be tested with "%pE" because it would
cause crash.
Signed-off-by: Petr Mladek <pmladek@suse.com>
---
lib/test_printf.c | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/lib/test_printf.c b/lib/test_printf.c
index 6fa6fb606554..1ee1bb703307 100644
--- a/lib/test_printf.c
+++ b/lib/test_printf.c
@@ -278,28 +278,22 @@ test_hashed(const char *fmt, const void *p)
failed_tests++;
}
-static void __init
-plain(void)
-{
- test_hashed("%p", PTR);
-}
+#define PTR_INVALID ((void *)0x000000ab)
static void __init
-null_pointer(void)
+plain_pointer(void)
{
+ test_hashed("%p", PTR);
test_hashed("%p", NULL);
- test(ZEROS "00000000", "%px", NULL);
- test("(null)", "%pE", NULL);
+ test_hashed("%p", PTR_INVALID);
}
-#define PTR_INVALID ((void *)0x000000ab)
-
static void __init
-invalid_pointer(void)
+real_pointer(void)
{
- test_hashed("%p", PTR_INVALID);
+ test(PTR_STR, "%px", PTR);
+ test(ZEROS "00000000", "%px", NULL);
test(ZEROS "000000ab", "%px", PTR_INVALID);
- test("(efault)", "%pE", PTR_INVALID);
}
static void __init
@@ -326,6 +320,8 @@ addr(void)
static void __init
escaped_str(void)
{
+ test("(null)", "%pE", NULL);
+ test("(efault)", "%pE", PTR_INVALID);
}
static void __init
@@ -601,9 +597,8 @@ errptr(void)
static void __init
test_pointer(void)
{
- plain();
- null_pointer();
- invalid_pointer();
+ plain_pointer();
+ real_pointer();
symbol_ptr();
kernel_ptr();
struct_resource();
--
2.16.4
next prev parent reply other threads:[~2020-02-27 13:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-27 13:01 [PATCH 0/3] lib/test_printf: Clean up basic pointer testing Petr Mladek
2020-02-27 13:01 ` [PATCH 1/3] lib/test_printf: Clean up test of hashed pointers Petr Mladek
2020-02-27 14:30 ` Uwe Kleine-König
2020-03-02 10:24 ` Petr Mladek
2020-03-03 11:14 ` Rasmus Villemoes
2020-02-27 13:01 ` Petr Mladek [this message]
2020-02-27 13:01 ` [PATCH 3/3] lib/test_printf: Clean up invalid pointer value testing Petr Mladek
2020-03-03 7:24 ` [PATCH 0/3] lib/test_printf: Clean up basic pointer testing Sergey Senozhatsky
2020-03-03 9:22 ` Petr Mladek
2020-03-03 10:32 ` Sergey Senozhatsky
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=20200227130123.32442-3-pmladek@suse.com \
--to=pmladek@suse.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=idryomov@gmail.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=me@tobin.cc \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=uwe@kleine-koenig.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).