kprintf variants for testing.
This commit is contained in:
parent
a4ad38f616
commit
a33db5e187
@ -197,4 +197,13 @@ void kprintf_bootstrap(void);
|
||||
void random_yielder(uint32_t);
|
||||
void random_spinner(uint32_t);
|
||||
|
||||
/*
|
||||
* Testing variants of kprintf. tprintf is silent during automated testing.
|
||||
* sprintf prefixes the kernel secret to kprintf messages during automated
|
||||
* testing.
|
||||
*/
|
||||
|
||||
int tkprintf(const char *format, ...) __PF(1,2);
|
||||
int skprintf(const char *format, ...) __PF(1,2);
|
||||
|
||||
#endif /* _LIB_H_ */
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <mainbus.h>
|
||||
#include <vfs.h> // for vfs_sync()
|
||||
#include <lamebus/ltrace.h> // for ltrace_stop()
|
||||
#include <kern/secret.h>
|
||||
|
||||
|
||||
/* Flags word for DEBUG() macro. */
|
||||
@ -90,13 +91,13 @@ console_send(void *junk, const char *data, size_t len)
|
||||
}
|
||||
|
||||
/*
|
||||
* Printf to the console.
|
||||
* kprintf and tprintf helper function.
|
||||
*/
|
||||
inline
|
||||
int
|
||||
kprintf(const char *fmt, ...)
|
||||
vkprintf(const char *fmt, va_list ap)
|
||||
{
|
||||
int chars;
|
||||
va_list ap;
|
||||
bool dolock;
|
||||
|
||||
dolock = kprintf_lock != NULL
|
||||
@ -111,9 +112,7 @@ kprintf(const char *fmt, ...)
|
||||
spinlock_acquire(&kprintf_spinlock);
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
chars = __vprintf(console_send, NULL, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (dolock) {
|
||||
lock_release(kprintf_lock);
|
||||
@ -125,6 +124,62 @@ kprintf(const char *fmt, ...)
|
||||
return chars;
|
||||
}
|
||||
|
||||
/*
|
||||
* Printf to the console.
|
||||
*/
|
||||
int
|
||||
kprintf(const char *fmt, ...)
|
||||
{
|
||||
int chars;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
chars = vkprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return chars;
|
||||
}
|
||||
|
||||
/*
|
||||
* kprintf variant that is quiet during automated testing
|
||||
*/
|
||||
int
|
||||
tkprintf(const char *fmt, ...)
|
||||
{
|
||||
int chars;
|
||||
va_list ap;
|
||||
|
||||
if (KERNEL_SECRET != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
chars = vkprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return chars;
|
||||
}
|
||||
|
||||
/*
|
||||
* kprintf variant that prints the automated secret
|
||||
*/
|
||||
int
|
||||
skprintf(const char *fmt, ...)
|
||||
{
|
||||
int chars;
|
||||
va_list ap;
|
||||
|
||||
if (KERNEL_SECRET != 0) {
|
||||
kprintf("SECRET=%llu ", KERNEL_SECRET);
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
chars = vkprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return chars;
|
||||
}
|
||||
|
||||
/*
|
||||
* panic() is for fatal errors. It prints the printf arguments it's
|
||||
* passed and then halts the system.
|
||||
|
Loading…
x
Reference in New Issue
Block a user