| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #include "tools.h"
- #include <stdlib.h>
- #include <stdarg.h>
- const char *gcov; /* = NULL */
- bool run_gcov(const void *ctx, unsigned int *time_ms, char **output,
- const char *fmt, ...)
- {
- const char *cmd = gcov;
- char *args;
- va_list ap;
- bool rc;
- if (!gcov) {
- #ifdef __GNUC__
- cmd = "gcov";
- #endif
- }
- if (!cmd)
- return false;
- va_start(ap, fmt);
- args = tal_vfmt(ctx, fmt, ap);
- rc = run_command(ctx, time_ms, output, "%s %s", cmd, args);
- tal_free(args);
- return rc;
- }
- const char *gcov_unavailable(void *ctx)
- {
- const char *err = NULL;
- /*
- * If the user has specified a path, assume they know what
- * they're doing
- */
- if (gcov)
- return NULL;
- #ifdef __GNUC__
- unsigned int timeleft = default_timeout_ms;
- char *output;
- if (!run_gcov(ctx, &timeleft, &output, "-h")) {
- err = tal_fmt(ctx, "No gcov support: %s", output);
- tal_free(output);
- }
- #else
- err = "No coverage support for this compiler";
- #endif
- return err;
- }
|