Skip to content

Commit 7c58294

Browse files
whitslackrustyrussell
authored andcommitted
lightningd/test: use tmpdir_mkstemp() to create log file
Changelog-None
1 parent 2d904d3 commit 7c58294

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lightningd/test/run-log_filter.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ int main(int argc, char *argv[])
118118
struct log_book *lb;
119119
struct node_id node_id;
120120
struct lightningd *ld;
121-
char tmpfiletemplate[] = "/tmp/run-log_filter.XXXXXX";
121+
char *tmpfile;
122122

123123
common_setup(argv[0]);
124124

@@ -131,8 +131,8 @@ int main(int argc, char *argv[])
131131
ld->log = new_logger(ld, lb, NULL, "dummy");
132132
assert(arg_log_to_file("-", ld) == NULL);
133133

134-
assert(mkstemp(tmpfiletemplate) >= 0);
135-
assert(arg_log_to_file(tmpfiletemplate, ld) == NULL);
134+
assert(tmpdir_mkstemp(tmpctx, "run-log_filter.XXXXXX", &tmpfile) >= 0);
135+
assert(arg_log_to_file(tmpfile, ld) == NULL);
136136

137137
/* Log level default. */
138138
assert(opt_log_level("BROKEN", lb) == NULL);
@@ -224,7 +224,7 @@ int main(int argc, char *argv[])
224224
assert(try_log(lb, "prefix", NULL, LOG_IO_IN) == 0);
225225

226226
/* File exception: tmpfile logs everything */
227-
assert(opt_log_level(tal_fmt(tmpctx, "io::%s", tmpfiletemplate), lb) == NULL);
227+
assert(opt_log_level(tal_fmt(tmpctx, "io::%s", tmpfile), lb) == NULL);
228228
assert(try_log(lb, "stdout1", NULL, LOG_BROKEN) == 2);
229229
assert(try_log(lb, "stdout1", NULL, LOG_INFORM) == 2);
230230
assert(try_log(lb, "stdout1", NULL, LOG_DBG) == 2);

0 commit comments

Comments
 (0)