From 0959b3de847ac67fe97afb5d594c79056d0ebd61 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Wed, 17 Jul 2024 10:11:16 -0400 Subject: [PATCH] Address review comment Signed-off-by: Cole Miller --- test/integration/test_fsm.c | 22 +++++++++++----------- test/lib/util.h | 7 ++++++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/test/integration/test_fsm.c b/test/integration/test_fsm.c index 00bf4d381..d4e97ff00 100644 --- a/test/integration/test_fsm.c +++ b/test/integration/test_fsm.c @@ -98,7 +98,7 @@ TEST(fsm, snapshotFreshDb, setUp, tearDown, 0, snapshot_params) unsigned n_bufs = 0; int rv; - bool disk_mode = param_bool(params, "disk_mode"); + bool disk_mode = param_get_bool(params, "disk_mode"); rv = fsm->snapshot(fsm, &bufs, &n_bufs); munit_assert_int(rv, ==, 0); @@ -128,7 +128,7 @@ TEST(fsm, snapshotWrittenDb, setUp, tearDown, 0, snapshot_params) uint64_t last_insert_id; uint64_t rows_affected; - bool disk_mode = param_bool(params, "disk_mode"); + bool disk_mode = param_get_bool(params, "disk_mode"); /* Add some data to database */ HANDSHAKE; @@ -166,7 +166,7 @@ TEST(fsm, snapshotHeapFaultSingleDB, setUp, tearDown, 0, snapshot_params) uint64_t last_insert_id; uint64_t rows_affected; - bool disk_mode = param_bool(params, "disk_mode"); + bool disk_mode = param_get_bool(params, "disk_mode"); /* Add some data to database */ HANDSHAKE; @@ -218,7 +218,7 @@ TEST(fsm, uint64_t last_insert_id; uint64_t rows_affected; - bool disk_mode = param_bool(params, "disk_mode"); + bool disk_mode = param_get_bool(params, "disk_mode"); if (!disk_mode) { return MUNIT_SKIP; @@ -261,7 +261,7 @@ TEST(fsm, snapshotHeapFaultTwoDB, setUp, tearDown, 0, snapshot_params) uint64_t last_insert_id; uint64_t rows_affected; - bool disk_mode = param_bool(params, "disk_mode"); + bool disk_mode = param_get_bool(params, "disk_mode"); /* Open 2 databases and add data to them */ HANDSHAKE; @@ -325,7 +325,7 @@ TEST(fsm, snapshotHeapFaultTwoDBAsync, setUp, tearDown, 0, snapshot_params) uint64_t last_insert_id; uint64_t rows_affected; - bool disk_mode = param_bool(params, "disk_mode"); + bool disk_mode = param_get_bool(params, "disk_mode"); if (!disk_mode) { return MUNIT_SKIP; } @@ -390,7 +390,7 @@ TEST(fsm, snapshotNewDbAddedBeforeFinalize, setUp, tearDown, 0, snapshot_params) uint64_t last_insert_id; uint64_t rows_affected; - bool disk_mode = param_bool(params, "disk_mode"); + bool disk_mode = param_get_bool(params, "disk_mode"); /* Add some data to database */ HANDSHAKE; @@ -440,7 +440,7 @@ TEST(fsm, snapshotWritesBeforeFinalize, setUp, tearDown, 0, snapshot_params) char sql[128]; int rv; - bool disk_mode = param_bool(params, "disk_mode"); + bool disk_mode = param_get_bool(params, "disk_mode"); /* Add some data to database */ HANDSHAKE; @@ -491,7 +491,7 @@ TEST(fsm, concurrentSnapshots, setUp, tearDown, 0, snapshot_params) uint64_t rows_affected; int rv; - bool disk_mode = param_bool(params, "disk_mode"); + bool disk_mode = param_get_bool(params, "disk_mode"); /* Add some data to database */ HANDSHAKE; @@ -583,7 +583,7 @@ TEST(fsm, snapshotRestore, setUp, tearDown, 0, restore_params) int rv; char sql[128]; - bool disk_mode = param_bool(params, "disk_mode"); + bool disk_mode = param_get_bool(params, "disk_mode"); /* Add some data to database */ HANDSHAKE; @@ -649,7 +649,7 @@ TEST(fsm, snapshotRestoreMultipleDBs, setUp, tearDown, 0, snapshot_params) char *msg; int rv; - bool disk_mode = param_bool(params, "disk_mode"); + bool disk_mode = param_get_bool(params, "disk_mode"); /* Create 2 databases and add data to them. */ HANDSHAKE; diff --git a/test/lib/util.h b/test/lib/util.h index b4c862baf..018547378 100644 --- a/test/lib/util.h +++ b/test/lib/util.h @@ -24,7 +24,12 @@ } \ } while (0) -static inline bool param_bool(const MunitParameter *params, const char *name) +/** + * Parse a numeric test parameter as a boolean. The result is false + * if the parameter is unset or set to "0", and true otherwise. + */ +static inline bool param_get_bool(const MunitParameter *params, + const char *name) { const char *param = munit_parameters_get(params, name); return param != NULL && (bool)atoi(param);