2017-09-15 04:18:52 +02:00
|
|
|
#define main unused_main
|
|
|
|
int unused_main(int argc, char *argv[]);
|
2018-05-10 01:18:19 +02:00
|
|
|
#include "../../common/base32.c"
|
|
|
|
#include "../../common/wireaddr.c"
|
2019-05-30 04:30:10 +02:00
|
|
|
#include "../io_loop_with_timers.c"
|
2017-09-15 04:18:52 +02:00
|
|
|
#include "../lightningd.c"
|
2018-09-03 05:40:00 +02:00
|
|
|
#include "../subd.c"
|
2019-02-20 12:31:48 +01:00
|
|
|
#include <common/amount.h>
|
2017-09-15 04:18:52 +02:00
|
|
|
|
|
|
|
/* AUTOGENERATED MOCKS START */
|
2018-01-03 06:26:44 +01:00
|
|
|
/* Generated stub for activate_peers */
|
|
|
|
void activate_peers(struct lightningd *ld UNNEEDED)
|
|
|
|
{ fprintf(stderr, "activate_peers called!\n"); abort(); }
|
2018-12-04 04:04:14 +01:00
|
|
|
/* Generated stub for add_plugin_dir */
|
|
|
|
char *add_plugin_dir(struct plugins *plugins UNNEEDED, const char *dir UNNEEDED,
|
2019-10-10 08:01:59 +02:00
|
|
|
bool error_ok UNNEEDED)
|
2018-12-04 04:04:14 +01:00
|
|
|
{ fprintf(stderr, "add_plugin_dir called!\n"); abort(); }
|
2018-01-03 06:26:44 +01:00
|
|
|
/* Generated stub for begin_topology */
|
|
|
|
void begin_topology(struct chain_topology *topo UNNEEDED)
|
|
|
|
{ fprintf(stderr, "begin_topology called!\n"); abort(); }
|
2019-07-30 07:25:12 +02:00
|
|
|
/* Generated stub for bigsize_get */
|
|
|
|
size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED)
|
|
|
|
{ fprintf(stderr, "bigsize_get called!\n"); abort(); }
|
|
|
|
/* Generated stub for bigsize_put */
|
|
|
|
size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED)
|
|
|
|
{ fprintf(stderr, "bigsize_put called!\n"); abort(); }
|
2018-05-06 15:32:01 +02:00
|
|
|
/* Generated stub for channel_notify_new_block */
|
|
|
|
void channel_notify_new_block(struct lightningd *ld UNNEEDED,
|
|
|
|
u32 block_height UNNEEDED)
|
|
|
|
{ fprintf(stderr, "channel_notify_new_block called!\n"); abort(); }
|
2018-07-24 08:18:58 +02:00
|
|
|
/* Generated stub for connectd_activate */
|
|
|
|
void connectd_activate(struct lightningd *ld UNNEEDED)
|
|
|
|
{ fprintf(stderr, "connectd_activate called!\n"); abort(); }
|
2018-07-24 08:18:58 +02:00
|
|
|
/* Generated stub for connectd_init */
|
|
|
|
int connectd_init(struct lightningd *ld UNNEEDED)
|
|
|
|
{ fprintf(stderr, "connectd_init called!\n"); abort(); }
|
2018-09-03 05:40:00 +02:00
|
|
|
/* Generated stub for daemon_poll */
|
|
|
|
int daemon_poll(struct pollfd *fds UNNEEDED, nfds_t nfds UNNEEDED, int timeout UNNEEDED)
|
|
|
|
{ fprintf(stderr, "daemon_poll called!\n"); abort(); }
|
2018-03-29 04:06:45 +02:00
|
|
|
/* Generated stub for daemon_setup */
|
|
|
|
void daemon_setup(const char *argv0 UNNEEDED,
|
|
|
|
void (*backtrace_print)(const char *fmt UNNEEDED, ...) UNNEEDED,
|
|
|
|
void (*backtrace_exit)(void))
|
|
|
|
{ fprintf(stderr, "daemon_setup called!\n"); abort(); }
|
|
|
|
/* Generated stub for daemon_shutdown */
|
|
|
|
void daemon_shutdown(void)
|
|
|
|
{ fprintf(stderr, "daemon_shutdown called!\n"); abort(); }
|
2017-11-01 02:21:56 +01:00
|
|
|
/* Generated stub for db_begin_transaction_ */
|
|
|
|
void db_begin_transaction_(struct db *db UNNEEDED, const char *location UNNEEDED)
|
|
|
|
{ fprintf(stderr, "db_begin_transaction_ called!\n"); abort(); }
|
2017-11-01 02:10:48 +01:00
|
|
|
/* Generated stub for db_commit_transaction */
|
2017-11-01 02:21:56 +01:00
|
|
|
void db_commit_transaction(struct db *db UNNEEDED)
|
2017-11-01 02:10:48 +01:00
|
|
|
{ fprintf(stderr, "db_commit_transaction called!\n"); abort(); }
|
2017-11-27 16:20:10 +01:00
|
|
|
/* Generated stub for db_get_intvar */
|
|
|
|
s64 db_get_intvar(struct db *db UNNEEDED, char *varname UNNEEDED, s64 defval UNNEEDED)
|
|
|
|
{ fprintf(stderr, "db_get_intvar called!\n"); abort(); }
|
2019-07-23 20:45:06 +02:00
|
|
|
/* Generated stub for db_in_transaction */
|
|
|
|
bool db_in_transaction(struct db *db UNNEEDED)
|
|
|
|
{ fprintf(stderr, "db_in_transaction called!\n"); abort(); }
|
2017-11-01 02:10:48 +01:00
|
|
|
/* Generated stub for fatal */
|
|
|
|
void fatal(const char *fmt UNNEEDED, ...)
|
|
|
|
{ fprintf(stderr, "fatal called!\n"); abort(); }
|
2017-11-10 03:01:10 +01:00
|
|
|
/* Generated stub for free_htlcs */
|
2018-02-12 11:13:04 +01:00
|
|
|
void free_htlcs(struct lightningd *ld UNNEEDED, const struct channel *channel UNNEEDED)
|
2017-11-10 03:01:10 +01:00
|
|
|
{ fprintf(stderr, "free_htlcs called!\n"); abort(); }
|
2019-06-05 09:00:02 +02:00
|
|
|
/* Generated stub for free_unreleased_txs */
|
|
|
|
void free_unreleased_txs(struct wallet *w UNNEEDED)
|
|
|
|
{ fprintf(stderr, "free_unreleased_txs called!\n"); abort(); }
|
2018-09-03 05:40:00 +02:00
|
|
|
/* Generated stub for fromwire_status_fail */
|
|
|
|
bool fromwire_status_fail(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, enum status_failreason *failreason UNNEEDED, wirestring **desc UNNEEDED)
|
|
|
|
{ fprintf(stderr, "fromwire_status_fail called!\n"); abort(); }
|
|
|
|
/* Generated stub for fromwire_status_peer_billboard */
|
|
|
|
bool fromwire_status_peer_billboard(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, bool *perm UNNEEDED, wirestring **happenings UNNEEDED)
|
|
|
|
{ fprintf(stderr, "fromwire_status_peer_billboard called!\n"); abort(); }
|
|
|
|
/* Generated stub for fromwire_status_peer_error */
|
2019-07-26 04:11:19 +02:00
|
|
|
bool fromwire_status_peer_error(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct channel_id *channel UNNEEDED, wirestring **desc UNNEEDED, bool *soft_error UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **error_for_them UNNEEDED)
|
2018-09-03 05:40:00 +02:00
|
|
|
{ fprintf(stderr, "fromwire_status_peer_error called!\n"); abort(); }
|
2017-09-15 04:18:52 +02:00
|
|
|
/* Generated stub for gossip_init */
|
2018-07-24 08:18:58 +02:00
|
|
|
void gossip_init(struct lightningd *ld UNNEEDED, int connectd_fd UNNEEDED)
|
2017-09-15 04:18:52 +02:00
|
|
|
{ fprintf(stderr, "gossip_init called!\n"); abort(); }
|
2019-09-22 04:06:43 +02:00
|
|
|
/* Generated stub for gossip_notify_new_block */
|
|
|
|
void gossip_notify_new_block(struct lightningd *ld UNNEEDED, u32 blockheight UNNEEDED)
|
|
|
|
{ fprintf(stderr, "gossip_notify_new_block called!\n"); abort(); }
|
2018-10-31 18:00:44 +01:00
|
|
|
/* Generated stub for handle_early_opts */
|
|
|
|
void handle_early_opts(struct lightningd *ld UNNEEDED, int argc UNNEEDED, char *argv[])
|
|
|
|
{ fprintf(stderr, "handle_early_opts called!\n"); abort(); }
|
2017-09-15 04:18:52 +02:00
|
|
|
/* Generated stub for handle_opts */
|
2018-05-03 14:20:28 +02:00
|
|
|
void handle_opts(struct lightningd *ld UNNEEDED, int argc UNNEEDED, char *argv[])
|
2017-09-15 04:18:52 +02:00
|
|
|
{ fprintf(stderr, "handle_opts called!\n"); abort(); }
|
|
|
|
/* Generated stub for hash_htlc_key */
|
|
|
|
size_t hash_htlc_key(const struct htlc_key *htlc_key UNNEEDED)
|
|
|
|
{ fprintf(stderr, "hash_htlc_key called!\n"); abort(); }
|
|
|
|
/* Generated stub for hsm_init */
|
2018-05-03 14:20:28 +02:00
|
|
|
void hsm_init(struct lightningd *ld UNNEEDED)
|
2017-09-15 04:18:52 +02:00
|
|
|
{ fprintf(stderr, "hsm_init called!\n"); abort(); }
|
2018-05-06 15:32:01 +02:00
|
|
|
/* Generated stub for htlcs_notify_new_block */
|
|
|
|
void htlcs_notify_new_block(struct lightningd *ld UNNEEDED, u32 height UNNEEDED)
|
|
|
|
{ fprintf(stderr, "htlcs_notify_new_block called!\n"); abort(); }
|
2019-08-10 07:24:57 +02:00
|
|
|
/* Generated stub for htlcs_resubmit */
|
2019-12-12 00:39:10 +01:00
|
|
|
void htlcs_resubmit(struct lightningd *ld UNNEEDED,
|
|
|
|
struct htlc_in_map *unconnected_htlcs_in UNNEEDED)
|
2019-08-10 07:24:57 +02:00
|
|
|
{ fprintf(stderr, "htlcs_resubmit called!\n"); abort(); }
|
2020-01-26 13:07:50 +01:00
|
|
|
/* Generated stub for json_add_member */
|
|
|
|
void json_add_member(struct json_stream *js UNNEEDED,
|
|
|
|
const char *fieldname UNNEEDED,
|
|
|
|
bool quote UNNEEDED,
|
|
|
|
const char *fmt UNNEEDED, ...)
|
|
|
|
{ fprintf(stderr, "json_add_member called!\n"); abort(); }
|
|
|
|
/* Generated stub for json_array_end */
|
|
|
|
void json_array_end(struct json_stream *js UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_array_end called!\n"); abort(); }
|
|
|
|
/* Generated stub for json_array_start */
|
|
|
|
void json_array_start(struct json_stream *js UNNEEDED, const char *fieldname UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_array_start called!\n"); abort(); }
|
|
|
|
/* Generated stub for json_member_direct */
|
|
|
|
char *json_member_direct(struct json_stream *js UNNEEDED,
|
|
|
|
const char *fieldname UNNEEDED, size_t extra UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_member_direct called!\n"); abort(); }
|
|
|
|
/* Generated stub for json_object_end */
|
|
|
|
void json_object_end(struct json_stream *js UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_object_end called!\n"); abort(); }
|
|
|
|
/* Generated stub for json_object_start */
|
|
|
|
void json_object_start(struct json_stream *ks UNNEEDED, const char *fieldname UNNEEDED)
|
|
|
|
{ fprintf(stderr, "json_object_start called!\n"); abort(); }
|
2018-11-22 11:37:08 +01:00
|
|
|
/* Generated stub for jsonrpc_listen */
|
|
|
|
void jsonrpc_listen(struct jsonrpc *rpc UNNEEDED, struct lightningd *ld UNNEEDED)
|
|
|
|
{ fprintf(stderr, "jsonrpc_listen called!\n"); abort(); }
|
2019-02-04 11:55:42 +01:00
|
|
|
/* Generated stub for jsonrpc_setup */
|
|
|
|
void jsonrpc_setup(struct lightningd *ld UNNEEDED)
|
|
|
|
{ fprintf(stderr, "jsonrpc_setup called!\n"); abort(); }
|
2018-09-03 03:08:53 +02:00
|
|
|
/* Generated stub for load_channels_from_wallet */
|
2019-08-10 07:24:57 +02:00
|
|
|
struct htlc_in_map *load_channels_from_wallet(struct lightningd *ld UNNEEDED)
|
2018-09-03 03:08:53 +02:00
|
|
|
{ fprintf(stderr, "load_channels_from_wallet called!\n"); abort(); }
|
2017-09-15 04:18:52 +02:00
|
|
|
/* Generated stub for log_ */
|
2019-11-17 12:41:33 +01:00
|
|
|
void log_(struct log *log UNNEEDED, enum log_level level UNNEEDED,
|
|
|
|
const struct node_id *node_id UNNEEDED,
|
|
|
|
bool call_notifier UNNEEDED,
|
|
|
|
const char *fmt UNNEEDED, ...)
|
2017-09-15 04:18:52 +02:00
|
|
|
|
|
|
|
{ fprintf(stderr, "log_ called!\n"); abort(); }
|
2018-03-29 04:06:45 +02:00
|
|
|
/* Generated stub for log_backtrace_exit */
|
|
|
|
void log_backtrace_exit(void)
|
|
|
|
{ fprintf(stderr, "log_backtrace_exit called!\n"); abort(); }
|
|
|
|
/* Generated stub for log_backtrace_print */
|
|
|
|
void log_backtrace_print(const char *fmt UNNEEDED, ...)
|
|
|
|
{ fprintf(stderr, "log_backtrace_print called!\n"); abort(); }
|
2018-09-03 05:40:00 +02:00
|
|
|
/* Generated stub for log_prefix */
|
|
|
|
const char *log_prefix(const struct log *log UNNEEDED)
|
|
|
|
{ fprintf(stderr, "log_prefix called!\n"); abort(); }
|
2019-11-18 01:27:17 +01:00
|
|
|
/* Generated stub for log_print_level */
|
|
|
|
enum log_level log_print_level(struct log *log UNNEEDED)
|
|
|
|
{ fprintf(stderr, "log_print_level called!\n"); abort(); }
|
2018-09-03 05:40:00 +02:00
|
|
|
/* Generated stub for log_status_msg */
|
2019-11-17 12:41:33 +01:00
|
|
|
bool log_status_msg(struct log *log UNNEEDED,
|
|
|
|
const struct node_id *node_id UNNEEDED,
|
|
|
|
const u8 *msg UNNEEDED)
|
2018-09-03 05:40:00 +02:00
|
|
|
{ fprintf(stderr, "log_status_msg called!\n"); abort(); }
|
2020-02-04 01:14:13 +01:00
|
|
|
/* Generated stub for memleak_remove_strmap_ */
|
|
|
|
void memleak_remove_strmap_(struct htable *memtable UNNEEDED, const struct strmap *m UNNEEDED)
|
|
|
|
{ fprintf(stderr, "memleak_remove_strmap_ called!\n"); abort(); }
|
2017-09-15 04:18:52 +02:00
|
|
|
/* Generated stub for new_log */
|
2019-11-17 12:41:33 +01:00
|
|
|
struct log *new_log(const tal_t *ctx UNNEEDED, struct log_book *record UNNEEDED,
|
|
|
|
const struct node_id *default_node_id UNNEEDED,
|
|
|
|
const char *fmt UNNEEDED, ...)
|
2017-09-15 04:18:52 +02:00
|
|
|
{ fprintf(stderr, "new_log called!\n"); abort(); }
|
|
|
|
/* Generated stub for new_log_book */
|
2019-11-18 01:27:17 +01:00
|
|
|
struct log_book *new_log_book(struct lightningd *ld UNNEEDED, size_t max_mem UNNEEDED)
|
2017-09-15 04:18:52 +02:00
|
|
|
{ fprintf(stderr, "new_log_book called!\n"); abort(); }
|
|
|
|
/* Generated stub for new_topology */
|
2017-11-01 11:20:40 +01:00
|
|
|
struct chain_topology *new_topology(struct lightningd *ld UNNEEDED, struct log *log UNNEEDED)
|
2017-09-15 04:18:52 +02:00
|
|
|
{ fprintf(stderr, "new_topology called!\n"); abort(); }
|
2018-04-17 15:31:30 +02:00
|
|
|
/* Generated stub for onchaind_replay_channels */
|
|
|
|
void onchaind_replay_channels(struct lightningd *ld UNNEEDED)
|
|
|
|
{ fprintf(stderr, "onchaind_replay_channels called!\n"); abort(); }
|
2019-06-03 20:11:25 +02:00
|
|
|
/* Generated stub for per_peer_state_set_fds_arr */
|
|
|
|
void per_peer_state_set_fds_arr(struct per_peer_state *pps UNNEEDED, const int *fds UNNEEDED)
|
|
|
|
{ fprintf(stderr, "per_peer_state_set_fds_arr called!\n"); abort(); }
|
2018-11-05 17:01:56 +01:00
|
|
|
/* Generated stub for plugins_config */
|
|
|
|
void plugins_config(struct plugins *plugins UNNEEDED)
|
|
|
|
{ fprintf(stderr, "plugins_config called!\n"); abort(); }
|
2018-09-20 20:45:25 +02:00
|
|
|
/* Generated stub for plugins_init */
|
2018-12-08 01:30:56 +01:00
|
|
|
void plugins_init(struct plugins *plugins UNNEEDED, const char *dev_plugin_debug UNNEEDED)
|
2018-09-20 20:45:25 +02:00
|
|
|
{ fprintf(stderr, "plugins_init called!\n"); abort(); }
|
2018-09-20 13:46:50 +02:00
|
|
|
/* Generated stub for plugins_new */
|
2018-11-21 21:54:01 +01:00
|
|
|
struct plugins *plugins_new(const tal_t *ctx UNNEEDED, struct log_book *log_book UNNEEDED,
|
2019-02-04 11:55:42 +01:00
|
|
|
struct lightningd *ld UNNEEDED)
|
2018-09-20 13:46:50 +02:00
|
|
|
{ fprintf(stderr, "plugins_new called!\n"); abort(); }
|
2017-10-23 07:05:28 +02:00
|
|
|
/* Generated stub for setup_color_and_alias */
|
|
|
|
void setup_color_and_alias(struct lightningd *ld UNNEEDED)
|
|
|
|
{ fprintf(stderr, "setup_color_and_alias called!\n"); abort(); }
|
2017-09-15 04:18:52 +02:00
|
|
|
/* Generated stub for setup_topology */
|
2018-06-04 15:00:05 +02:00
|
|
|
void setup_topology(struct chain_topology *topology UNNEEDED, struct timers *timers UNNEEDED,
|
|
|
|
u32 min_blockheight UNNEEDED, u32 max_blockheight UNNEEDED)
|
2017-09-15 04:18:52 +02:00
|
|
|
{ fprintf(stderr, "setup_topology called!\n"); abort(); }
|
|
|
|
/* Generated stub for timer_expired */
|
|
|
|
void timer_expired(tal_t *ctx UNNEEDED, struct timer *timer UNNEEDED)
|
|
|
|
{ fprintf(stderr, "timer_expired called!\n"); abort(); }
|
2017-11-27 16:20:10 +01:00
|
|
|
/* Generated stub for txfilter_add_derkey */
|
2018-03-07 01:06:01 +01:00
|
|
|
void txfilter_add_derkey(struct txfilter *filter UNNEEDED,
|
pubkey: rename PUBKEY_DER_LEN to PUBKEY_CMPR_LEN.
Pubkeys are not not actually DER encoding, but Pieter Wuille corrected
me: it's SEC 1 documented encoding.
Results from 5 runs, min-max(mean +/- stddev):
store_load_msec,vsz_kb,store_rewrite_sec,listnodes_sec,listchannels_sec,routing_sec,peer_write_all_sec
38922-39297(39180.6+/-1.3e+02),2880728,41.040000-41.160000(41.106+/-0.05),2.270000-2.530000(2.338+/-0.097),44.570000-53.980000(49.696+/-3),32.840000-33.080000(32.95+/-0.095),43.060000-44.950000(43.696+/-0.72)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-08 08:34:05 +02:00
|
|
|
const u8 derkey[PUBKEY_CMPR_LEN])
|
2017-11-27 16:20:10 +01:00
|
|
|
{ fprintf(stderr, "txfilter_add_derkey called!\n"); abort(); }
|
|
|
|
/* Generated stub for txfilter_new */
|
|
|
|
struct txfilter *txfilter_new(const tal_t *ctx UNNEEDED)
|
|
|
|
{ fprintf(stderr, "txfilter_new called!\n"); abort(); }
|
2017-09-15 04:18:52 +02:00
|
|
|
/* Generated stub for version */
|
|
|
|
const char *version(void)
|
|
|
|
{ fprintf(stderr, "version called!\n"); abort(); }
|
2020-01-31 09:19:32 +01:00
|
|
|
/* Generated stub for waitblockheight_notify_new_block */
|
|
|
|
void waitblockheight_notify_new_block(struct lightningd *ld UNNEEDED,
|
|
|
|
u32 block_height UNNEEDED)
|
|
|
|
{ fprintf(stderr, "waitblockheight_notify_new_block called!\n"); abort(); }
|
2018-06-04 14:47:32 +02:00
|
|
|
/* Generated stub for wallet_blocks_heights */
|
|
|
|
void wallet_blocks_heights(struct wallet *w UNNEEDED, u32 def UNNEEDED, u32 *min UNNEEDED, u32 *max UNNEEDED)
|
|
|
|
{ fprintf(stderr, "wallet_blocks_heights called!\n"); abort(); }
|
2019-06-05 09:00:05 +02:00
|
|
|
/* Generated stub for wallet_clean_utxos */
|
|
|
|
void wallet_clean_utxos(struct wallet *w UNNEEDED, struct bitcoind *bitcoind UNNEEDED)
|
|
|
|
{ fprintf(stderr, "wallet_clean_utxos called!\n"); abort(); }
|
2018-02-16 17:55:33 +01:00
|
|
|
/* Generated stub for wallet_network_check */
|
2019-11-20 02:55:57 +01:00
|
|
|
bool wallet_network_check(struct wallet *w UNNEEDED)
|
2018-02-16 17:55:33 +01:00
|
|
|
{ fprintf(stderr, "wallet_network_check called!\n"); abort(); }
|
2017-09-15 04:18:52 +02:00
|
|
|
/* Generated stub for wallet_new */
|
2019-11-18 01:27:17 +01:00
|
|
|
struct wallet *wallet_new(struct lightningd *ld UNNEEDED, struct timers *timers UNNEEDED)
|
2017-09-15 04:18:52 +02:00
|
|
|
{ fprintf(stderr, "wallet_new called!\n"); abort(); }
|
|
|
|
/* AUTOGENERATED MOCKS END */
|
|
|
|
|
2018-03-29 04:06:45 +02:00
|
|
|
struct log *crashlog;
|
|
|
|
|
2017-09-15 04:18:52 +02:00
|
|
|
#undef main
|
2018-02-21 16:06:07 +01:00
|
|
|
int main(int argc UNUSED, char *argv[] UNUSED)
|
2017-09-15 04:18:52 +02:00
|
|
|
{
|
2018-04-25 12:55:34 +02:00
|
|
|
setup_locale();
|
|
|
|
|
2017-09-15 04:18:52 +02:00
|
|
|
char *argv0;
|
|
|
|
/* We're assuming we're run from top build dir. */
|
2018-03-15 07:10:20 +01:00
|
|
|
const char *answer;
|
|
|
|
|
|
|
|
setup_tmpctx();
|
2018-09-03 05:40:00 +02:00
|
|
|
answer = path_canon(tmpctx, "lightningd/test/run-find_my_abspath");
|
2017-09-15 04:18:52 +02:00
|
|
|
|
|
|
|
/* Various different ways we could find ourselves. */
|
|
|
|
argv0 = path_join(tmpctx,
|
2018-09-03 05:40:00 +02:00
|
|
|
path_cwd(tmpctx), "lightningd/test/run-find_my_abspath");
|
2017-09-15 04:18:52 +02:00
|
|
|
unsetenv("PATH");
|
|
|
|
|
|
|
|
/* Absolute path. */
|
2018-09-03 05:40:00 +02:00
|
|
|
assert(streq(find_my_abspath(tmpctx, argv0), answer));
|
2017-09-15 04:18:52 +02:00
|
|
|
|
|
|
|
/* Relative to cwd. */
|
2018-09-03 05:40:00 +02:00
|
|
|
argv0 = "lightningd/test/run-find_my_abspath";
|
|
|
|
assert(streq(find_my_abspath(tmpctx, argv0), answer));
|
2017-09-15 04:18:52 +02:00
|
|
|
|
|
|
|
/* Using $PATH */
|
|
|
|
setenv("PATH", path_join(tmpctx,
|
|
|
|
path_cwd(tmpctx), "lightningd/test"), 1);
|
2018-09-03 05:40:00 +02:00
|
|
|
argv0 = "run-find_my_abspath";
|
2017-09-15 04:18:52 +02:00
|
|
|
|
2018-09-03 05:40:00 +02:00
|
|
|
assert(streq(find_my_abspath(tmpctx, argv0), answer));
|
2017-09-15 04:18:52 +02:00
|
|
|
|
|
|
|
/* Even with dummy things in path. */
|
|
|
|
char **pathelems = tal_arr(tmpctx, char *, 4);
|
|
|
|
pathelems[0] = "/tmp/foo";
|
|
|
|
pathelems[1] = "/sbin";
|
|
|
|
pathelems[2] = path_join(tmpctx, path_cwd(tmpctx), "lightningd/test");
|
|
|
|
pathelems[3] = NULL;
|
|
|
|
|
|
|
|
setenv("PATH", tal_strjoin(tmpctx, pathelems, ":", STR_NO_TRAIL), 1);
|
2018-09-03 05:40:00 +02:00
|
|
|
assert(streq(find_my_abspath(tmpctx, argv0), answer));
|
2017-09-15 04:18:52 +02:00
|
|
|
|
2017-09-28 05:40:05 +02:00
|
|
|
assert(!taken_any());
|
|
|
|
take_cleanup();
|
2017-09-15 04:18:52 +02:00
|
|
|
tal_free(tmpctx);
|
|
|
|
return 0;
|
|
|
|
}
|