Bump liberty

We've moved most of our configuration test in there.
This commit is contained in:
Přemysl Eric Janouch 2020-10-12 04:08:09 +02:00
parent 2759c311fa
commit 6837fdb7c4
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 11 additions and 45 deletions

View File

@ -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);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

@ -1 +1 @@
Subproject commit e029aae1d3d1884ca868c3694bdec0456b3e8267
Subproject commit 9b723049635329feda63fab675df794e429aa151