diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-06-30 19:06:21 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-06-30 19:06:21 +0000 |
| commit | 55bd3cfd623a86044fd028787c216810ee274af7 (patch) | |
| tree | d5eab7558e4795df69017feb4abffa1d46c11985 /config.c | |
| parent | config: NOINLINE a couple of functions doing tll operations (diff) | |
config: add unit test for config_clone()
We’re mainly interested in seeing that we don’t leak memory, or double
free heap allocated data.
Valgrind and/or gcc/clang sanitizers are best at this, hence the very
few asserts in the test itself.
Diffstat (limited to 'config.c')
| -rw-r--r-- | config.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -3140,6 +3140,27 @@ config_clone(const struct config *old) return conf; } +UNITTEST +{ + struct config original; + user_notifications_t nots = tll_init(); + config_override_t overrides = tll_init(); + + bool ret = config_load(&original, "/dev/null", ¬s, &overrides, false); + xassert(ret); + + struct config *clone = config_clone(&original); + xassert(clone != NULL); + xassert(clone != &original); + + config_free(original); + config_free(*clone); + free(clone); + + tll_free(overrides); + tll_free(nots); +} + void config_free(struct config conf) { |
