mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
This change allows mocking of print macros in unit tests. Being able to do this in unit tests, enables us to catch output from zgetdump functions and test it. Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com> Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
56 lines
917 B
C
56 lines
917 B
C
/*
|
|
* Copyright IBM Corp. 2001, 2017, 2021
|
|
*
|
|
* s390-tools is free software; you can redistribute it and/or modify
|
|
* it under the terms of the MIT license. See LICENSE for details.
|
|
*/
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include "zg.h"
|
|
|
|
static inline void _zg_stderr(const char *fmt, va_list ap)
|
|
{
|
|
vfprintf(stderr, fmt, ap);
|
|
fflush(stderr);
|
|
}
|
|
|
|
static inline void _zg_stderr_pr(const char *fmt, va_list ap)
|
|
{
|
|
fprintf(stderr, "\r%s: ", "zgetdump");
|
|
vfprintf(stderr, fmt, ap);
|
|
}
|
|
|
|
static inline void _zg_stdout(const char *fmt, va_list ap)
|
|
{
|
|
vfprintf(stdout, fmt, ap);
|
|
fflush(stdout);
|
|
}
|
|
|
|
void zg_stderr(const char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
_zg_stderr(fmt, ap);
|
|
va_end(ap);
|
|
}
|
|
|
|
void zg_stderr_pr(const char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
_zg_stderr_pr(fmt, ap);
|
|
va_end(ap);
|
|
}
|
|
|
|
void zg_stdout(const char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
_zg_stdout(fmt, ap);
|
|
va_end(ap);
|
|
}
|