Skip to content

Commit 40a44d9

Browse files
committed
build: fix build with no sqlite3 support.
Reported-by: whitslack Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Fixes: #8473 Changelog-Fixed: build: we can now build without sqlite3 support.
1 parent 13c5db5 commit 40a44d9

File tree

1 file changed

+76
-67
lines changed

1 file changed

+76
-67
lines changed

plugins/bkpr/test/run-recorder.c

Lines changed: 76 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@
3737
#include "plugins/bkpr/rebalances.c"
3838
#include "plugins/bkpr/sql.c"
3939

40-
#if HAVE_SQLITE3
41-
#include <sqlite3.h>
42-
#endif
43-
4440
/* AUTOGENERATED MOCKS START */
4541
/* Generated stub for chain_event_description */
4642
const char *chain_event_description(const struct bkpr *bkpr UNNEEDED,
@@ -89,6 +85,55 @@ void plugin_log(struct plugin *p UNNEEDED, enum log_level l UNNEEDED, const char
8985
{ fprintf(stderr, "plugin_log called!\n"); abort(); }
9086
/* AUTOGENERATED MOCKS END */
9187

88+
struct command_result *jsonrpc_set_datastore_(struct command *cmd UNNEEDED,
89+
const char *path UNNEEDED,
90+
const void *value UNNEEDED,
91+
int len_or_str UNNEEDED,
92+
const char *mode UNNEEDED,
93+
struct command_result *(*cb)(struct command *command,
94+
const char *method,
95+
const char *buf,
96+
const jsmntok_t *result,
97+
void *arg),
98+
struct command_result *(*errcb)(struct command *command UNNEEDED,
99+
const char *method UNNEEDED,
100+
const char *buf UNNEEDED,
101+
const jsmntok_t *result UNNEEDED,
102+
void *arg) UNNEEDED,
103+
void *arg)
104+
105+
{
106+
return cb(cmd, NULL, NULL, NULL, arg);
107+
}
108+
109+
struct command_result *ignore_datastore_reply(struct command *cmd,
110+
const char *method UNNEEDED,
111+
const char *buf UNNEEDED,
112+
const jsmntok_t *result UNNEEDED,
113+
void *arg UNNEEDED)
114+
{
115+
return NULL;
116+
}
117+
118+
struct json_out *json_out_obj(const tal_t *ctx,
119+
const char *fieldname,
120+
const char *str)
121+
{
122+
struct json_out *jout = json_out_new(ctx);
123+
json_out_start(jout, NULL, '{');
124+
if (str)
125+
json_out_addstr(jout, fieldname, str);
126+
if (taken(str))
127+
tal_free(str);
128+
json_out_end(jout, '}');
129+
json_out_finished(jout);
130+
131+
return jout;
132+
}
133+
134+
#if HAVE_SQLITE3
135+
#include <sqlite3.h>
136+
92137
static sqlite3 *bkpr_db;
93138
static struct command *cmd;
94139

@@ -425,59 +470,12 @@ static void log_channel_event(sqlite3 *db,
425470
sqlite3_finalize(stmt);
426471
}
427472

428-
struct command_result *jsonrpc_set_datastore_(struct command *cmd UNNEEDED,
429-
const char *path UNNEEDED,
430-
const void *value UNNEEDED,
431-
int len_or_str UNNEEDED,
432-
const char *mode UNNEEDED,
433-
struct command_result *(*cb)(struct command *command,
434-
const char *method,
435-
const char *buf,
436-
const jsmntok_t *result,
437-
void *arg),
438-
struct command_result *(*errcb)(struct command *command UNNEEDED,
439-
const char *method UNNEEDED,
440-
const char *buf UNNEEDED,
441-
const jsmntok_t *result UNNEEDED,
442-
void *arg) UNNEEDED,
443-
void *arg)
444-
445-
{
446-
return cb(cmd, NULL, NULL, NULL, arg);
447-
}
448-
449-
struct command_result *ignore_datastore_reply(struct command *cmd,
450-
const char *method UNNEEDED,
451-
const char *buf UNNEEDED,
452-
const jsmntok_t *result UNNEEDED,
453-
void *arg UNNEEDED)
454-
{
455-
return NULL;
456-
}
457-
458-
struct json_out *json_out_obj(const tal_t *ctx,
459-
const char *fieldname,
460-
const char *str)
461-
{
462-
struct json_out *jout = json_out_new(ctx);
463-
json_out_start(jout, NULL, '{');
464-
if (str)
465-
json_out_addstr(jout, fieldname, str);
466-
if (taken(str))
467-
tal_free(str);
468-
json_out_end(jout, '}');
469-
json_out_finished(jout);
470-
471-
return jout;
472-
}
473-
474473
const jsmntok_t *jsonrpc_request_sync(const tal_t *ctx,
475474
struct command *cmd,
476475
const char *method,
477476
const struct json_out *params TAKES,
478477
const char **resp)
479478
{
480-
#if HAVE_SQLITE3
481479
sqlite3_stmt *s;
482480
jsmntok_t *toks;
483481
jsmn_parser parser;
@@ -551,9 +549,6 @@ const jsmntok_t *jsonrpc_request_sync(const tal_t *ctx,
551549
tal_free(params);
552550
*resp = buf;
553551
return toks;
554-
#else
555-
return NULL;
556-
#endif
557552
}
558553

559554
static char *tmp_dsn(const tal_t *ctx)
@@ -1660,21 +1655,35 @@ int main(int argc, char *argv[])
16601655

16611656
common_setup(argv[0]);
16621657

1663-
if (HAVE_SQLITE3) {
1664-
/* UBSan insists cmd isn't NULL */
1665-
cmd = tal(tmpctx, struct command);
1666-
ok &= test_account_crud(tmpctx);
1667-
ok &= test_channel_event_crud(tmpctx);
1668-
ok &= test_chain_event_crud(tmpctx);
1669-
ok &= test_account_balances(tmpctx);
1670-
ok &= test_onchain_fee_chan_close(tmpctx);
1671-
ok &= test_onchain_fee_chan_open(tmpctx);
1672-
ok &= test_channel_rebalances(tmpctx);
1673-
ok &= test_onchain_fee_wallet_spend(tmpctx);
1674-
sqlite3_close(bkpr_db);
1675-
}
1658+
/* UBSan insists cmd isn't NULL */
1659+
cmd = tal(tmpctx, struct command);
1660+
ok &= test_account_crud(tmpctx);
1661+
ok &= test_channel_event_crud(tmpctx);
1662+
ok &= test_chain_event_crud(tmpctx);
1663+
ok &= test_account_balances(tmpctx);
1664+
ok &= test_onchain_fee_chan_close(tmpctx);
1665+
ok &= test_onchain_fee_chan_open(tmpctx);
1666+
ok &= test_channel_rebalances(tmpctx);
1667+
ok &= test_onchain_fee_wallet_spend(tmpctx);
1668+
sqlite3_close(bkpr_db);
16761669

16771670
common_shutdown();
16781671
trace_cleanup();
16791672
return !ok;
16801673
}
1674+
#else /* No sqlite, no test! */
1675+
const jsmntok_t *jsonrpc_request_sync(const tal_t *ctx,
1676+
struct command *cmd,
1677+
const char *method,
1678+
const struct json_out *params TAKES,
1679+
const char **resp)
1680+
{
1681+
abort();
1682+
}
1683+
1684+
int main(int argc, char *argv[])
1685+
{
1686+
common_setup(argv[0]);
1687+
common_shutdown();
1688+
}
1689+
#endif /* !HAVE_SQLITE3 */

0 commit comments

Comments
 (0)