From 5cb4705eb48a2483a73f99fe9adfef9246abcc7d Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 28 Mar 2022 10:58:12 +1030 Subject: [PATCH] unit tests: don't crash if !HAVE_SQLITE3. Fixes: #4928 Reported-by: @whitslack Signed-off-by: Rusty Russell --- wallet/test/run-db.c | 11 +++++++---- wallet/test/run-wallet.c | 21 ++++++++++++--------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/wallet/test/run-db.c b/wallet/test/run-db.c index 54d1a107b..054ddc31d 100644 --- a/wallet/test/run-db.c +++ b/wallet/test/run-db.c @@ -262,10 +262,13 @@ int main(int argc, char *argv[]) common_setup(argv[0]); ld->config = test_config; - ok &= test_empty_db_migrate(ld); - ok &= test_vars(ld); - ok &= test_primitives(); - ok &= test_manip_columns(); + /* We do a runtime test here, so we still check compile! */ + if (HAVE_SQLITE3) { + ok &= test_empty_db_migrate(ld); + ok &= test_vars(ld); + ok &= test_primitives(); + ok &= test_manip_columns(); + } tal_free(ld); common_shutdown(); diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index f095d170c..b4dc58e20 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -1906,15 +1906,18 @@ int main(int argc, const char *argv[]) htlc_in_map_init(&ld->htlcs_in); htlc_out_map_init(&ld->htlcs_out); - ok &= test_shachain_crud(ld, tmpctx); - ok &= test_channel_crud(ld, tmpctx); - ok &= test_channel_inflight_crud(ld, tmpctx); - ok &= test_channel_config_crud(ld, tmpctx); - ok &= test_channel_inflight_crud(ld, tmpctx); - ok &= test_wallet_outputs(ld, tmpctx); - ok &= test_htlc_crud(ld, tmpctx); - ok &= test_payment_crud(ld, tmpctx); - ok &= test_wallet_payment_status_enum(); + /* We do a runtime test here, so we still check compile! */ + if (HAVE_SQLITE3) { + ok &= test_shachain_crud(ld, tmpctx); + ok &= test_channel_crud(ld, tmpctx); + ok &= test_channel_inflight_crud(ld, tmpctx); + ok &= test_channel_config_crud(ld, tmpctx); + ok &= test_channel_inflight_crud(ld, tmpctx); + ok &= test_wallet_outputs(ld, tmpctx); + ok &= test_htlc_crud(ld, tmpctx); + ok &= test_payment_crud(ld, tmpctx); + ok &= test_wallet_payment_status_enum(); + } /* Do not clean up in the case of an error, we might want to debug the * database. */