int verbose = 0;
static struct ccanlint_map tests;
bool safe_mode = false;
+bool keep_results = false;
static bool targeting = false;
static unsigned int timeout;
}
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) {
i->skip = "timeout";
if (verbose)
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;
- 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);
- }
+ keep_results = true;
/* Don't automatically destroy temporary dir. */
talloc_set_destructor(temp_dir(NULL), show_tmpdir);
"list tests ccanlint performs (and exit)");
opt_register_noarg("--test-dep-graph", test_dependency_graph, NULL,
"print dependency graph of tests in Graphviz .dot format");
- opt_register_arg("-k|--keep <testname>", keep_test, NULL, NULL,
- "keep results of <testname>"
- " (can be used multiple times, or 'all')");
+ opt_register_noarg("-k|--keep", keep_tests, NULL,
+ "do not delete ccanlint working files");
opt_register_noarg("--summary|-s", opt_set_bool, &summary,
"simply give one line summary");
opt_register_arg("-x|--exclude <testname>", exclude_test, NULL, NULL,
/* Should we stop immediately if test fails? */
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
* depends are done. */
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) */
void (*handle)(struct manifest *m, struct score *score);
struct dgraph_node node;
/* Did we skip a dependency? If so, must skip this, too. */
const char *skip;
- /* Did the user want to keep these results? */
- bool keep_results;
/* Have we already run this? */
bool done;
};
/* Are we happy to compile stuff, or just non-intrusive tests? */
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. */
extern const char *ccan_dir;
}
static void check_headers_no_cpp(struct manifest *m,
- bool keep,
unsigned int *timeleft, struct score *score)
{
char *contents;
int fd;
struct ccan_file *mainh = main_header(m);
- tmpsrc = maybe_temp_file(m, "-included.c", keep, mainh->fullname);
- tmpobj = maybe_temp_file(m, ".o", keep, tmpsrc);
+ tmpsrc = temp_file(m, "-included.c", mainh->fullname);
+ tmpobj = temp_file(m, ".o", tmpsrc);
/* We don't fail you for this. */
score->pass = true;
#ifndef CCANLINT_BUILD_H
#define CCANLINT_BUILD_H
-char *build_module(struct manifest *m, bool keep, enum compile_type ctype,
- char **errstr);
+char *build_module(struct manifest *m, enum compile_type ctype, char **errstr);
char *build_submodule(struct manifest *m, const char *flags,
enum compile_type ctype);
void build_objects(struct manifest *m,
- bool keep, struct score *score, const char *flags,
+ struct score *score, const char *flags,
enum compile_type ctype);
#endif /* CCANLINT_BUILD_H */
}
static void check_depends_accurate(struct manifest *m,
- bool keep,
unsigned int *timeleft, struct score *score)
{
struct list_head *list;
char *fullfile = talloc_asprintf(m, "%s/%s", m->dir, i->name);
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,
i->compiled[ctype], &output)) {
talloc_free(i->compiled[ctype]);
if (errstr)
return errstr;
- m->compiled[ctype] = build_module(m, false, ctype, &errstr);
+ m->compiled[ctype] = build_module(m, ctype, &errstr);
if (!m->compiled[ctype])
return errstr;
return NULL;
}
static void check_depends_built(struct manifest *m,
- bool keep,
unsigned int *timeleft, struct score *score)
{
struct manifest *i;
}
static void check_depends_built_without_features(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
/* FIXME: check this is still true once we reduce features. */
static void check_depends_exist(struct manifest *m,
- bool keep,
unsigned int *timeleft, struct score *score)
{
unsigned int i;
static bool compile(const void *ctx,
struct manifest *m,
struct ccan_file *file,
- bool keep, char **output)
+ char **output)
{
- file->compiled[COMPILE_NORMAL]
- = maybe_temp_file(ctx, "", keep, file->fullname);
+ file->compiled[COMPILE_NORMAL] = temp_file(ctx, "", file->fullname);
if (!compile_and_link(ctx, file->fullname, ccan_dir,
example_obj_list(m, file),
compiler, cflags,
lib_list(m), file->compiled[COMPILE_NORMAL],
output)) {
- /* Don't keep failures. */
- if (keep)
- unlink(file->compiled[COMPILE_NORMAL]);
- talloc_free(file->compiled[COMPILE_NORMAL]);
+ /* Don't keep failures, even with --keep */
+ unlink(file->compiled[COMPILE_NORMAL]);
file->compiled[COMPILE_NORMAL] = NULL;
return false;
}
static struct ccan_file *mangle_example(struct manifest *m,
struct ccan_file *example,
- char **lines,
- bool keep)
+ char **lines)
{
char *name, *contents;
int fd;
struct ccan_file *f;
- name = maybe_temp_file(example, ".c", keep,
- talloc_asprintf(m, "%s/mangled-%s",
- m->dir, example->name));
+ name = temp_file(example, ".c",
+ talloc_asprintf(m, "%s/mangled-%s",
+ m->dir, example->name));
f = new_ccan_file(example,
talloc_dirname(example, name),
talloc_basename(example, name));
static unsigned int try_compiling(struct manifest *m,
struct ccan_file *i,
char **prev,
- bool keep,
struct ccan_file *mangled[3],
bool res[3],
char *err[3],
/* Try standalone. */
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);
if (res[0] && streq(err[0], ""))
return 1;
if (prev) {
lines[1] = combine(i, get_ccan_file_lines(i), prev);
- mangled[1] = mangle_example(m, i, lines[1], keep);
- res[1] = compile(i, m, mangled[1], keep, &err[1]);
+ mangled[1] = mangle_example(m, i, lines[1]);
+ res[1] = compile(i, m, mangled[1], &err[1]);
if (res[1] && streq(err[1], "")) {
return 2;
}
/* Try standalone. */
lines[num] = get_ccan_file_lines(i);
- mangled[num] = mangle_example(m, i, lines[num], keep);
- res[num] = compile(i, m, mangled[num], keep, &err[num]);
+ mangled[num] = mangle_example(m, i, lines[num]);
+ res[num] = compile(i, m, mangled[num], &err[num]);
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)
{
struct ccan_file *i;
/* Simplify our dumb parsing. */
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. */
for (j = 0; j < num; j++) {
/* Creates and adds an example file. */
static char *add_example(struct manifest *m, struct ccan_file *source,
- bool keep,
struct doc_section *example)
{
char *name;
while (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));
talloc_steal(f, name);
list_add_tail(&m->examples, &f->list);
/* FIXME: We should have one example per function in header. */
static void extract_examples(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
score->total = 2;
list_for_each(get_ccan_file_docs(m->info_file), d, list) {
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)
return;
have_info_example = true;
mainh = f;
list_for_each(get_ccan_file_docs(f), d, list) {
if (streq(d->type, "example")) {
- score->error = add_example(m, f, keep, d);
+ score->error = add_example(m, f, d);
if (score->error)
return;
have_header_example = true;
#include <ctype.h>
static void examples_relevant_check(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
return output;
}
-static void run_examples(struct manifest *m, bool keep,
+static void run_examples(struct manifest *m,
unsigned int *timeleft, struct score *score)
{
struct ccan_file *i;
#include <ctype.h>
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;
const char *explanation =
if (!ask(q))
continue;
- tmpname = maybe_temp_file(score, ".h", false, e->file->name);
+ tmpname = temp_file(score, ".h", e->file->name);
out = fopen(tmpname, "w");
if (!out)
err(1, "Opening %s", tmpname);
}
static void check_idempotent(struct manifest *m,
- bool keep,
unsigned int *timeleft, struct score *score)
{
struct ccan_file *f;
}
static void check_info_documentation_exists(struct manifest *m,
- bool keep,
- unsigned int *timeleft,
- struct score *score)
+ unsigned int *timeleft,
+ struct score *score)
{
struct list_head *infodocs = get_ccan_file_docs(m->info_file);
struct doc_section *d;
#include <ccan/talloc/talloc.h>
static void check_has_info(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
#include <ccan/str/str.h>
static void check_info_summary_single_line(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
#include <ccan/str_talloc/str_talloc.h>
static void check_license_comment(struct manifest *m,
- bool keep,
unsigned int *timeleft, struct score *score)
{
struct list_head *list;
#include <ccan/str_talloc/str_talloc.h>
static void check_license_depends_compat(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
extern struct ccanlint license_exists;
static void check_has_license(struct manifest *m,
- bool keep,
unsigned int *timeleft, struct score *score)
{
char buf[PATH_MAX];
#include <ccan/str_talloc/str_talloc.h>
static void check_license_file_compat(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
}
static void check_includes_build(struct manifest *m,
- bool keep,
unsigned int *timeleft, struct score *score)
{
char *contents;
int fd;
struct ccan_file *mainh = main_header(m);
- tmpsrc = maybe_temp_file(m, "-included.c", keep, mainh->fullname);
- tmpobj = maybe_temp_file(m, ".o", keep, tmpsrc);
+ tmpsrc = temp_file(m, "-included.c", mainh->fullname);
+ tmpobj = temp_file(m, ".o", tmpsrc);
fd = open(tmpsrc, O_WRONLY | O_CREAT | O_EXCL, 0600);
if (fd < 0)
#include <ccan/noerr/noerr.h>
static void check_has_main_header(struct manifest *m,
- bool keep,
unsigned int *timeleft, struct score *score)
{
struct ccan_file *f;
return list;
}
-char *build_module(struct manifest *m, bool keep,
+char *build_module(struct manifest *m,
enum compile_type ctype, char **errstr)
{
- char *name = link_objects(m, m->basename, false, obj_list(m, ctype),
- 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;
+ return link_objects(m, m->basename, obj_list(m, ctype), errstr);
}
static void do_build(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
}
m->compiled[COMPILE_NORMAL]
- = build_module(m, keep, COMPILE_NORMAL, &errstr);
+ = build_module(m, COMPILE_NORMAL, &errstr);
if (!m->compiled[COMPILE_NORMAL]) {
score_file_error(score, NULL, 0, "%s", errstr);
return;
}
static void check_use_build(struct manifest *m,
- bool keep,
unsigned int *timeleft, struct score *score)
{
char *contents;
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", basename);
fd = open(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0600);
if (fd < 0)
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;
}
static void check_trailing_whitespace(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
}
void build_objects(struct manifest *m,
- bool keep, struct score *score, const char *flags,
+ struct score *score, const char *flags,
enum compile_type ctype)
{
struct ccan_file *i;
char *output;
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,
i->compiled[ctype], &output)) {
talloc_free(i->compiled[ctype]);
}
static void check_objs_build(struct manifest *m,
- bool keep,
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 = {
static void test_compile(struct score *score,
struct ccan_file *file,
const char *filename,
- bool keep,
const char *flags,
bool *errors,
bool *warnings)
{
char *output, *compiled;
- compiled = maybe_temp_file(score, "", keep, filename);
+ compiled = temp_file(score, "", filename);
if (!compile_object(score, filename, ccan_dir, compiler, flags,
compiled, &output)) {
score_file_error(score, file, 0,
}
static void build_objects_with_stringchecks(struct manifest *m,
- bool keep, unsigned int *timeleft,
+ unsigned int *timeleft,
struct score *score)
{
struct ccan_file *i;
if (list_empty(&m->c_files)) {
char *line;
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);
line = talloc_asprintf(score, "#include <ccan/%s/%s.h>\n",
m->basename, m->basename);
write_str(tmpfd, line);
close(tmpfd);
- test_compile(score, i, tmp, keep, flags, &errors, &warnings);
+ test_compile(score, i, tmp, flags, &errors, &warnings);
} else {
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);
write_str(tmpfd, get_ccan_file_contents(i));
close(tmpfd);
- test_compile(score, i, tmp, keep, flags,
- &errors, &warnings);
+ test_compile(score, i, tmp, flags, &errors, &warnings);
}
}
#include "build.h"
static void check_objs_build_without_features(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
const char *flags = talloc_asprintf(score, "%s %s",
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 = {
}
static void do_reduce_features(struct manifest *m,
- bool keep,
unsigned int *timeleft, struct score *score)
{
struct htable_option *options_used, *options_avail, *options;
struct ccan_file *file,
bool fail,
bool link_with_module,
- bool keep,
enum compile_type ctype,
char **output)
{
ctype == COMPILE_NOFEAT
? " "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,
test_obj_list(m, link_with_module,
ctype, ctype),
struct manifest *m,
struct ccan_file *file,
bool link_with_module,
- bool keep,
enum compile_type ctype,
unsigned int time_ms)
{
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",
cflags,
ctype == COMPILE_NOFEAT
file->compiled[ctype]);
}
-static void compile_tests(struct manifest *m, bool keep,
+static void compile_tests(struct manifest *m,
struct score *score,
enum compile_type ctype,
unsigned int time_ms)
foreach_ptr(list, &m->compile_ok_tests, &m->run_tests, &m->api_tests) {
list_for_each(list, i, list) {
compile_async(score, m, i,
- list == &m->api_tests, keep,
+ list == &m->api_tests,
ctype, time_ms);
}
}
/* For historical reasons, "fail" often means "gives warnings" */
list_for_each(&m->compile_fail_tests, i, list) {
- if (!compile(score, m, i, false, false, false,
- ctype, &cmdout)) {
+ if (!compile(score, m, i, false, false, ctype, &cmdout)) {
score_file_error(score, i, 0,
"Compile without -DFAIL failed:\n%s",
cmdout);
cmdout);
return;
}
- if (compile(score, m, i, true, false, false,
- ctype, &cmdout)
+ if (compile(score, m, i, true, false, ctype, &cmdout)
&& streq(cmdout, "")) {
score_file_error(score, i, 0,
"Compiled successfully with -DFAIL?");
/* FIXME: If we time out, set *timeleft to 0 */
static void do_compile_tests(struct manifest *m,
- bool keep,
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 = {
}
static void do_compile_tests_without_features(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
- compile_tests(m, keep, score, COMPILE_NOFEAT, *timeleft);
+ compile_tests(m, score, COMPILE_NOFEAT, *timeleft);
}
struct ccanlint tests_compile_without_features = {
unsigned int time_ms,
struct manifest *m,
struct ccan_file *file,
- bool link_with_module,
- bool keep)
+ bool link_with_module)
{
char *flags = talloc_asprintf(ctx, "%s %s", cflags, COVERAGE_CFLAGS);
- file->compiled[COMPILE_COVERAGE]
- = maybe_temp_file(ctx, "", keep, file->fullname);
+ file->compiled[COMPILE_COVERAGE] = temp_file(ctx, "", file->fullname);
compile_and_link_async(file, time_ms, file->fullname, ccan_dir,
test_obj_list(m, link_with_module,
COMPILE_NORMAL,
/* FIXME: Coverage from testable examples as well. */
static void do_compile_coverage_tests(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
/* For API tests, we need coverage version of module. */
if (!list_empty(&m->api_tests)) {
- build_objects(m, keep, score, f, COMPILE_COVERAGE);
+ build_objects(m, score, f, COMPILE_COVERAGE);
if (!score->pass) {
score->error = talloc_strdup(score,
"Failed to compile module objects with coverage");
foreach_ptr(h, &m->run_tests, &m->api_tests) {
list_for_each(h, i, list) {
- cov_compile(m, *timeleft, m, i, h == &m->api_tests,
- keep);
+ cov_compile(m, *timeleft, m, i, h == &m->api_tests);
}
}
}
static void do_run_coverage_tests(struct manifest *m,
- bool keep,
unsigned int *timeleft, struct score *score)
{
struct ccan_file *i;
full_gcov ? "" : "-n",
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. */
foreach_ptr(list, &m->run_tests, &m->api_tests) {
list_for_each(list, i, list) {
}
static void check_tests_exist(struct manifest *m,
- bool keep,
unsigned int *timeleft, struct score *score)
{
struct stat st;
}
static bool compile(struct manifest *m,
- bool keep,
struct ccan_file *cfile,
const char *flags,
enum compile_type ctype,
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,
cfile->compiled[ctype], output);
}
static void compile_test_helpers(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score,
const char *flags,
list_for_each(&m->other_test_c_files, i, list) {
char *cmdout;
- if (!compile(m, keep, i, flags, ctype, &cmdout)) {
+ if (!compile(m, i, flags, ctype, &cmdout)) {
errors = true;
score_file_error(score, i, 0, "Compile failed:\n%s",
cmdout);
}
static void do_compile_test_helpers(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
- compile_test_helpers(m, keep, timeleft, score, cflags,
- COMPILE_NORMAL);
+ compile_test_helpers(m, timeleft, score, cflags, COMPILE_NORMAL);
}
struct ccanlint tests_helpers_compile = {
}
static void do_compile_test_helpers_without_features(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
flags = talloc_asprintf(score, "%s %s", cflags,
REDUCE_FEATURES_FLAGS);
- compile_test_helpers(m, keep, timeleft, score, flags,
- COMPILE_NOFEAT);
+ compile_test_helpers(m, timeleft, score, flags, COMPILE_NOFEAT);
}
struct ccanlint tests_helpers_compile_without_features = {
i->valgrind_log = talloc_asprintf(m,
"%s.valgrind-log",
i->compiled[COMPILE_NORMAL]);
- talloc_set_destructor(i->valgrind_log,
- unlink_file_destructor);
run_command_async(i, *timeleft,
"valgrind -q"
}
static void do_run_tests(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
/* FIXME: Run examples, too! */
static void do_run_tests_vg(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
continue;
}
- if (keep)
- talloc_set_destructor(i->valgrind_log, NULL);
-
output = grab_file(i, i->valgrind_log, NULL);
/* No valgrind errors? */
if (!output || output[0] == '\0') {
}
static void do_leakcheck_vg(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
/* We don't do these under valgrind: too slow! */
static void do_run_tests_no_features(struct manifest *m,
- bool keep,
unsigned int *timeleft,
struct score *score)
{
bool compile_verbose = false;
/* 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)
{
- char *file = maybe_temp_file(ctx, ".o", in_pwd, basename);
+ char *file = temp_file(ctx, ".o", basename);
if (compile_verbose)
printf("Linking objects into %s\n", file);
if (!info)
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);
if (fd < 0)
return NULL;
if (strrchr(ccandir, '/'))
*strrchr(ccandir, '/') = '\0';
- compiled = maybe_temp_file(ctx, "", false, "info");
+ compiled = temp_file(ctx, "", "info");
if (compile_and_link(ctx, info_c_file, ccandir, "",
CCAN_COMPILER, CCAN_CFLAGS " -I.", "",
compiled, &output))
return 0;
}
-char *maybe_temp_file(const void *ctx, const char *extension, bool keep,
- const char *srcname)
+char *temp_file(const void *ctx, const char *extension, const char *srcname)
{
unsigned baselen;
char *f, *suffix = talloc_strdup(ctx, "");
} while (lstat(f, &st) == 0);
if (tools_verbose)
- printf("Creating %sfile %s\n", keep ? "" : "temporary ", f);
-
- if (!keep)
- talloc_set_destructor(f, unlink_file_destructor);
+ printf("Creating file %s\n", f);
talloc_free(suffix);
return f;
/* If set, say what we're compiling to. */
extern bool compile_verbose;
/* 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);
/* 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,
const char *compiler, const char *cflags,
const char *libs, const char *outfile, char **output);
-/* If in_pwd is false, return a file int temp_dir, otherwise a local file. */
-char *maybe_temp_file(const void *ctx, const char *extension, bool in_pwd,
- const char *srcname);
+/* Returns a file in temp_dir() */
+char *temp_file(const void *ctx, const char *extension, const char *srcname);
/* Default wait for run_command. Should never time out. */
extern const unsigned int default_timeout_ms;