diff options
author | Julian Andres Klode <jak@debian.org> | 2016-09-11 13:58:40 +0200 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2016-09-11 17:44:17 +0200 |
commit | bccb344412a0e97afdf0aaaf41a31124c84f6eaa (patch) | |
tree | c57341872a3d83bc5a01ea5b45d9b25d631afacc /test/interactive-helper/libnoprofile.c | |
parent | 422a2eba84361a8dfd84b549c13037512779c572 (diff) |
Coverage: Do not print messages from gcov
We need to ignore messages from gcov. All those messages
start with profiling: and are printed using vfprintf(), so
the only thing we can do is add a library overriding those
functions and linking apt-pkg to it.
Diffstat (limited to 'test/interactive-helper/libnoprofile.c')
-rw-r--r-- | test/interactive-helper/libnoprofile.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/interactive-helper/libnoprofile.c b/test/interactive-helper/libnoprofile.c new file mode 100644 index 000000000..2cba6dc8b --- /dev/null +++ b/test/interactive-helper/libnoprofile.c @@ -0,0 +1,50 @@ +#define _GNU_SOURCE +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> +#include <dlfcn.h> +#include <unistd.h> +#include <stdio.h> + +int vprintf(const char *format, va_list ap) { + static int (*func_fprintf)(const char *format, va_list ap) = NULL; + if (func_fprintf == NULL) + func_fprintf = (int (*) (const char *format, va_list ap)) dlsym(RTLD_NEXT, "vprintf"); + + va_list ap2; + va_copy(ap2, ap); + if (strncmp(format, "profiling:", strlen("profiling:")) == 0) + return 0; + int res = func_fprintf(format, ap2); + va_end(ap2); + return res; +} +int printf(const char *format, ...) { + va_list ap; + va_start(ap, format); + int res = vprintf(format, ap); + va_end(ap); + return res; +} + +int vfprintf(FILE *stream, const char *format, va_list ap) { + static int (*func_vfprintf)(FILE *stream, const char *format, va_list ap) = NULL; + if (func_vfprintf == NULL) + func_vfprintf = (int (*) (FILE *stream, const char *format, va_list ap)) dlsym(RTLD_NEXT, "vfprintf"); + + va_list ap2; + va_copy(ap2, ap); + if (strncmp(format, "profiling:", strlen("profiling:")) == 0) + return 0; + int res = func_vfprintf(stream, format, ap2); + va_end(ap2); + return res; +} + +int fprintf(FILE *stream, const char *format, ...) { + va_list ap; + va_start(ap, format); + int res = vfprintf(stream, format, ap); + va_end(ap); + return res; +} |