gcov.c 686 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "tools.h"
  2. #include <stdlib.h>
  3. #include <stdarg.h>
  4. bool run_gcov(const void *ctx, unsigned int *time_ms, char **output,
  5. const char *fmt, ...)
  6. {
  7. char *args;
  8. va_list ap;
  9. bool rc;
  10. va_start(ap, fmt);
  11. args = tal_vfmt(ctx, fmt, ap);
  12. rc = run_command(ctx, time_ms, output, "gcov %s", args);
  13. tal_free(args);
  14. return rc;
  15. }
  16. const char *gcov_unavailable(void *ctx)
  17. {
  18. const char *err = NULL;
  19. #ifdef __GNUC__
  20. unsigned int timeleft = default_timeout_ms;
  21. char *output;
  22. if (!run_gcov(ctx, &timeleft, &output, "-h")) {
  23. err = tal_fmt(ctx, "No gcov support: %s", output);
  24. tal_free(output);
  25. }
  26. #else
  27. err = "No coverage support for this compiler";
  28. #endif
  29. return err;
  30. }