lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190828052405.GA526@jagdpanzerIV>
Date:   Wed, 28 Aug 2019 14:24:05 +0900
From:   Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
To:     Brendan Higgins <brendanhiggins@...gle.com>
Cc:     Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
        shuah@...nel.org, pmladek@...e.com, sergey.senozhatsky@...il.com,
        rostedt@...dmis.org, kunit-dev@...glegroups.com,
        linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
        frowand.list@...il.com, sboyd@...nel.org,
        Randy Dunlap <rdunlap@...radead.org>,
        Stephen Rothwell <sfr@...b.auug.org.au>
Subject: Re: [PATCH v1] printk: add dummy vprintk_emit for when
 CONFIG_PRINTK=n

On (08/27/19 21:45), Brendan Higgins wrote:
[..]
> I actually use it in a very similar way as dev_printk() does. I am using
> it to define an equivalent kunit_printk(), which takes a log level, and
> adds its own test information to the log.
> 
> What I have now is:
> 
> static int kunit_vprintk_emit(int level, const char *fmt, va_list args)
> {
> 	return vprintk_emit(0, level, NULL, 0, fmt, args);
> }
> 
> static int kunit_printk_emit(int level, const char *fmt, ...)
> {
> 	va_list args;
> 	int ret;
> 
> 	va_start(args, fmt);
> 	ret = kunit_vprintk_emit(level, fmt, args);
> 	va_end(args);
> 
> 	return ret;
> }
> 
> static void kunit_vprintk(const struct kunit *test,
> 			  const char *level,
> 			  struct va_format *vaf)
> {
> 	kunit_printk_emit(level[1] - '0', "\t# %s: %pV", test->name, vaf);
> }

Basically, for prefixes we have pr_fmt().

#define pr_fmt(fmt) "module name: " fmt

but pr_fmt() is mostly for static prefixes. If that doesn't work for
you, then maybe you can tweak kunit_foo() macros?

E.g. something like this

#define kunit_info(test, fmt, ...)                                   \
	printk(KERN_INFO "\t# %s: " pr_fmt(fmt), (test)->name, ##__VA_ARGS__)

#define kunit_err(test, fmt, ...)                                    \
	printk(KERN_ERR "\t# %s: " pr_fmt(fmt), (test)->name, ##__VA_ARGS__)

#define kunit_debug(test, fmt, ...)                                  \
	printk(KERN_DEBUG "\t# %s: " pr_fmt(fmt), (test)->name, ##__VA_ARGS__)

Would that do the trick? Am I missing something?

	-ss

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ