1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018, Olivier MATZ <zer0@droids-corp.org>
11 #include <ecoli_string.h>
12 #include <ecoli_malloc.h>
13 #include <ecoli_keyval.h>
14 #include <ecoli_node.h>
15 #include <ecoli_log.h>
16 #include <ecoli_test.h>
17 #include <ecoli_config.h>
19 EC_LOG_TYPE_REGISTER(config);
21 const char *ec_config_reserved_keys[] = {
29 __ec_config_dump(FILE *out, const char *key, const struct ec_config *config,
32 ec_config_dict_validate(const struct ec_keyval *dict,
33 const struct ec_config_schema *schema);
36 ec_config_key_is_reserved(const char *name)
40 for (i = 0; i < EC_COUNT_OF(ec_config_reserved_keys); i++) {
41 if (!strcmp(name, ec_config_reserved_keys[i]))
47 /* return ec_value type as a string */
49 ec_config_type_str(enum ec_config_type type)
52 case EC_CONFIG_TYPE_BOOL: return "bool";
53 case EC_CONFIG_TYPE_INT64: return "int64";
54 case EC_CONFIG_TYPE_UINT64: return "uint64";
55 case EC_CONFIG_TYPE_STRING: return "string";
56 case EC_CONFIG_TYPE_NODE: return "node";
57 case EC_CONFIG_TYPE_LIST: return "list";
58 case EC_CONFIG_TYPE_DICT: return "dict";
59 default: return "unknown";
64 ec_config_schema_len(const struct ec_config_schema *schema)
70 for (i = 0; schema[i].type != EC_CONFIG_TYPE_NONE; i++)
76 __ec_config_schema_validate(const struct ec_config_schema *schema,
77 enum ec_config_type type)
82 if (type == EC_CONFIG_TYPE_LIST) {
83 if (schema[0].key != NULL) {
85 EC_LOG(EC_LOG_ERR, "list schema key must be NULL\n");
88 } else if (type == EC_CONFIG_TYPE_DICT) {
89 for (i = 0; schema[i].type != EC_CONFIG_TYPE_NONE; i++) {
90 if (schema[i].key == NULL) {
93 "dict schema key should not be NULL\n");
99 EC_LOG(EC_LOG_ERR, "invalid schema type\n");
103 for (i = 0; schema[i].type != EC_CONFIG_TYPE_NONE; i++) {
104 if (schema[i].key != NULL &&
105 ec_config_key_is_reserved(schema[i].key)) {
108 "key name <%s> is reserved\n", schema[i].key);
111 /* check for duplicate name if more than one element */
112 for (j = i + 1; schema[j].type != EC_CONFIG_TYPE_NONE; j++) {
113 if (!strcmp(schema[i].key, schema[j].key)) {
116 "duplicate key <%s> in schema\n",
122 switch (schema[i].type) {
123 case EC_CONFIG_TYPE_BOOL:
124 case EC_CONFIG_TYPE_INT64:
125 case EC_CONFIG_TYPE_UINT64:
126 case EC_CONFIG_TYPE_STRING:
127 case EC_CONFIG_TYPE_NODE:
128 if (schema[i].subschema != NULL || ec_config_schema_len(
129 schema[i].subschema) != 0) {
132 "key <%s> should not have subtype/subschema\n",
137 case EC_CONFIG_TYPE_LIST:
138 if (schema[i].subschema == NULL || ec_config_schema_len(
139 schema[i].subschema) != 1) {
142 "key <%s> must have subschema of length 1\n",
147 case EC_CONFIG_TYPE_DICT:
148 if (schema[i].subschema == NULL || ec_config_schema_len(
149 schema[i].subschema) == 0) {
152 "key <%s> must have subschema\n",
158 EC_LOG(EC_LOG_ERR, "invalid type for key <%s>\n",
164 if (schema[i].subschema == NULL)
167 ret = __ec_config_schema_validate(schema[i].subschema,
170 EC_LOG(EC_LOG_ERR, "cannot parse subschema %s%s\n",
171 schema[i].key ? "key=" : "",
172 schema[i].key ? : "");
181 ec_config_schema_validate(const struct ec_config_schema *schema)
183 return __ec_config_schema_validate(schema, EC_CONFIG_TYPE_DICT);
187 __ec_config_schema_dump(FILE *out, const struct ec_config_schema *schema,
192 for (i = 0; schema[i].type != EC_CONFIG_TYPE_NONE; i++) {
193 fprintf(out, "%*s" "%s%s%stype=%s desc='%s'\n",
195 schema[i].key ? "key=": "",
196 schema[i].key ? : "",
197 schema[i].key ? " ": "",
198 ec_config_type_str(schema[i].type),
200 if (schema[i].subschema == NULL)
202 __ec_config_schema_dump(out, schema[i].subschema,
208 ec_config_schema_dump(FILE *out, const struct ec_config_schema *schema)
210 fprintf(out, "------------------- schema dump:\n");
212 if (schema == NULL) {
213 fprintf(out, "no schema\n");
217 __ec_config_schema_dump(out, schema, 0);
220 enum ec_config_type ec_config_get_type(const struct ec_config *config)
226 ec_config_bool(bool boolean)
228 struct ec_config *value = NULL;
230 value = ec_calloc(1, sizeof(*value));
234 value->type = EC_CONFIG_TYPE_BOOL;
235 value->boolean = boolean;
241 ec_config_i64(int64_t i64)
243 struct ec_config *value = NULL;
245 value = ec_calloc(1, sizeof(*value));
249 value->type = EC_CONFIG_TYPE_INT64;
256 ec_config_u64(uint64_t u64)
258 struct ec_config *value = NULL;
260 value = ec_calloc(1, sizeof(*value));
264 value->type = EC_CONFIG_TYPE_UINT64;
270 /* duplicate string */
272 ec_config_string(const char *string)
274 struct ec_config *value = NULL;
280 s = ec_strdup(string);
284 value = ec_calloc(1, sizeof(*value));
288 value->type = EC_CONFIG_TYPE_STRING;
299 /* "consume" the node */
301 ec_config_node(struct ec_node *node)
303 struct ec_config *value = NULL;
308 value = ec_calloc(1, sizeof(*value));
312 value->type = EC_CONFIG_TYPE_NODE;
326 struct ec_config *value = NULL;
327 struct ec_keyval *dict = NULL;
333 value = ec_calloc(1, sizeof(*value));
337 value->type = EC_CONFIG_TYPE_DICT;
343 ec_keyval_free(dict);
351 struct ec_config *value = NULL;
353 value = ec_calloc(1, sizeof(*value));
357 value->type = EC_CONFIG_TYPE_LIST;
358 TAILQ_INIT(&value->list);
363 static const struct ec_config_schema *
364 ec_config_schema_lookup(const struct ec_config_schema *schema,
365 const char *key, enum ec_config_type type)
369 for (i = 0; schema[i].type != EC_CONFIG_TYPE_NONE; i++) {
370 if (!strcmp(key, schema[i].key) &&
371 type == schema[i].type)
380 ec_config_free(struct ec_config *value)
385 switch (value->type) {
386 case EC_CONFIG_TYPE_STRING:
387 ec_free(value->string);
389 case EC_CONFIG_TYPE_NODE:
390 ec_node_free(value->node);
392 case EC_CONFIG_TYPE_LIST:
393 while (!TAILQ_EMPTY(&value->list)) {
395 v = TAILQ_FIRST(&value->list);
396 TAILQ_REMOVE(&value->list, v, next);
400 case EC_CONFIG_TYPE_DICT:
401 ec_keyval_free(value->dict);
411 ec_config_list_cmp(const struct ec_config_list *list1,
412 const struct ec_config_list *list2)
414 const struct ec_config *v1, *v2;
416 for (v1 = TAILQ_FIRST(list1), v2 = TAILQ_FIRST(list2);
417 v1 != NULL && v2 != NULL;
418 v1 = TAILQ_NEXT(v1, next), v2 = TAILQ_NEXT(v2, next)) {
419 if (ec_config_cmp(v1, v2))
422 if (v1 != NULL || v2 != NULL)
428 /* XXX -> ec_keyval_cmp() */
430 ec_config_dict_cmp(const struct ec_keyval *d1,
431 const struct ec_keyval *d2)
433 const struct ec_config *v1, *v2;
434 struct ec_keyval_iter *iter = NULL;
437 if (ec_keyval_len(d1) != ec_keyval_len(d2))
440 for (iter = ec_keyval_iter(d1);
441 ec_keyval_iter_valid(iter);
442 ec_keyval_iter_next(iter)) {
443 key = ec_keyval_iter_get_key(iter);
444 v1 = ec_keyval_iter_get_val(iter);
445 v2 = ec_keyval_get(d2, key);
447 if (ec_config_cmp(v1, v2))
451 ec_keyval_iter_free(iter);
455 ec_keyval_iter_free(iter);
460 ec_config_cmp(const struct ec_config *value1,
461 const struct ec_config *value2)
463 if (value1 == NULL || value2 == NULL) {
468 if (value1->type != value2->type)
471 switch (value1->type) {
472 case EC_CONFIG_TYPE_BOOL:
473 if (value1->boolean == value2->boolean)
475 case EC_CONFIG_TYPE_INT64:
476 if (value1->i64 == value2->i64)
478 case EC_CONFIG_TYPE_UINT64:
479 if (value1->u64 == value2->u64)
481 case EC_CONFIG_TYPE_STRING:
482 if (!strcmp(value1->string, value2->string))
484 case EC_CONFIG_TYPE_NODE:
485 if (value1->node == value2->node)
487 case EC_CONFIG_TYPE_LIST:
488 return ec_config_list_cmp(&value1->list, &value2->list);
489 case EC_CONFIG_TYPE_DICT:
490 return ec_config_dict_cmp(value1->dict, value2->dict);
499 ec_config_list_validate(const struct ec_config_list *list,
500 const struct ec_config_schema *sch)
502 const struct ec_config *value;
504 TAILQ_FOREACH(value, list, next) {
505 if (value->type != sch->type) {
510 if (value->type == EC_CONFIG_TYPE_LIST) {
511 if (ec_config_list_validate(&value->list,
514 } else if (value->type == EC_CONFIG_TYPE_DICT) {
515 if (ec_config_dict_validate(value->dict,
525 ec_config_dict_validate(const struct ec_keyval *dict,
526 const struct ec_config_schema *schema)
528 const struct ec_config *value;
529 struct ec_keyval_iter *iter = NULL;
530 const struct ec_config_schema *sch;
533 for (iter = ec_keyval_iter(dict);
534 ec_keyval_iter_valid(iter);
535 ec_keyval_iter_next(iter)) {
537 key = ec_keyval_iter_get_key(iter);
538 value = ec_keyval_iter_get_val(iter);
539 sch = ec_config_schema_lookup(schema, key, value->type);
545 if (value->type == EC_CONFIG_TYPE_LIST) {
546 if (ec_config_list_validate(&value->list,
549 } else if (value->type == EC_CONFIG_TYPE_DICT) {
550 if (ec_config_dict_validate(value->dict,
556 ec_keyval_iter_free(iter);
560 ec_keyval_iter_free(iter);
565 ec_config_validate(const struct ec_config *dict,
566 const struct ec_config_schema *schema)
568 if (dict->type != EC_CONFIG_TYPE_DICT || schema == NULL) {
573 if (ec_config_dict_validate(dict->dict, schema) < 0)
583 ec_config_dict_get(const struct ec_config *config, const char *key)
585 if (config == NULL) {
590 if (config->type != EC_CONFIG_TYPE_DICT) {
595 return ec_keyval_get(config->dict, key);
599 ec_config_list_first(struct ec_config *list)
601 if (list == NULL || list->type != EC_CONFIG_TYPE_LIST) {
606 return TAILQ_FIRST(&list->list);
610 ec_config_list_next(struct ec_config *list, struct ec_config *config)
613 return TAILQ_NEXT(config, next);
616 /* value is consumed */
617 int ec_config_dict_set(struct ec_config *config, const char *key,
618 struct ec_config *value)
620 void (*free_cb)(struct ec_config *) = ec_config_free;
622 if (config == NULL || key == NULL || value == NULL) {
626 if (config->type != EC_CONFIG_TYPE_DICT) {
631 return ec_keyval_set(config->dict, key, value,
632 (void (*)(void *))free_cb);
635 ec_config_free(value);
639 int ec_config_dict_del(struct ec_config *config, const char *key)
641 if (config == NULL || key == NULL) {
645 if (config->type != EC_CONFIG_TYPE_DICT) {
650 return ec_keyval_del(config->dict, key);
653 /* value is consumed */
655 ec_config_list_add(struct ec_config *list,
656 struct ec_config *value)
658 if (list == NULL || list->type != EC_CONFIG_TYPE_LIST || value == NULL) {
663 TAILQ_INSERT_TAIL(&list->list, value, next);
668 ec_config_free(value);
672 int ec_config_list_del(struct ec_config *list, struct ec_config *config)
674 if (list == NULL || list->type != EC_CONFIG_TYPE_LIST) {
679 TAILQ_REMOVE(&list->list, config, next);
680 ec_config_free(config);
684 static struct ec_config *
685 ec_config_list_dup(const struct ec_config_list *list)
687 struct ec_config *dup = NULL, *v, *value;
689 dup = ec_config_list();
693 TAILQ_FOREACH(v, list, next) {
694 value = ec_config_dup(v);
697 if (ec_config_list_add(dup, value) < 0)
708 static struct ec_config *
709 ec_config_dict_dup(const struct ec_keyval *dict)
711 struct ec_config *dup = NULL, *value;
712 struct ec_keyval_iter *iter = NULL;
715 dup = ec_config_dict();
719 for (iter = ec_keyval_iter(dict);
720 ec_keyval_iter_valid(iter);
721 ec_keyval_iter_next(iter)) {
722 key = ec_keyval_iter_get_key(iter);
723 value = ec_config_dup(ec_keyval_iter_get_val(iter));
726 if (ec_config_dict_set(dup, key, value) < 0)
729 ec_keyval_iter_free(iter);
735 ec_keyval_iter_free(iter);
740 ec_config_dup(const struct ec_config *config)
742 if (config == NULL) {
747 switch (config->type) {
748 case EC_CONFIG_TYPE_BOOL:
749 return ec_config_bool(config->boolean);
750 case EC_CONFIG_TYPE_INT64:
751 return ec_config_i64(config->i64);
752 case EC_CONFIG_TYPE_UINT64:
753 return ec_config_u64(config->u64);
754 case EC_CONFIG_TYPE_STRING:
755 return ec_config_string(config->string);
756 case EC_CONFIG_TYPE_NODE:
757 return ec_config_node(ec_node_clone(config->node));
758 case EC_CONFIG_TYPE_LIST:
759 return ec_config_list_dup(&config->list);
760 case EC_CONFIG_TYPE_DICT:
761 return ec_config_dict_dup(config->dict);
771 ec_config_list_dump(FILE *out, const struct ec_config_list *list,
774 const struct ec_config *v;
776 fprintf(out, "%*s" "type=list:\n", (int)indent * 4, "");
778 TAILQ_FOREACH(v, list, next) {
779 if (__ec_config_dump(out, NULL, v, indent + 1) < 0)
787 ec_config_dict_dump(FILE *out, const struct ec_keyval *dict,
790 const struct ec_config *value;
791 struct ec_keyval_iter *iter;
794 fprintf(out, "%*s" "type=dict:\n", (int)indent * 4, "");
795 for (iter = ec_keyval_iter(dict);
796 ec_keyval_iter_valid(iter);
797 ec_keyval_iter_next(iter)) {
798 key = ec_keyval_iter_get_key(iter);
799 value = ec_keyval_iter_get_val(iter);
800 if (__ec_config_dump(out, key, value, indent + 1) < 0)
803 ec_keyval_iter_free(iter);
807 ec_keyval_iter_free(iter);
812 __ec_config_dump(FILE *out, const char *key, const struct ec_config *value,
815 char *val_str = NULL;
817 switch (value->type) {
818 case EC_CONFIG_TYPE_BOOL:
820 ec_asprintf(&val_str, "true");
822 ec_asprintf(&val_str, "false");
824 case EC_CONFIG_TYPE_INT64:
825 ec_asprintf(&val_str, "%"PRIu64, value->u64);
827 case EC_CONFIG_TYPE_UINT64:
828 ec_asprintf(&val_str, "%"PRIi64, value->i64);
830 case EC_CONFIG_TYPE_STRING:
831 ec_asprintf(&val_str, "%s", value->string);
833 case EC_CONFIG_TYPE_NODE:
834 ec_asprintf(&val_str, "%p", value->node);
836 case EC_CONFIG_TYPE_LIST:
837 return ec_config_list_dump(out, &value->list, indent);
838 case EC_CONFIG_TYPE_DICT:
839 return ec_config_dict_dump(out, value->dict, indent);
845 /* errno is already set on error */
849 fprintf(out, "%*s" "%s%s%stype=%s val=%s\n", (int)indent * 4, "",
853 ec_config_type_str(value->type), val_str);
864 ec_config_dump(FILE *out, const struct ec_config *config)
866 fprintf(out, "------------------- config dump:\n");
868 if (config == NULL) {
869 fprintf(out, "no config\n");
873 if (__ec_config_dump(out, NULL, config, 0) < 0)
874 fprintf(out, "error while dumping\n");
877 /* LCOV_EXCL_START */
878 static const struct ec_config_schema sch_intlist_elt[] = {
880 .desc = "This is a description for int",
881 .type = EC_CONFIG_TYPE_INT64,
884 .type = EC_CONFIG_TYPE_NONE,
888 static const struct ec_config_schema sch_dict[] = {
891 .desc = "This is a description for int",
892 .type = EC_CONFIG_TYPE_INT64,
896 .desc = "This is a description for int2",
897 .type = EC_CONFIG_TYPE_INT64,
900 .type = EC_CONFIG_TYPE_NONE,
904 static const struct ec_config_schema sch_dictlist_elt[] = {
906 .desc = "This is a description for dict",
907 .type = EC_CONFIG_TYPE_DICT,
908 .subschema = sch_dict,
911 .type = EC_CONFIG_TYPE_NONE,
915 static const struct ec_config_schema sch_baseconfig[] = {
918 .desc = "This is a description for bool",
919 .type = EC_CONFIG_TYPE_BOOL,
923 .desc = "This is a description for int",
924 .type = EC_CONFIG_TYPE_INT64,
928 .desc = "This is a description for string",
929 .type = EC_CONFIG_TYPE_STRING,
933 .desc = "This is a description for node",
934 .type = EC_CONFIG_TYPE_NODE,
938 .desc = "This is a description for list",
939 .type = EC_CONFIG_TYPE_LIST,
940 .subschema = sch_intlist_elt,
943 .key = "my_dictlist",
944 .desc = "This is a description for list",
945 .type = EC_CONFIG_TYPE_LIST,
946 .subschema = sch_dictlist_elt,
949 .type = EC_CONFIG_TYPE_NONE,
953 static int ec_config_testcase(void)
955 struct ec_node *node = NULL;
956 struct ec_keyval *dict = NULL;
957 const struct ec_config *value = NULL;
958 struct ec_config *config = NULL, *config2 = NULL;
959 struct ec_config *list = NULL, *subconfig = NULL;
960 struct ec_config *list_, *config_;
964 testres |= EC_TEST_CHECK(ec_config_key_is_reserved("id"),
965 "'id' should be reserved");
966 testres |= EC_TEST_CHECK(!ec_config_key_is_reserved("foo"),
967 "'foo' should not be reserved");
969 node = ec_node("empty", EC_NO_ID);
973 if (ec_config_schema_validate(sch_baseconfig) < 0) {
974 EC_LOG(EC_LOG_ERR, "invalid config schema\n");
978 ec_config_schema_dump(stdout, sch_baseconfig);
980 config = ec_config_dict();
984 ret = ec_config_dict_set(config, "my_bool", ec_config_bool(true));
985 testres |= EC_TEST_CHECK(ret == 0, "cannot set boolean");
986 value = ec_config_dict_get(config, "my_bool");
987 testres |= EC_TEST_CHECK(
989 value->type == EC_CONFIG_TYPE_BOOL &&
990 value->boolean == true,
991 "unexpected boolean value");
993 ret = ec_config_dict_set(config, "my_int", ec_config_i64(1234));
994 testres |= EC_TEST_CHECK(ret == 0, "cannot set int");
995 value = ec_config_dict_get(config, "my_int");
996 testres |= EC_TEST_CHECK(
998 value->type == EC_CONFIG_TYPE_INT64 &&
1000 "unexpected int value");
1002 testres |= EC_TEST_CHECK(
1003 ec_config_validate(config, sch_baseconfig) == 0,
1004 "cannot validate config\n");
1006 ret = ec_config_dict_set(config, "my_string", ec_config_string("toto"));
1007 testres |= EC_TEST_CHECK(ret == 0, "cannot set string");
1008 value = ec_config_dict_get(config, "my_string");
1009 testres |= EC_TEST_CHECK(
1011 value->type == EC_CONFIG_TYPE_STRING &&
1012 !strcmp(value->string, "toto"),
1013 "unexpected string value");
1015 list = ec_config_list();
1019 subconfig = ec_config_dict();
1020 if (subconfig == NULL)
1023 ret = ec_config_dict_set(subconfig, "my_int", ec_config_i64(1));
1024 testres |= EC_TEST_CHECK(ret == 0, "cannot set int");
1025 value = ec_config_dict_get(subconfig, "my_int");
1026 testres |= EC_TEST_CHECK(
1028 value->type == EC_CONFIG_TYPE_INT64 &&
1030 "unexpected int value");
1032 ret = ec_config_dict_set(subconfig, "my_int2", ec_config_i64(2));
1033 testres |= EC_TEST_CHECK(ret == 0, "cannot set int");
1034 value = ec_config_dict_get(subconfig, "my_int2");
1035 testres |= EC_TEST_CHECK(
1037 value->type == EC_CONFIG_TYPE_INT64 &&
1039 "unexpected int value");
1041 testres |= EC_TEST_CHECK(
1042 ec_config_validate(subconfig, sch_dict) == 0,
1043 "cannot validate subconfig\n");
1045 ret = ec_config_list_add(list, subconfig);
1046 subconfig = NULL; /* freed */
1047 testres |= EC_TEST_CHECK(ret == 0, "cannot add in list");
1049 subconfig = ec_config_dict();
1050 if (subconfig == NULL)
1053 ret = ec_config_dict_set(subconfig, "my_int", ec_config_i64(3));
1054 testres |= EC_TEST_CHECK(ret == 0, "cannot set int");
1055 value = ec_config_dict_get(subconfig, "my_int");
1056 testres |= EC_TEST_CHECK(
1058 value->type == EC_CONFIG_TYPE_INT64 &&
1060 "unexpected int value");
1062 ret = ec_config_dict_set(subconfig, "my_int2", ec_config_i64(4));
1063 testres |= EC_TEST_CHECK(ret == 0, "cannot set int");
1064 value = ec_config_dict_get(subconfig, "my_int2");
1065 testres |= EC_TEST_CHECK(
1067 value->type == EC_CONFIG_TYPE_INT64 &&
1069 "unexpected int value");
1071 testres |= EC_TEST_CHECK(
1072 ec_config_validate(subconfig, sch_dict) == 0,
1073 "cannot validate subconfig\n");
1075 ret = ec_config_list_add(list, subconfig);
1076 subconfig = NULL; /* freed */
1077 testres |= EC_TEST_CHECK(ret == 0, "cannot add in list");
1079 ret = ec_config_dict_set(config, "my_dictlist", list);
1081 testres |= EC_TEST_CHECK(ret == 0, "cannot set list");
1083 testres |= EC_TEST_CHECK(
1084 ec_config_validate(config, sch_baseconfig) == 0,
1085 "cannot validate config\n");
1087 list_ = ec_config_dict_get(config, "my_dictlist");
1088 for (config_ = ec_config_list_first(list_); config_ != NULL;
1089 config_ = ec_config_list_next(list_, config_)) {
1090 ec_config_dump(stdout, config_);
1093 ec_config_dump(stdout, config);
1095 config2 = ec_config_dup(config);
1096 testres |= EC_TEST_CHECK(config2 != NULL, "cannot duplicate config");
1097 testres |= EC_TEST_CHECK(
1098 ec_config_cmp(config, config2) == 0,
1099 "fail to compare config");
1100 ec_config_free(config2);
1103 /* remove the first element */
1104 ec_config_list_del(list_, ec_config_list_first(list_));
1105 testres |= EC_TEST_CHECK(
1106 ec_config_validate(config, sch_baseconfig) == 0,
1107 "cannot validate config\n");
1109 ec_config_dump(stdout, config);
1111 ec_config_free(list);
1112 ec_config_free(subconfig);
1113 ec_config_free(config);
1114 ec_keyval_free(dict);
1120 ec_config_free(list);
1121 ec_config_free(subconfig);
1122 ec_config_free(config);
1123 ec_config_free(config2);
1124 ec_keyval_free(dict);
1129 /* LCOV_EXCL_STOP */
1131 static struct ec_test ec_config_test = {
1133 .test = ec_config_testcase,
1136 EC_TEST_REGISTER(ec_config_test);