Commit af5b1a18 authored by Rusty Russell's avatar Rusty Russell

ccanlint: remove argument to -k/--keep

It's much easier to simply say "keep all", and it simplifies the code
quite a bit.
parent 04f453bb
...@@ -42,6 +42,7 @@ struct ccanlint_map { ...@@ -42,6 +42,7 @@ struct ccanlint_map {
int verbose = 0; int verbose = 0;
static struct ccanlint_map tests; static struct ccanlint_map tests;
bool safe_mode = false; bool safe_mode = false;
bool keep_results = false;
static bool targeting = false; static bool targeting = false;
static unsigned int timeout; static unsigned int timeout;
...@@ -150,7 +151,7 @@ static bool run_test(struct dgraph_node *n, struct run_info *run) ...@@ -150,7 +151,7 @@ static bool run_test(struct dgraph_node *n, struct run_info *run)
} }
timeleft = timeout ? timeout : default_timeout_ms; timeleft = timeout ? timeout : default_timeout_ms;
i->check(run->m, i->keep_results, &timeleft, score); i->check(run->m, &timeleft, score);
if (timeout && timeleft == 0) { if (timeout && timeleft == 0) {
i->skip = "timeout"; i->skip = "timeout";
if (verbose) if (verbose)
...@@ -343,22 +344,9 @@ static int show_tmpdir(const char *dir) ...@@ -343,22 +344,9 @@ static int show_tmpdir(const char *dir)
return 0; return 0;
} }
static bool keep_one_test(const char *member, struct ccanlint *c, void *unused) static char *keep_tests(void *unused)
{ {
c->keep_results = true; keep_results = true;
return true;
}
static char *keep_test(const char *testname, void *unused)
{
if (streq(testname, "all")) {
strmap_iterate(&tests, keep_one_test, NULL);
} else {
struct ccanlint *i = find_test(testname);
if (!i)
errx(1, "No test %s to --keep", testname);
keep_one_test(testname, i, NULL);
}
/* Don't automatically destroy temporary dir. */ /* Don't automatically destroy temporary dir. */
talloc_set_destructor(temp_dir(NULL), show_tmpdir); talloc_set_destructor(temp_dir(NULL), show_tmpdir);
...@@ -726,9 +714,8 @@ int main(int argc, char *argv[]) ...@@ -726,9 +714,8 @@ int main(int argc, char *argv[])
"list tests ccanlint performs (and exit)"); "list tests ccanlint performs (and exit)");
opt_register_noarg("--test-dep-graph", test_dependency_graph, NULL, opt_register_noarg("--test-dep-graph", test_dependency_graph, NULL,
"print dependency graph of tests in Graphviz .dot format"); "print dependency graph of tests in Graphviz .dot format");
opt_register_arg("-k|--keep <testname>", keep_test, NULL, NULL, opt_register_noarg("-k|--keep", keep_tests, NULL,
"keep results of <testname>" "do not delete ccanlint working files");
" (can be used multiple times, or 'all')");
opt_register_noarg("--summary|-s", opt_set_bool, &summary, opt_register_noarg("--summary|-s", opt_set_bool, &summary,
"simply give one line summary"); "simply give one line summary");
opt_register_arg("-x|--exclude <testname>", exclude_test, NULL, NULL, opt_register_arg("-x|--exclude <testname>", exclude_test, NULL, NULL,
......
...@@ -93,12 +93,11 @@ struct ccanlint { ...@@ -93,12 +93,11 @@ struct ccanlint {
/* Should we stop immediately if test fails? */ /* Should we stop immediately if test fails? */
bool compulsory; bool compulsory;
/* keep is set if you should keep the results. /* If timeleft is set to 0, means it timed out.
* If timeleft is set to 0, means it timed out.
* score is the result, and a talloc context freed after all our * score is the result, and a talloc context freed after all our
* depends are done. */ * depends are done. */
void (*check)(struct manifest *m, void (*check)(struct manifest *m,
bool keep, unsigned int *timeleft, struct score *score); unsigned int *timeleft, struct score *score);
/* Can we do something about it? (NULL if not) */ /* Can we do something about it? (NULL if not) */
void (*handle)(struct manifest *m, struct score *score); void (*handle)(struct manifest *m, struct score *score);
...@@ -116,8 +115,6 @@ struct ccanlint { ...@@ -116,8 +115,6 @@ struct ccanlint {
struct dgraph_node node; struct dgraph_node node;
/* Did we skip a dependency? If so, must skip this, too. */ /* Did we skip a dependency? If so, must skip this, too. */
const char *skip; const char *skip;
/* Did the user want to keep these results? */
bool keep_results;
/* Have we already run this? */ /* Have we already run this? */
bool done; bool done;
}; };
...@@ -267,6 +264,9 @@ void add_info_options(struct ccan_file *info); ...@@ -267,6 +264,9 @@ void add_info_options(struct ccan_file *info);
/* Are we happy to compile stuff, or just non-intrusive tests? */ /* Are we happy to compile stuff, or just non-intrusive tests? */
extern bool safe_mode; extern bool safe_mode;
/* Did the user want to keep all the results? */
extern bool keep_results;
/* Where is the ccan dir? Available after first manifest. */ /* Where is the ccan dir? Available after first manifest. */
extern const char *ccan_dir; extern const char *ccan_dir;
......
...@@ -36,7 +36,6 @@ static struct ccan_file *main_header(struct manifest *m) ...@@ -36,7 +36,6 @@ static struct ccan_file *main_header(struct manifest *m)
} }
static void check_headers_no_cpp(struct manifest *m, static void check_headers_no_cpp(struct manifest *m,
bool keep,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
char *contents; char *contents;
...@@ -44,8 +43,8 @@ static void check_headers_no_cpp(struct manifest *m, ...@@ -44,8 +43,8 @@ static void check_headers_no_cpp(struct manifest *m,
int fd; int fd;
struct ccan_file *mainh = main_header(m); struct ccan_file *mainh = main_header(m);
tmpsrc = maybe_temp_file(m, "-included.c", keep, mainh->fullname); tmpsrc = temp_file(m, "-included.c", mainh->fullname);
tmpobj = maybe_temp_file(m, ".o", keep, tmpsrc); tmpobj = temp_file(m, ".o", tmpsrc);
/* We don't fail you for this. */ /* We don't fail you for this. */
score->pass = true; score->pass = true;
......
#ifndef CCANLINT_BUILD_H #ifndef CCANLINT_BUILD_H
#define CCANLINT_BUILD_H #define CCANLINT_BUILD_H
char *build_module(struct manifest *m, bool keep, enum compile_type ctype, char *build_module(struct manifest *m, enum compile_type ctype, char **errstr);
char **errstr);
char *build_submodule(struct manifest *m, const char *flags, char *build_submodule(struct manifest *m, const char *flags,
enum compile_type ctype); enum compile_type ctype);
void build_objects(struct manifest *m, void build_objects(struct manifest *m,
bool keep, struct score *score, const char *flags, struct score *score, const char *flags,
enum compile_type ctype); enum compile_type ctype);
#endif /* CCANLINT_BUILD_H */ #endif /* CCANLINT_BUILD_H */
...@@ -32,7 +32,6 @@ static bool has_dep(struct manifest *m, const char *depname) ...@@ -32,7 +32,6 @@ static bool has_dep(struct manifest *m, const char *depname)
} }
static void check_depends_accurate(struct manifest *m, static void check_depends_accurate(struct manifest *m,
bool keep,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
struct list_head *list; struct list_head *list;
......
...@@ -38,7 +38,7 @@ static char *build_subdir_objs(struct manifest *m, ...@@ -38,7 +38,7 @@ static char *build_subdir_objs(struct manifest *m,
char *fullfile = talloc_asprintf(m, "%s/%s", m->dir, i->name); char *fullfile = talloc_asprintf(m, "%s/%s", m->dir, i->name);
char *output; char *output;
i->compiled[ctype] = maybe_temp_file(m, "", false, fullfile); i->compiled[ctype] = temp_file(m, "", fullfile);
if (!compile_object(m, fullfile, ccan_dir, compiler, flags, if (!compile_object(m, fullfile, ccan_dir, compiler, flags,
i->compiled[ctype], &output)) { i->compiled[ctype], &output)) {
talloc_free(i->compiled[ctype]); talloc_free(i->compiled[ctype]);
...@@ -70,14 +70,13 @@ char *build_submodule(struct manifest *m, const char *flags, ...@@ -70,14 +70,13 @@ char *build_submodule(struct manifest *m, const char *flags,
if (errstr) if (errstr)
return errstr; return errstr;
m->compiled[ctype] = build_module(m, false, ctype, &errstr); m->compiled[ctype] = build_module(m, ctype, &errstr);
if (!m->compiled[ctype]) if (!m->compiled[ctype])
return errstr; return errstr;
return NULL; return NULL;
} }
static void check_depends_built(struct manifest *m, static void check_depends_built(struct manifest *m,
bool keep,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
struct manifest *i; struct manifest *i;
......
...@@ -24,7 +24,6 @@ static const char *can_build(struct manifest *m) ...@@ -24,7 +24,6 @@ static const char *can_build(struct manifest *m)
} }
static void check_depends_built_without_features(struct manifest *m, static void check_depends_built_without_features(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
......
...@@ -35,7 +35,6 @@ static bool add_dep(struct manifest *m, const char *dep, struct score *score) ...@@ -35,7 +35,6 @@ static bool add_dep(struct manifest *m, const char *dep, struct score *score)
/* FIXME: check this is still true once we reduce features. */ /* FIXME: check this is still true once we reduce features. */
static void check_depends_exist(struct manifest *m, static void check_depends_exist(struct manifest *m,
bool keep,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
unsigned int i; unsigned int i;
......
...@@ -122,19 +122,16 @@ static char *lib_list(const struct manifest *m) ...@@ -122,19 +122,16 @@ static char *lib_list(const struct manifest *m)
static bool compile(const void *ctx, static bool compile(const void *ctx,
struct manifest *m, struct manifest *m,
struct ccan_file *file, struct ccan_file *file,
bool keep, char **output) char **output)
{ {
file->compiled[COMPILE_NORMAL] file->compiled[COMPILE_NORMAL] = temp_file(ctx, "", file->fullname);
= maybe_temp_file(ctx, "", keep, file->fullname);
if (!compile_and_link(ctx, file->fullname, ccan_dir, if (!compile_and_link(ctx, file->fullname, ccan_dir,
example_obj_list(m, file), example_obj_list(m, file),
compiler, cflags, compiler, cflags,
lib_list(m), file->compiled[COMPILE_NORMAL], lib_list(m), file->compiled[COMPILE_NORMAL],
output)) { output)) {
/* Don't keep failures. */ /* Don't keep failures, even with --keep */
if (keep) unlink(file->compiled[COMPILE_NORMAL]);
unlink(file->compiled[COMPILE_NORMAL]);
talloc_free(file->compiled[COMPILE_NORMAL]);
file->compiled[COMPILE_NORMAL] = NULL; file->compiled[COMPILE_NORMAL] = NULL;
return false; return false;
} }
...@@ -441,16 +438,15 @@ static char *mangle(struct manifest *m, char **lines) ...@@ -441,16 +438,15 @@ static char *mangle(struct manifest *m, char **lines)
static struct ccan_file *mangle_example(struct manifest *m, static struct ccan_file *mangle_example(struct manifest *m,
struct ccan_file *example, struct ccan_file *example,
char **lines, char **lines)
bool keep)
{ {
char *name, *contents; char *name, *contents;
int fd; int fd;
struct ccan_file *f; struct ccan_file *f;
name = maybe_temp_file(example, ".c", keep, name = temp_file(example, ".c",
talloc_asprintf(m, "%s/mangled-%s", talloc_asprintf(m, "%s/mangled-%s",
m->dir, example->name)); m->dir, example->name));
f = new_ccan_file(example, f = new_ccan_file(example,
talloc_dirname(example, name), talloc_dirname(example, name),
talloc_basename(example, name)); talloc_basename(example, name));
...@@ -491,7 +487,6 @@ static bool has_expected_output(char **lines) ...@@ -491,7 +487,6 @@ static bool has_expected_output(char **lines)
static unsigned int try_compiling(struct manifest *m, static unsigned int try_compiling(struct manifest *m,
struct ccan_file *i, struct ccan_file *i,
char **prev, char **prev,
bool keep,
struct ccan_file *mangled[3], struct ccan_file *mangled[3],
bool res[3], bool res[3],
char *err[3], char *err[3],
...@@ -501,7 +496,7 @@ static unsigned int try_compiling(struct manifest *m, ...@@ -501,7 +496,7 @@ static unsigned int try_compiling(struct manifest *m,
/* Try standalone. */ /* Try standalone. */
mangled[0] = i; mangled[0] = i;
res[0] = compile(i, m, mangled[0], keep, &err[0]); res[0] = compile(i, m, mangled[0], &err[0]);
lines[0] = get_ccan_file_lines(i); lines[0] = get_ccan_file_lines(i);
if (res[0] && streq(err[0], "")) if (res[0] && streq(err[0], ""))
return 1; return 1;
...@@ -509,8 +504,8 @@ static unsigned int try_compiling(struct manifest *m, ...@@ -509,8 +504,8 @@ static unsigned int try_compiling(struct manifest *m,
if (prev) { if (prev) {
lines[1] = combine(i, get_ccan_file_lines(i), prev); lines[1] = combine(i, get_ccan_file_lines(i), prev);
mangled[1] = mangle_example(m, i, lines[1], keep); mangled[1] = mangle_example(m, i, lines[1]);
res[1] = compile(i, m, mangled[1], keep, &err[1]); res[1] = compile(i, m, mangled[1], &err[1]);
if (res[1] && streq(err[1], "")) { if (res[1] && streq(err[1], "")) {
return 2; return 2;
} }
...@@ -520,13 +515,13 @@ static unsigned int try_compiling(struct manifest *m, ...@@ -520,13 +515,13 @@ static unsigned int try_compiling(struct manifest *m,
/* Try standalone. */ /* Try standalone. */
lines[num] = get_ccan_file_lines(i); lines[num] = get_ccan_file_lines(i);
mangled[num] = mangle_example(m, i, lines[num], keep); mangled[num] = mangle_example(m, i, lines[num]);
res[num] = compile(i, m, mangled[num], keep, &err[num]); res[num] = compile(i, m, mangled[num], &err[num]);
return num+1; return num+1;
} }
static void build_examples(struct manifest *m, bool keep, static void build_examples(struct manifest *m,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
struct ccan_file *i; struct ccan_file *i;
...@@ -549,7 +544,7 @@ static void build_examples(struct manifest *m, bool keep, ...@@ -549,7 +544,7 @@ static void build_examples(struct manifest *m, bool keep,
/* Simplify our dumb parsing. */ /* Simplify our dumb parsing. */
strip_leading_whitespace(get_ccan_file_lines(i)); strip_leading_whitespace(get_ccan_file_lines(i));
num = try_compiling(m, i, prev, keep, file, res, err, lines); num = try_compiling(m, i, prev, file, res, err, lines);
/* First look for a compile without any warnings. */ /* First look for a compile without any warnings. */
for (j = 0; j < num; j++) { for (j = 0; j < num; j++) {
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
/* Creates and adds an example file. */ /* Creates and adds an example file. */
static char *add_example(struct manifest *m, struct ccan_file *source, static char *add_example(struct manifest *m, struct ccan_file *source,
bool keep,
struct doc_section *example) struct doc_section *example)
{ {
char *name; char *name;
...@@ -34,7 +33,7 @@ static char *add_example(struct manifest *m, struct ccan_file *source, ...@@ -34,7 +33,7 @@ static char *add_example(struct manifest *m, struct ccan_file *source,
while (strchr(name, ' ')) while (strchr(name, ' '))
*strchr(name, ' ') = '_'; *strchr(name, ' ') = '_';
name = maybe_temp_file(m, ".c", keep, name); name = temp_file(m, ".c", name);
f = new_ccan_file(m, talloc_dirname(m, name), talloc_basename(m, name)); f = new_ccan_file(m, talloc_dirname(m, name), talloc_basename(m, name));
talloc_steal(f, name); talloc_steal(f, name);
list_add_tail(&m->examples, &f->list); list_add_tail(&m->examples, &f->list);
...@@ -59,7 +58,6 @@ static char *add_example(struct manifest *m, struct ccan_file *source, ...@@ -59,7 +58,6 @@ static char *add_example(struct manifest *m, struct ccan_file *source,
/* FIXME: We should have one example per function in header. */ /* FIXME: We should have one example per function in header. */
static void extract_examples(struct manifest *m, static void extract_examples(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
...@@ -70,7 +68,7 @@ static void extract_examples(struct manifest *m, ...@@ -70,7 +68,7 @@ static void extract_examples(struct manifest *m,
score->total = 2; score->total = 2;
list_for_each(get_ccan_file_docs(m->info_file), d, list) { list_for_each(get_ccan_file_docs(m->info_file), d, list) {
if (streq(d->type, "example")) { if (streq(d->type, "example")) {
score->error = add_example(m, m->info_file, keep, d); score->error = add_example(m, m->info_file, d);
if (score->error) if (score->error)
return; return;
have_info_example = true; have_info_example = true;
...@@ -86,7 +84,7 @@ static void extract_examples(struct manifest *m, ...@@ -86,7 +84,7 @@ static void extract_examples(struct manifest *m,
mainh = f; mainh = f;
list_for_each(get_ccan_file_docs(f), d, list) { list_for_each(get_ccan_file_docs(f), d, list) {
if (streq(d->type, "example")) { if (streq(d->type, "example")) {
score->error = add_example(m, f, keep, d); score->error = add_example(m, f, d);
if (score->error) if (score->error)
return; return;
have_header_example = true; have_header_example = true;
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <ctype.h> #include <ctype.h>
static void examples_relevant_check(struct manifest *m, static void examples_relevant_check(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
......
...@@ -225,7 +225,7 @@ static char *unexpected(struct ccan_file *i, const char *input, ...@@ -225,7 +225,7 @@ static char *unexpected(struct ccan_file *i, const char *input,
return output; return output;
} }
static void run_examples(struct manifest *m, bool keep, static void run_examples(struct manifest *m,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
struct ccan_file *i; struct ccan_file *i;
......
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
#include <ctype.h> #include <ctype.h>
static void check_hash_if(struct manifest *m, static void check_hash_if(struct manifest *m,
bool keep, unsigned int *timeleft, struct score *score)
unsigned int *timeleft, struct score *score)
{ {
struct list_head *list; struct list_head *list;
const char *explanation = const char *explanation =
......
...@@ -58,7 +58,7 @@ static void handle_idem(struct manifest *m, struct score *score) ...@@ -58,7 +58,7 @@ static void handle_idem(struct manifest *m, struct score *score)
if (!ask(q)) if (!ask(q))
continue; continue;
tmpname = maybe_temp_file(score, ".h", false, e->file->name); tmpname = temp_file(score, ".h", e->file->name);
out = fopen(tmpname, "w"); out = fopen(tmpname, "w");
if (!out) if (!out)
err(1, "Opening %s", tmpname); err(1, "Opening %s", tmpname);
...@@ -174,7 +174,6 @@ static void check_idem(struct ccan_file *f, struct score *score) ...@@ -174,7 +174,6 @@ static void check_idem(struct ccan_file *f, struct score *score)
} }
static void check_idempotent(struct manifest *m, static void check_idempotent(struct manifest *m,
bool keep,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
struct ccan_file *f; struct ccan_file *f;
......
...@@ -59,9 +59,8 @@ static void create_info_template_doc(struct manifest *m, struct score *score) ...@@ -59,9 +59,8 @@ static void create_info_template_doc(struct manifest *m, struct score *score)
} }
static void check_info_documentation_exists(struct manifest *m, static void check_info_documentation_exists(struct manifest *m,
bool keep, unsigned int *timeleft,
unsigned int *timeleft, struct score *score)
struct score *score)
{ {
struct list_head *infodocs = get_ccan_file_docs(m->info_file); struct list_head *infodocs = get_ccan_file_docs(m->info_file);
struct doc_section *d; struct doc_section *d;
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <ccan/talloc/talloc.h> #include <ccan/talloc/talloc.h>
static void check_has_info(struct manifest *m, static void check_has_info(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include <ccan/str/str.h> #include <ccan/str/str.h>
static void check_info_summary_single_line(struct manifest *m, static void check_info_summary_single_line(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <ccan/str_talloc/str_talloc.h> #include <ccan/str_talloc/str_talloc.h>
static void check_license_comment(struct manifest *m, static void check_license_comment(struct manifest *m,
bool keep,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
struct list_head *list; struct list_head *list;
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <ccan/str_talloc/str_talloc.h> #include <ccan/str_talloc/str_talloc.h>
static void check_license_depends_compat(struct manifest *m, static void check_license_depends_compat(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
......
...@@ -63,7 +63,6 @@ static void handle_license_link(struct manifest *m, struct score *score) ...@@ -63,7 +63,6 @@ static void handle_license_link(struct manifest *m, struct score *score)
extern struct ccanlint license_exists; extern struct ccanlint license_exists;
static void check_has_license(struct manifest *m, static void check_has_license(struct manifest *m,
bool keep,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
char buf[PATH_MAX]; char buf[PATH_MAX];
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <ccan/str_talloc/str_talloc.h> #include <ccan/str_talloc/str_talloc.h>
static void check_license_file_compat(struct manifest *m, static void check_license_file_compat(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
......
...@@ -36,7 +36,6 @@ static struct ccan_file *main_header(struct manifest *m) ...@@ -36,7 +36,6 @@ static struct ccan_file *main_header(struct manifest *m)
} }
static void check_includes_build(struct manifest *m, static void check_includes_build(struct manifest *m,
bool keep,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
char *contents; char *contents;
...@@ -44,8 +43,8 @@ static void check_includes_build(struct manifest *m, ...@@ -44,8 +43,8 @@ static void check_includes_build(struct manifest *m,
int fd; int fd;
struct ccan_file *mainh = main_header(m); struct ccan_file *mainh = main_header(m);
tmpsrc = maybe_temp_file(m, "-included.c", keep, mainh->fullname); tmpsrc = temp_file(m, "-included.c", mainh->fullname);
tmpobj = maybe_temp_file(m, ".o", keep, tmpsrc); tmpobj = temp_file(m, ".o", tmpsrc);
fd = open(tmpsrc, O_WRONLY | O_CREAT | O_EXCL, 0600); fd = open(tmpsrc, O_WRONLY | O_CREAT | O_EXCL, 0600);
if (fd < 0) if (fd < 0)
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <ccan/noerr/noerr.h> #include <ccan/noerr/noerr.h>
static void check_has_main_header(struct manifest *m, static void check_has_main_header(struct manifest *m,
bool keep,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
struct ccan_file *f; struct ccan_file *f;
......
...@@ -35,26 +35,13 @@ static char *obj_list(const struct manifest *m, enum compile_type ctype) ...@@ -35,26 +35,13 @@ static char *obj_list(const struct manifest *m, enum compile_type ctype)
return list; return list;
} }
char *build_module(struct manifest *m, bool keep, char *build_module(struct manifest *m,
enum compile_type ctype, char **errstr) enum compile_type ctype, char **errstr)
{ {
char *name = link_objects(m, m->basename, false, obj_list(m, ctype), return link_objects(m, m->basename, obj_list(m, ctype), errstr);
errstr);
if (name) {
if (keep) {
char *realname = talloc_asprintf(m, "%s.o", m->dir);
assert(ctype == COMPILE_NORMAL);
/* We leave this object file around, all built. */
if (!move_file(name, realname))
err(1, "Renaming %s to %s", name, realname);
name = realname;
}
}
return name;
} }
static void do_build(struct manifest *m, static void do_build(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
...@@ -68,7 +55,7 @@ static void do_build(struct manifest *m, ...@@ -68,7 +55,7 @@ static void do_build(struct manifest *m,
} }
m->compiled[COMPILE_NORMAL] m->compiled[COMPILE_NORMAL]
= build_module(m, keep, COMPILE_NORMAL, &errstr); = build_module(m, COMPILE_NORMAL, &errstr);
if (!m->compiled[COMPILE_NORMAL]) { if (!m->compiled[COMPILE_NORMAL]) {
score_file_error(score, NULL, 0, "%s", errstr); score_file_error(score, NULL, 0, "%s", errstr);
return; return;
......
...@@ -49,7 +49,6 @@ static char *lib_list(const struct manifest *m) ...@@ -49,7 +49,6 @@ static char *lib_list(const struct manifest *m)
} }
static void check_use_build(struct manifest *m, static void check_use_build(struct manifest *m,
bool keep,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
char *contents; char *contents;
...@@ -57,7 +56,7 @@ static void check_use_build(struct manifest *m, ...@@ -57,7 +56,7 @@ static void check_use_build(struct manifest *m,
char *basename = talloc_asprintf(m, "%s/example.c", m->dir); char *basename = talloc_asprintf(m, "%s/example.c", m->dir);
int fd; int fd;
tmpfile = maybe_temp_file(m, ".c", keep, basename); tmpfile = temp_file(m, ".c", basename);
fd = open(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0600); fd = open(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0600);
if (fd < 0) if (fd < 0)
...@@ -76,7 +75,7 @@ static void check_use_build(struct manifest *m, ...@@ -76,7 +75,7 @@ static void check_use_build(struct manifest *m,
if (compile_and_link(score, tmpfile, ccan_dir, obj_list(m), if (compile_and_link(score, tmpfile, ccan_dir, obj_list(m),
compiler, cflags, lib_list(m), compiler, cflags, lib_list(m),
maybe_temp_file(m, "", keep, tmpfile), temp_file(m, "", tmpfile),
&cmdout)) { &cmdout)) {
score->pass = true; score->pass = true;
score->score = score->total; score->score = score->total;
......
...@@ -22,7 +22,6 @@ static char *get_trailing_whitespace(const char *line) ...@@ -22,7 +22,6 @@ static char *get_trailing_whitespace(const char *line)
} }
static void check_trailing_whitespace(struct manifest *m, static void check_trailing_whitespace(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
......
...@@ -23,7 +23,7 @@ static const char *can_build(struct manifest *m) ...@@ -23,7 +23,7 @@ static const char *can_build(struct manifest *m)
} }
void build_objects(struct manifest *m, void build_objects(struct manifest *m,
bool keep, struct score *score, const char *flags, struct score *score, const char *flags,
enum compile_type ctype) enum compile_type ctype)
{ {
struct ccan_file *i; struct ccan_file *i;
...@@ -38,7 +38,7 @@ void build_objects(struct manifest *m, ...@@ -38,7 +38,7 @@ void build_objects(struct manifest *m,
char *output; char *output;
char *fullfile = talloc_asprintf(m, "%s/%s", m->dir, i->name); char *fullfile = talloc_asprintf(m, "%s/%s", m->dir, i->name);
i->compiled[ctype] = maybe_temp_file(m, "", keep, fullfile); i->compiled[ctype] = temp_file(m, "", fullfile);
if (!compile_object(score, fullfile, ccan_dir, compiler, flags, if (!compile_object(score, fullfile, ccan_dir, compiler, flags,
i->compiled[ctype], &output)) { i->compiled[ctype], &output)) {
talloc_free(i->compiled[ctype]); talloc_free(i->compiled[ctype]);
...@@ -62,10 +62,9 @@ void build_objects(struct manifest *m, ...@@ -62,10 +62,9 @@ void build_objects(struct manifest *m,
} }
static void check_objs_build(struct manifest *m, static void check_objs_build(struct manifest *m,
bool keep,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
build_objects(m, keep, score, cflags, COMPILE_NORMAL); build_objects(m, score, cflags, COMPILE_NORMAL);
} }
struct ccanlint objects_build = { struct ccanlint objects_build = {
......
...@@ -58,14 +58,13 @@ static int start_file(const char *filename) ...@@ -58,14 +58,13 @@ static int start_file(const char *filename)
static void test_compile(struct score *score, static void test_compile(struct score *score,
struct ccan_file *file, struct ccan_file *file,
const char *filename, const char *filename,
bool keep,
const char *flags, const char *flags,
bool *errors, bool *errors,
bool *warnings) bool *warnings)
{ {
char *output, *compiled; char *output, *compiled;
compiled = maybe_temp_file(score, "", keep, filename); compiled = temp_file(score, "", filename);
if (!compile_object(score, filename, ccan_dir, compiler, flags, if (!compile_object(score, filename, ccan_dir, compiler, flags,
compiled, &output)) { compiled, &output)) {
score_file_error(score, file, 0, score_file_error(score, file, 0,
...@@ -95,7 +94,7 @@ static struct ccan_file *get_main_header(struct manifest *m) ...@@ -95,7 +94,7 @@ static struct ccan_file *get_main_header(struct manifest *m)
} }
static void build_objects_with_stringchecks(struct manifest *m, static void build_objects_with_stringchecks(struct manifest *m,
bool keep, unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
struct ccan_file *i; struct ccan_file *i;
...@@ -110,21 +109,20 @@ static void build_objects_with_stringchecks(struct manifest *m, ...@@ -110,21 +109,20 @@ static void build_objects_with_stringchecks(struct manifest *m,
if (list_empty(&m->c_files)) { if (list_empty(&m->c_files)) {
char *line; char *line;
i = get_main_header(m); i = get_main_header(m);
tmp = maybe_temp_file(score, ".c", keep, i->fullname); tmp = temp_file(score, ".c", i->fullname);
tmpfd = start_file(tmp); tmpfd = start_file(tmp);
line = talloc_asprintf(score, "#include <ccan/%s/%s.h>\n", line = talloc_asprintf(score, "#include <ccan/%s/%s.h>\n",
m->basename, m->basename); m->basename, m->basename);
write_str(tmpfd, line); write_str(tmpfd, line);
close(tmpfd); close(tmpfd);
test_compile(score, i, tmp, keep, flags, &errors, &warnings); test_compile(score, i, tmp, flags, &errors, &warnings);
} else { } else {
list_for_each(&m->c_files, i, list) { list_for_each(&m->c_files, i, list) {
tmp = maybe_temp_file(score, ".c", keep, i->fullname); tmp = temp_file(score, ".c", i->fullname);
tmpfd = start_file(tmp); tmpfd = start_file(tmp);
write_str(tmpfd, get_ccan_file_contents(i)); write_str(tmpfd, get_ccan_file_contents(i));
close(tmpfd); close(tmpfd);
test_compile(score, i, tmp, keep, flags, test_compile(score, i, tmp, flags, &errors, &warnings);
&errors, &warnings);
} }
} }
......
...@@ -4,13 +4,12 @@ ...@@ -4,13 +4,12 @@
#include "build.h" #include "build.h"
static void check_objs_build_without_features(struct manifest *m, static void check_objs_build_without_features(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
const char *flags = talloc_asprintf(score, "%s %s", const char *flags = talloc_asprintf(score, "%s %s",
REDUCE_FEATURES_FLAGS, cflags); REDUCE_FEATURES_FLAGS, cflags);
build_objects(m, keep, score, flags, COMPILE_NOFEAT); build_objects(m, score, flags, COMPILE_NOFEAT);
} }
struct ccanlint objects_build_without_features = { struct ccanlint objects_build_without_features = {
......
...@@ -129,7 +129,6 @@ static struct htable_option *get_config_options(struct manifest *m) ...@@ -129,7 +129,6 @@ static struct htable_option *get_config_options(struct manifest *m)
} }
static void do_reduce_features(struct manifest *m, static void do_reduce_features(struct manifest *m,
bool keep,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
struct htable_option *options_used, *options_avail, *options; struct htable_option *options_used, *options_avail, *options;
......
...@@ -69,7 +69,6 @@ static bool compile(const void *ctx, ...@@ -69,7 +69,6 @@ static bool compile(const void *ctx,
struct ccan_file *file, struct ccan_file *file,
bool fail, bool fail,
bool link_with_module, bool link_with_module,
bool keep,
enum compile_type ctype, enum compile_type ctype,
char **output) char **output)
{ {
...@@ -81,7 +80,7 @@ static bool compile(const void *ctx, ...@@ -81,7 +80,7 @@ static bool compile(const void *ctx,
ctype == COMPILE_NOFEAT ctype == COMPILE_NOFEAT
? " "REDUCE_FEATURES_FLAGS : ""); ? " "REDUCE_FEATURES_FLAGS : "");
fname = maybe_temp_file(ctx, "", keep, file->fullname); fname = temp_file(ctx, "", file->fullname);
if (!compile_and_link(ctx, file->fullname, ccan_dir, if (!compile_and_link(ctx, file->fullname, ccan_dir,
test_obj_list(m, link_with_module, test_obj_list(m, link_with_module,
ctype, ctype), ctype, ctype),
...@@ -99,13 +98,12 @@ static void compile_async(const void *ctx, ...@@ -99,13 +98,12 @@ static void compile_async(const void *ctx,
struct manifest *m, struct manifest *m,
struct ccan_file *file, struct ccan_file *file,
bool link_with_module, bool link_with_module,
bool keep,
enum compile_type ctype, enum compile_type ctype,
unsigned int time_ms) unsigned int time_ms)
{ {
char *flags; char *flags;
file->compiled[ctype] = maybe_temp_file(ctx, "", keep, file->fullname); file->compiled[ctype] = temp_file(ctx, "", file->fullname);
flags = talloc_asprintf(ctx, "%s%s", flags = talloc_asprintf(ctx, "%s%s",
cflags, cflags,
ctype == COMPILE_NOFEAT ctype == COMPILE_NOFEAT
...@@ -117,7 +115,7 @@ static void compile_async(const void *ctx, ...@@ -117,7 +115,7 @@ static void compile_async(const void *ctx,
file->compiled[ctype]); file->compiled[ctype]);
} }
static void compile_tests(struct manifest *m, bool keep, static void compile_tests(struct manifest *m,
struct score *score, struct score *score,
enum compile_type ctype, enum compile_type ctype,
unsigned int time_ms) unsigned int time_ms)
...@@ -130,7 +128,7 @@ static void compile_tests(struct manifest *m, bool keep, ...@@ -130,7 +128,7 @@ static void compile_tests(struct manifest *m, bool keep,
foreach_ptr(list, &m->compile_ok_tests, &m->run_tests, &m->api_tests) { foreach_ptr(list, &m->compile_ok_tests, &m->run_tests, &m->api_tests) {
list_for_each(list, i, list) { list_for_each(list, i, list) {
compile_async(score, m, i, compile_async(score, m, i,
list == &m->api_tests, keep, list == &m->api_tests,
ctype, time_ms); ctype, time_ms);
} }
} }
...@@ -155,8 +153,7 @@ static void compile_tests(struct manifest *m, bool keep, ...@@ -155,8 +153,7 @@ static void compile_tests(struct manifest *m, bool keep,
/* For historical reasons, "fail" often means "gives warnings" */ /* For historical reasons, "fail" often means "gives warnings" */
list_for_each(&m->compile_fail_tests, i, list) { list_for_each(&m->compile_fail_tests, i, list) {
if (!compile(score, m, i, false, false, false, if (!compile(score, m, i, false, false, ctype, &cmdout)) {
ctype, &cmdout)) {
score_file_error(score, i, 0, score_file_error(score, i, 0,
"Compile without -DFAIL failed:\n%s", "Compile without -DFAIL failed:\n%s",
cmdout); cmdout);
...@@ -169,8 +166,7 @@ static void compile_tests(struct manifest *m, bool keep, ...@@ -169,8 +166,7 @@ static void compile_tests(struct manifest *m, bool keep,
cmdout); cmdout);
return; return;
} }
if (compile(score, m, i, true, false, false, if (compile(score, m, i, true, false, ctype, &cmdout)
ctype, &cmdout)
&& streq(cmdout, "")) { && streq(cmdout, "")) {
score_file_error(score, i, 0, score_file_error(score, i, 0,
"Compiled successfully with -DFAIL?"); "Compiled successfully with -DFAIL?");
...@@ -185,10 +181,9 @@ static void compile_tests(struct manifest *m, bool keep, ...@@ -185,10 +181,9 @@ static void compile_tests(struct manifest *m, bool keep,
/* FIXME: If we time out, set *timeleft to 0 */ /* FIXME: If we time out, set *timeleft to 0 */
static void do_compile_tests(struct manifest *m, static void do_compile_tests(struct manifest *m,
bool keep,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
compile_tests(m, keep, score, COMPILE_NORMAL, *timeleft); compile_tests(m, score, COMPILE_NORMAL, *timeleft);
} }
struct ccanlint tests_compile = { struct ccanlint tests_compile = {
...@@ -209,11 +204,10 @@ static const char *features_reduced(struct manifest *m) ...@@ -209,11 +204,10 @@ static const char *features_reduced(struct manifest *m)
} }
static void do_compile_tests_without_features(struct manifest *m, static void do_compile_tests_without_features(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
compile_tests(m, keep, score, COMPILE_NOFEAT, *timeleft); compile_tests(m, score, COMPILE_NOFEAT, *timeleft);
} }
struct ccanlint tests_compile_without_features = { struct ccanlint tests_compile_without_features = {
......
...@@ -32,13 +32,11 @@ static void cov_compile(const void *ctx, ...@@ -32,13 +32,11 @@ static void cov_compile(const void *ctx,
unsigned int time_ms, unsigned int time_ms,
struct manifest *m, struct manifest *m,
struct ccan_file *file, struct ccan_file *file,
bool link_with_module, bool link_with_module)
bool keep)
{ {
char *flags = talloc_asprintf(ctx, "%s %s", cflags, COVERAGE_CFLAGS); char *flags = talloc_asprintf(ctx, "%s %s", cflags, COVERAGE_CFLAGS);
file->compiled[COMPILE_COVERAGE] file->compiled[COMPILE_COVERAGE] = temp_file(ctx, "", file->fullname);
= maybe_temp_file(ctx, "", keep, file->fullname);
compile_and_link_async(file, time_ms, file->fullname, ccan_dir, compile_and_link_async(file, time_ms, file->fullname, ccan_dir,
test_obj_list(m, link_with_module, test_obj_list(m, link_with_module,
COMPILE_NORMAL, COMPILE_NORMAL,
...@@ -50,7 +48,6 @@ static void cov_compile(const void *ctx, ...@@ -50,7 +48,6 @@ static void cov_compile(const void *ctx,
/* FIXME: Coverage from testable examples as well. */ /* FIXME: Coverage from testable examples as well. */
static void do_compile_coverage_tests(struct manifest *m, static void do_compile_coverage_tests(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
...@@ -62,7 +59,7 @@ static void do_compile_coverage_tests(struct manifest *m, ...@@ -62,7 +59,7 @@ static void do_compile_coverage_tests(struct manifest *m,
/* For API tests, we need coverage version of module. */ /* For API tests, we need coverage version of module. */
if (!list_empty(&m->api_tests)) { if (!list_empty(&m->api_tests)) {
build_objects(m, keep, score, f, COMPILE_COVERAGE); build_objects(m, score, f, COMPILE_COVERAGE);
if (!score->pass) { if (!score->pass) {
score->error = talloc_strdup(score, score->error = talloc_strdup(score,
"Failed to compile module objects with coverage"); "Failed to compile module objects with coverage");
...@@ -72,8 +69,7 @@ static void do_compile_coverage_tests(struct manifest *m, ...@@ -72,8 +69,7 @@ static void do_compile_coverage_tests(struct manifest *m,
foreach_ptr(h, &m->run_tests, &m->api_tests) { foreach_ptr(h, &m->run_tests, &m->api_tests) {
list_for_each(h, i, list) { list_for_each(h, i, list) {
cov_compile(m, *timeleft, m, i, h == &m->api_tests, cov_compile(m, *timeleft, m, i, h == &m->api_tests);
keep);
} }
} }
......
...@@ -127,7 +127,6 @@ static void analyze_coverage(struct manifest *m, bool full_gcov, ...@@ -127,7 +127,6 @@ static void analyze_coverage(struct manifest *m, bool full_gcov,
} }
static void do_run_coverage_tests(struct manifest *m, static void do_run_coverage_tests(struct manifest *m,
bool keep,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
struct ccan_file *i; struct ccan_file *i;
...@@ -144,16 +143,6 @@ static void do_run_coverage_tests(struct manifest *m, ...@@ -144,16 +143,6 @@ static void do_run_coverage_tests(struct manifest *m,
full_gcov ? "" : "-n", full_gcov ? "" : "-n",
outdir); outdir);
/* Unlink these files afterwards. */
if (!keep) {
talloc_set_destructor(talloc_asprintf(score,
"%s/run.gcno", outdir),
unlink_file_destructor);
talloc_set_destructor(talloc_asprintf(score,
"%s/run.gcda", outdir),
unlink_file_destructor);
}
/* Run them all. */ /* Run them all. */
foreach_ptr(list, &m->run_tests, &m->api_tests) { foreach_ptr(list, &m->run_tests, &m->api_tests) {
list_for_each(list, i, list) { list_for_each(list, i, list) {
......
...@@ -94,7 +94,6 @@ static void handle_no_tests(struct manifest *m, struct score *score) ...@@ -94,7 +94,6 @@ static void handle_no_tests(struct manifest *m, struct score *score)
} }
static void check_tests_exist(struct manifest *m, static void check_tests_exist(struct manifest *m,
bool keep,
unsigned int *timeleft, struct score *score) unsigned int *timeleft, struct score *score)
{ {
struct stat st; struct stat st;
......
...@@ -23,19 +23,17 @@ static const char *can_run(struct manifest *m) ...@@ -23,19 +23,17 @@ static const char *can_run(struct manifest *m)
} }
static bool compile(struct manifest *m, static bool compile(struct manifest *m,
bool keep,
struct ccan_file *cfile, struct ccan_file *cfile,
const char *flags, const char *flags,
enum compile_type ctype, enum compile_type ctype,
char **output) char **output)
{ {
cfile->compiled[ctype] = maybe_temp_file(m, ".o", keep, cfile->fullname); cfile->compiled[ctype] = temp_file(m, ".o", cfile->fullname);
return compile_object(m, cfile->fullname, ccan_dir, compiler, flags, return compile_object(m, cfile->fullname, ccan_dir, compiler, flags,
cfile->compiled[ctype], output); cfile->compiled[ctype], output);
} }
static void compile_test_helpers(struct manifest *m, static void compile_test_helpers(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score, struct score *score,
const char *flags, const char *flags,
...@@ -52,7 +50,7 @@ static void compile_test_helpers(struct manifest *m, ...@@ -52,7 +50,7 @@ static void compile_test_helpers(struct manifest *m,
list_for_each(&m->other_test_c_files, i, list) { list_for_each(&m->other_test_c_files, i, list) {
char *cmdout; char *cmdout;
if (!compile(m, keep, i, flags, ctype, &cmdout)) { if (!compile(m, i, flags, ctype, &cmdout)) {
errors = true; errors = true;
score_file_error(score, i, 0, "Compile failed:\n%s", score_file_error(score, i, 0, "Compile failed:\n%s",
cmdout); cmdout);
...@@ -70,12 +68,10 @@ static void compile_test_helpers(struct manifest *m, ...@@ -70,12 +68,10 @@ static void compile_test_helpers(struct manifest *m,
} }
static void do_compile_test_helpers(struct manifest *m, static void do_compile_test_helpers(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
compile_test_helpers(m, keep, timeleft, score, cflags, compile_test_helpers(m, timeleft, score, cflags, COMPILE_NORMAL);
COMPILE_NORMAL);
} }
struct ccanlint tests_helpers_compile = { struct ccanlint tests_helpers_compile = {
...@@ -96,7 +92,6 @@ static const char *features_reduced(struct manifest *m) ...@@ -96,7 +92,6 @@ static const char *features_reduced(struct manifest *m)
} }
static void do_compile_test_helpers_without_features(struct manifest *m, static void do_compile_test_helpers_without_features(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
...@@ -105,8 +100,7 @@ static void do_compile_test_helpers_without_features(struct manifest *m, ...@@ -105,8 +100,7 @@ static void do_compile_test_helpers_without_features(struct manifest *m,
flags = talloc_asprintf(score, "%s %s", cflags, flags = talloc_asprintf(score, "%s %s", cflags,
REDUCE_FEATURES_FLAGS); REDUCE_FEATURES_FLAGS);
compile_test_helpers(m, keep, timeleft, score, flags, compile_test_helpers(m, timeleft, score, flags, COMPILE_NOFEAT);
COMPILE_NOFEAT);
} }
struct ccanlint tests_helpers_compile_without_features = { struct ccanlint tests_helpers_compile_without_features = {
......
...@@ -63,8 +63,6 @@ static void run_test(void *ctx, ...@@ -63,8 +63,6 @@ static void run_test(void *ctx,
i->valgrind_log = talloc_asprintf(m, i->valgrind_log = talloc_asprintf(m,
"%s.valgrind-log", "%s.valgrind-log",
i->compiled[COMPILE_NORMAL]); i->compiled[COMPILE_NORMAL]);
talloc_set_destructor(i->valgrind_log,
unlink_file_destructor);
run_command_async(i, *timeleft, run_command_async(i, *timeleft,
"valgrind -q" "valgrind -q"
...@@ -83,7 +81,6 @@ static void run_test(void *ctx, ...@@ -83,7 +81,6 @@ static void run_test(void *ctx,
} }
static void do_run_tests(struct manifest *m, static void do_run_tests(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
......
...@@ -146,7 +146,6 @@ static const char *concat(struct score *score, char *bits[]) ...@@ -146,7 +146,6 @@ static const char *concat(struct score *score, char *bits[])
/* FIXME: Run examples, too! */ /* FIXME: Run examples, too! */
static void do_run_tests_vg(struct manifest *m, static void do_run_tests_vg(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
...@@ -170,9 +169,6 @@ static void do_run_tests_vg(struct manifest *m, ...@@ -170,9 +169,6 @@ static void do_run_tests_vg(struct manifest *m,
continue; continue;
} }
if (keep)
talloc_set_destructor(i->valgrind_log, NULL);
output = grab_file(i, i->valgrind_log, NULL); output = grab_file(i, i->valgrind_log, NULL);
/* No valgrind errors? */ /* No valgrind errors? */
if (!output || output[0] == '\0') { if (!output || output[0] == '\0') {
...@@ -191,7 +187,6 @@ static void do_run_tests_vg(struct manifest *m, ...@@ -191,7 +187,6 @@ static void do_run_tests_vg(struct manifest *m,
} }
static void do_leakcheck_vg(struct manifest *m, static void do_leakcheck_vg(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
/* We don't do these under valgrind: too slow! */ /* We don't do these under valgrind: too slow! */
static void do_run_tests_no_features(struct manifest *m, static void do_run_tests_no_features(struct manifest *m,
bool keep,
unsigned int *timeleft, unsigned int *timeleft,
struct score *score) struct score *score)
{ {
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
bool compile_verbose = false; bool compile_verbose = false;
/* Compile multiple object files into a single. Returns NULL if fails. */ /* Compile multiple object files into a single. Returns NULL if fails. */
char *link_objects(const void *ctx, const char *basename, bool in_pwd, char *link_objects(const void *ctx, const char *basename,
const char *objs, char **errmsg) const char *objs, char **errmsg)
{ {
char *file = maybe_temp_file(ctx, ".o", in_pwd, basename); char *file = temp_file(ctx, ".o", basename);
if (compile_verbose) if (compile_verbose)
printf("Linking objects into %s\n", file); printf("Linking objects into %s\n", file);
......
...@@ -48,7 +48,7 @@ static char *compile_info(const void *ctx, const char *dir) ...@@ -48,7 +48,7 @@ static char *compile_info(const void *ctx, const char *dir)
if (!info) if (!info)
return NULL; return NULL;
info_c_file = maybe_temp_file(ctx, ".c", false, "_info"); info_c_file = temp_file(ctx, ".c", "_info");
fd = open(info_c_file, O_WRONLY|O_CREAT|O_EXCL, 0600); fd = open(info_c_file, O_WRONLY|O_CREAT|O_EXCL, 0600);
if (fd < 0) if (fd < 0)
return NULL; return NULL;
...@@ -62,7 +62,7 @@ static char *compile_info(const void *ctx, const char *dir) ...@@ -62,7 +62,7 @@ static char *compile_info(const void *ctx, const char *dir)
if (strrchr(ccandir, '/')) if (strrchr(ccandir, '/'))
*strrchr(ccandir, '/') = '\0'; *strrchr(ccandir, '/') = '\0';
compiled = maybe_temp_file(ctx, "", false, "info"); compiled = temp_file(ctx, "", "info");
if (compile_and_link(ctx, info_c_file, ccandir, "", if (compile_and_link(ctx, info_c_file, ccandir, "",
CCAN_COMPILER, CCAN_CFLAGS " -I.", "", CCAN_COMPILER, CCAN_CFLAGS " -I.", "",
compiled, &output)) compiled, &output))
......
...@@ -213,8 +213,7 @@ int unlink_file_destructor(char *filename) ...@@ -213,8 +213,7 @@ int unlink_file_destructor(char *filename)
return 0; return 0;
} }
char *maybe_temp_file(const void *ctx, const char *extension, bool keep, char *temp_file(const void *ctx, const char *extension, const char *srcname)
const char *srcname)
{ {
unsigned baselen; unsigned baselen;
char *f, *suffix = talloc_strdup(ctx, ""); char *f, *suffix = talloc_strdup(ctx, "");
...@@ -237,10 +236,7 @@ char *maybe_temp_file(const void *ctx, const char *extension, bool keep, ...@@ -237,10 +236,7 @@ char *maybe_temp_file(const void *ctx, const char *extension, bool keep,
} while (lstat(f, &st) == 0); } while (lstat(f, &st) == 0);
if (tools_verbose) if (tools_verbose)
printf("Creating %sfile %s\n", keep ? "" : "temporary ", f); printf("Creating file %s\n", f);
if (!keep)
talloc_set_destructor(f, unlink_file_destructor);
talloc_free(suffix); talloc_free(suffix);
return f; return f;
......
...@@ -53,7 +53,7 @@ bool move_file(const char *oldname, const char *newname); ...@@ -53,7 +53,7 @@ bool move_file(const char *oldname, const char *newname);
/* If set, say what we're compiling to. */ /* If set, say what we're compiling to. */
extern bool compile_verbose; extern bool compile_verbose;
/* Compile multiple object files into a single. */ /* Compile multiple object files into a single. */
char *link_objects(const void *ctx, const char *basename, bool in_pwd, char *link_objects(const void *ctx, const char *basename,
const char *objs, char **errmsg); const char *objs, char **errmsg);
/* Compile a single C file to an object file. Returns false if fails. */ /* Compile a single C file to an object file. Returns false if fails. */
bool compile_object(const void *ctx, const char *cfile, const char *ccandir, bool compile_object(const void *ctx, const char *cfile, const char *ccandir,
...@@ -66,9 +66,8 @@ bool compile_and_link(const void *ctx, const char *cfile, const char *ccandir, ...@@ -66,9 +66,8 @@ bool compile_and_link(const void *ctx, const char *cfile, const char *ccandir,
const char *compiler, const char *cflags, const char *compiler, const char *cflags,
const char *libs, const char *outfile, char **output); const char *libs, const char *outfile, char **output);
/* If in_pwd is false, return a file int temp_dir, otherwise a local file. */ /* Returns a file in temp_dir() */
char *maybe_temp_file(const void *ctx, const char *extension, bool in_pwd, char *temp_file(const void *ctx, const char *extension, const char *srcname);
const char *srcname);
/* Default wait for run_command. Should never time out. */ /* Default wait for run_command. Should never time out. */
extern const unsigned int default_timeout_ms; extern const unsigned int default_timeout_ms;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment