summaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c54
1 files changed, 10 insertions, 44 deletions
diff --git a/degesch.c b/degesch.c
index 92863da..d4c84c1 100644
--- a/degesch.c
+++ b/degesch.c
@@ -13768,64 +13768,30 @@ init_poller_events (struct app_context *ctx)
#ifdef TESTING
-static void
-on_test_config_foo_change (struct config_item *item)
-{
- *(bool *) item->user_data = item->value.boolean;
-}
-
static struct config_schema g_config_test[] =
{
- { .name = "foo",
- .comment = "baz",
- .type = CONFIG_ITEM_BOOLEAN,
- .default_ = "off",
- .on_change = on_test_config_foo_change },
- { .name = "bar",
- .type = CONFIG_ITEM_INTEGER,
- .validate = config_validate_nonnegative,
- .default_ = "1" },
- { .name = "foobar",
- .type = CONFIG_ITEM_STRING,
- .default_ = "\"qux\"" },
+ { .name = "foo", .type = CONFIG_ITEM_BOOLEAN, .default_ = "off" },
+ { .name = "bar", .type = CONFIG_ITEM_INTEGER, .default_ = "1" },
+ { .name = "foobar", .type = CONFIG_ITEM_STRING, .default_ = "\"x\\x01\"" },
{}
};
static void
-test_config_load (struct config_item *subtree, void *user_data)
-{
- config_schema_apply_to_object (g_config_test, subtree, user_data);
-}
-
-static void
test_config (void)
{
- struct config config = config_make ();
-
- bool b = true;
- config_register_module (&config, "top", test_config_load, &b);
- config_load (&config, config_item_object ());
- config_schema_call_changed (config.root);
- hard_assert (b == false);
-
- struct config_item *invalid = config_item_integer (-1);
- hard_assert (!config_item_set_from (config_item_get (config.root,
- "top.bar", NULL), invalid, NULL));
- config_item_destroy (invalid);
-
- struct str s = str_make ();
- serialize_configuration (config.root, &s);
- config_load (&config, config_item_parse (s.str, s.len, false, NULL));
- str_free (&s);
+ struct config_item *foo = config_item_object ();
+ config_schema_apply_to_object (g_config_test, foo, NULL);
+ struct config_item *root = config_item_object ();
+ str_map_set (&root->value.object, "top", foo);
struct strv v = strv_make ();
- dump_matching_options (config.root, "*foo*", &v);
+ dump_matching_options (root, "*foo*", &v);
hard_assert (v.len == 2);
hard_assert (!strcmp (v.vector[0], "top.foo = off"));
- hard_assert (!strcmp (v.vector[1], "top.foobar = \"qux\""));
+ hard_assert (!strcmp (v.vector[1], "top.foobar = \"x\\x01\""));
strv_free (&v);
- config_free (&config);
+ config_item_destroy (root);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -