mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-05 23:24:21 +01:00
common/utils: introduce tmpdir_mkstemp; use it
Various unit tests were creating temporary files unconditionally in /tmp and were not cleaning up after themselves. Introduce a new variant of mkstemp(3p) that respects the TMPDIR environment variable, and use it in the offending unit tests. This allows each test run to use a dedicated TMPDIR that can be cleaned up after the run. Changelog-None Signed-off-by: Matt Whitlock <c-lightning@mattwhitlock.name>
This commit is contained in:
committed by
Rusty Russell
parent
5284ee4dae
commit
1f79aad830
@@ -13,6 +13,7 @@
|
||||
#include <common/route.h>
|
||||
#include <common/setup.h>
|
||||
#include <common/type_to_string.h>
|
||||
#include <common/utils.h>
|
||||
#include <bitcoin/chainparams.h>
|
||||
#include <stdio.h>
|
||||
#include <wire/peer_wiregen.h>
|
||||
@@ -185,7 +186,7 @@ int main(int argc, char *argv[])
|
||||
struct gossmap *gossmap;
|
||||
const double riskfactor = 1.0;
|
||||
char gossip_version = GOSSIP_STORE_VERSION;
|
||||
char gossipfilename[] = "/tmp/run-route-specific-gossipstore.XXXXXX";
|
||||
char *gossipfilename;
|
||||
|
||||
common_setup(argv[0]);
|
||||
node_id_from_hexstr("03c173897878996287a8100469f954dd820fcd8941daed91c327f168f3329be0bf",
|
||||
@@ -203,7 +204,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
chainparams = chainparams_for_network("regtest");
|
||||
|
||||
store_fd = mkstemp(gossipfilename);
|
||||
store_fd = tmpdir_mkstemp(tmpctx, "run-route-specific-gossipstore.XXXXXX", &gossipfilename);
|
||||
assert(write(store_fd, &gossip_version, sizeof(gossip_version))
|
||||
== sizeof(gossip_version));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user