X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fmodule_links.c;h=5c25e6126589ebd0cadd01d15b4fd66e8a18e11c;hb=d379e0ae835bdd047a5d277f7ded41f180134e27;hp=0bf9821555d70b53c98f6c767b8b36726b58bc72;hpb=441a3cb13e428cfa4973d83acb68e231a7cd4cf4;p=ccan diff --git a/tools/ccanlint/tests/module_links.c b/tools/ccanlint/tests/module_links.c index 0bf98215..5c25e612 100644 --- a/tools/ccanlint/tests/module_links.c +++ b/tools/ccanlint/tests/module_links.c @@ -23,13 +23,18 @@ static const char *can_build(struct manifest *m) static char *obj_list(const struct manifest *m) { - char *list = talloc_strdup(m, ""); + char *list; struct manifest *i; + if (m->compiled[COMPILE_NORMAL]) + list = talloc_strdup(m, m->compiled[COMPILE_NORMAL]); + else + list = talloc_strdup(m, ""); + /* Other CCAN deps. */ list_for_each(&m->deps, i, list) { if (i->compiled[COMPILE_NORMAL]) - list = talloc_asprintf_append(list, "%s ", + list = talloc_asprintf_append(list, " %s", i->compiled [COMPILE_NORMAL]); } @@ -38,26 +43,24 @@ static char *obj_list(const struct manifest *m) static char *lib_list(const struct manifest *m) { - unsigned int i, num; - char **libs = get_libs(m, ".", - &num, &m->info_file->compiled[COMPILE_NORMAL]); + unsigned int i; + char **libs; char *ret = talloc_strdup(m, ""); - for (i = 0; i < num; i++) + libs = get_libs(m, m->dir, "depends", get_or_compile_info); + for (i = 0; libs[i]; i++) ret = talloc_asprintf_append(ret, "-l%s ", libs[i]); return ret; } static void check_use_build(struct manifest *m, - bool keep, unsigned int *timeleft, struct score *score) { char *contents; char *tmpfile, *cmdout; - char *basename = talloc_asprintf(m, "%s/example.c", m->dir); int fd; - tmpfile = maybe_temp_file(m, ".c", keep, basename); + tmpfile = temp_file(m, ".c", "example.c"); fd = open(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0600); if (fd < 0) @@ -69,14 +72,14 @@ static void check_use_build(struct manifest *m, "{\n" " return 0;\n" "}\n", - m->basename, m->basename); + m->modname, m->basename); if (write(fd, contents, strlen(contents)) != strlen(contents)) err(1, "Failure writing to temporary file %s", tmpfile); close(fd); if (compile_and_link(score, tmpfile, ccan_dir, obj_list(m), compiler, cflags, lib_list(m), - maybe_temp_file(m, "", keep, tmpfile), + temp_file(m, "", tmpfile), &cmdout)) { score->pass = true; score->score = score->total;