diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2020-10-12 04:08:09 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2020-10-12 04:08:09 +0200 |
commit | 6837fdb7c4eac3e36b297e8dd1c3943bf6767884 (patch) | |
tree | e8ea2e0f03ab3717831cac7ac4dc74e702efa400 /degesch.c | |
parent | 2759c311faeab339e52fcecaf52cd04885a5a54c (diff) | |
download | xK-6837fdb7c4eac3e36b297e8dd1c3943bf6767884.tar.gz xK-6837fdb7c4eac3e36b297e8dd1c3943bf6767884.tar.xz xK-6837fdb7c4eac3e36b297e8dd1c3943bf6767884.zip |
Bump liberty
We've moved most of our configuration test in there.
Diffstat (limited to 'degesch.c')
-rw-r--r-- | degesch.c | 54 |
1 files changed, 10 insertions, 44 deletions
@@ -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); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |