mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +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
@@ -2,6 +2,7 @@
|
||||
#include <bitcoin/chainparams.h>
|
||||
#include <common/gossip_store.h>
|
||||
#include <common/setup.h>
|
||||
#include <common/utils.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -332,11 +333,11 @@ int main(int argc, char *argv[])
|
||||
struct payment *p;
|
||||
struct payment_modifier **mods;
|
||||
char gossip_version = GOSSIP_STORE_VERSION;
|
||||
char gossipfilename[] = "/tmp/run-route-overlong.XXXXXX";
|
||||
char *gossipfilename;
|
||||
|
||||
common_setup(argv[0]);
|
||||
chainparams = chainparams_for_network("regtest");
|
||||
store_fd = mkstemp(gossipfilename);
|
||||
store_fd = tmpdir_mkstemp(tmpctx, "run-route-overlong.XXXXXX", &gossipfilename);
|
||||
assert(write(store_fd, &gossip_version, sizeof(gossip_version))
|
||||
== sizeof(gossip_version));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user