LINT_CCAN_MODULES := asort autodata dgraph ilog lbalance ptr_valid strmap
LINT_CCAN_SRCS := $(wildcard $(LINT_CCAN_MODULES:%=ccan/%/*.c))
LINT_OBJS := $(LINT_SRCS:%.c=%.o) $(LINT_CCAN_SRCS:%.c=%.o) $(TOOLS_OBJS)
+ifneq ($(GCOV),)
+LINT_GCOV = --gcov="$(GCOV)"
+endif
$(LINT): $(LINT).c $(LINT_OBJS)
$(PRE)$(CC) $(CCAN_CFLAGS) $(DEP_CFLAGS) $(LINT).c $(LINT_OBJS) -lm -o $@
# We produce .ok files when the tests succeed
%.ok: $(LINT) %info
- $(PRE)$(LINT) $(LINT_OPTS$(notdir $@)) --deps-fail-ignore $(LINTFLAGS) $(dir $*) && touch $@
+ $(PRE)$(LINT) $(LINT_OPTS$(notdir $@)) --deps-fail-ignore $(LINT_GCOV) $(LINTFLAGS) $(dir $*) && touch $@
check: $(MODULES:%=%/.ok)
fastcheck: $(MODULES:%=%/.fast.ok)
char *cwd = path_cwd(NULL), *dir;
struct ccanlint top; /* cannot_run may try to set ->can_run */
const char *override_compiler = NULL, *override_cflags = NULL;
+ const char *override_gcov = NULL;
/* Empty graph node to which we attach everything else. */
dgraph_init_node(&top.node);
NULL, &override_compiler, "set the compiler");
opt_register_arg("--cflags <flags>", opt_set_const_charp,
NULL, &override_cflags, "set the compiler flags");
+ opt_register_arg("--gcov <coverage tool>", opt_set_const_charp,
+ NULL, &override_gcov, "set the coverage tool");
opt_register_noarg("--deps-fail-ignore", opt_set_bool,
&deps_fail_ignore,
"don't fail if external dependencies are missing");
cflags = override_cflags;
if (override_compiler)
compiler = override_compiler;
+ if (override_gcov)
+ gcov = override_gcov;
if (argc == 1)
pass = test_module(&top.node, cwd, "",
#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, "gcov %s", args);
+ rc = run_command(ctx, time_ms, output, "%s %s", cmd, args);
tal_free(args);
return rc;
}
{
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;
const char *find_ccan_dir(const char *base);
/* Run gcov coverage tool */
+extern const char *gcov;
const char *gcov_unavailable(void *ctx);
bool run_gcov(const void *ctx, unsigned int *time_ms, char **output,
const char *fmt, ...);