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 const struct ec_config_schema *
364 ec_config_schema_lookup(const struct ec_config_schema *schema,
369 for (i = 0; schema[i].type != EC_CONFIG_TYPE_NONE; i++) {
370 if (!strcmp(key, schema[i].key))
379 ec_config_schema_type(const struct ec_config_schema *schema_elt)
381 return schema_elt->type;
384 const struct ec_config_schema *
385 ec_config_schema_sub(const struct ec_config_schema *schema_elt)
387 return schema_elt->subschema;
391 ec_config_free(struct ec_config *value)
396 switch (value->type) {
397 case EC_CONFIG_TYPE_STRING:
398 ec_free(value->string);
400 case EC_CONFIG_TYPE_NODE:
401 ec_node_free(value->node);
403 case EC_CONFIG_TYPE_LIST:
404 while (!TAILQ_EMPTY(&value->list)) {
406 v = TAILQ_FIRST(&value->list);
407 TAILQ_REMOVE(&value->list, v, next);
411 case EC_CONFIG_TYPE_DICT:
412 ec_keyval_free(value->dict);
422 ec_config_list_cmp(const struct ec_config_list *list1,
423 const struct ec_config_list *list2)
425 const struct ec_config *v1, *v2;
427 for (v1 = TAILQ_FIRST(list1), v2 = TAILQ_FIRST(list2);
428 v1 != NULL && v2 != NULL;
429 v1 = TAILQ_NEXT(v1, next), v2 = TAILQ_NEXT(v2, next)) {
430 if (ec_config_cmp(v1, v2))
433 if (v1 != NULL || v2 != NULL)
439 /* XXX -> ec_keyval_cmp() */
441 ec_config_dict_cmp(const struct ec_keyval *d1,
442 const struct ec_keyval *d2)
444 const struct ec_config *v1, *v2;
445 struct ec_keyval_iter *iter = NULL;
448 if (ec_keyval_len(d1) != ec_keyval_len(d2))
451 for (iter = ec_keyval_iter(d1);
452 ec_keyval_iter_valid(iter);
453 ec_keyval_iter_next(iter)) {
454 key = ec_keyval_iter_get_key(iter);
455 v1 = ec_keyval_iter_get_val(iter);
456 v2 = ec_keyval_get(d2, key);
458 if (ec_config_cmp(v1, v2))
462 ec_keyval_iter_free(iter);
466 ec_keyval_iter_free(iter);
471 ec_config_cmp(const struct ec_config *value1,
472 const struct ec_config *value2)
474 if (value1 == NULL || value2 == NULL) {
479 if (value1->type != value2->type)
482 switch (value1->type) {
483 case EC_CONFIG_TYPE_BOOL:
484 if (value1->boolean == value2->boolean)
486 case EC_CONFIG_TYPE_INT64:
487 if (value1->i64 == value2->i64)
489 case EC_CONFIG_TYPE_UINT64:
490 if (value1->u64 == value2->u64)
492 case EC_CONFIG_TYPE_STRING:
493 if (!strcmp(value1->string, value2->string))
495 case EC_CONFIG_TYPE_NODE:
496 if (value1->node == value2->node)
498 case EC_CONFIG_TYPE_LIST:
499 return ec_config_list_cmp(&value1->list, &value2->list);
500 case EC_CONFIG_TYPE_DICT:
501 return ec_config_dict_cmp(value1->dict, value2->dict);
510 ec_config_list_validate(const struct ec_config_list *list,
511 const struct ec_config_schema *sch)
513 const struct ec_config *value;
515 TAILQ_FOREACH(value, list, next) {
516 if (value->type != sch->type) {
521 if (value->type == EC_CONFIG_TYPE_LIST) {
522 if (ec_config_list_validate(&value->list,
525 } else if (value->type == EC_CONFIG_TYPE_DICT) {
526 if (ec_config_dict_validate(value->dict,
536 ec_config_dict_validate(const struct ec_keyval *dict,
537 const struct ec_config_schema *schema)
539 const struct ec_config *value;
540 struct ec_keyval_iter *iter = NULL;
541 const struct ec_config_schema *sch;
544 for (iter = ec_keyval_iter(dict);
545 ec_keyval_iter_valid(iter);
546 ec_keyval_iter_next(iter)) {
548 key = ec_keyval_iter_get_key(iter);
549 value = ec_keyval_iter_get_val(iter);
550 sch = ec_config_schema_lookup(schema, key);
551 if (sch == NULL || sch->type != value->type) {
555 if (value->type == EC_CONFIG_TYPE_LIST) {
556 if (ec_config_list_validate(&value->list,
559 } else if (value->type == EC_CONFIG_TYPE_DICT) {
560 if (ec_config_dict_validate(value->dict,
566 ec_keyval_iter_free(iter);
570 ec_keyval_iter_free(iter);
575 ec_config_validate(const struct ec_config *dict,
576 const struct ec_config_schema *schema)
578 if (dict->type != EC_CONFIG_TYPE_DICT || schema == NULL) {
583 if (ec_config_dict_validate(dict->dict, schema) < 0)
593 ec_config_dict_get(const struct ec_config *config, const char *key)
595 if (config == NULL) {
600 if (config->type != EC_CONFIG_TYPE_DICT) {
605 return ec_keyval_get(config->dict, key);
609 ec_config_list_first(struct ec_config *list)
611 if (list == NULL || list->type != EC_CONFIG_TYPE_LIST) {
616 return TAILQ_FIRST(&list->list);
620 ec_config_list_next(struct ec_config *list, struct ec_config *config)
623 return TAILQ_NEXT(config, next);
626 /* value is consumed */
627 int ec_config_dict_set(struct ec_config *config, const char *key,
628 struct ec_config *value)
630 void (*free_cb)(struct ec_config *) = ec_config_free;
632 if (config == NULL || key == NULL || value == NULL) {
636 if (config->type != EC_CONFIG_TYPE_DICT) {
641 return ec_keyval_set(config->dict, key, value,
642 (void (*)(void *))free_cb);
645 ec_config_free(value);
649 int ec_config_dict_del(struct ec_config *config, const char *key)
651 if (config == NULL || key == NULL) {
655 if (config->type != EC_CONFIG_TYPE_DICT) {
660 return ec_keyval_del(config->dict, key);
663 /* value is consumed */
665 ec_config_list_add(struct ec_config *list,
666 struct ec_config *value)
668 if (list == NULL || list->type != EC_CONFIG_TYPE_LIST || value == NULL) {
673 TAILQ_INSERT_TAIL(&list->list, value, next);
678 ec_config_free(value);
682 int ec_config_list_del(struct ec_config *list, struct ec_config *config)
684 if (list == NULL || list->type != EC_CONFIG_TYPE_LIST) {
689 TAILQ_REMOVE(&list->list, config, next);
690 ec_config_free(config);
694 static struct ec_config *
695 ec_config_list_dup(const struct ec_config_list *list)
697 struct ec_config *dup = NULL, *v, *value;
699 dup = ec_config_list();
703 TAILQ_FOREACH(v, list, next) {
704 value = ec_config_dup(v);
707 if (ec_config_list_add(dup, value) < 0)
718 static struct ec_config *
719 ec_config_dict_dup(const struct ec_keyval *dict)
721 struct ec_config *dup = NULL, *value;
722 struct ec_keyval_iter *iter = NULL;
725 dup = ec_config_dict();
729 for (iter = ec_keyval_iter(dict);
730 ec_keyval_iter_valid(iter);
731 ec_keyval_iter_next(iter)) {
732 key = ec_keyval_iter_get_key(iter);
733 value = ec_config_dup(ec_keyval_iter_get_val(iter));
736 if (ec_config_dict_set(dup, key, value) < 0)
739 ec_keyval_iter_free(iter);
745 ec_keyval_iter_free(iter);
750 ec_config_dup(const struct ec_config *config)
752 if (config == NULL) {
757 switch (config->type) {
758 case EC_CONFIG_TYPE_BOOL:
759 return ec_config_bool(config->boolean);
760 case EC_CONFIG_TYPE_INT64:
761 return ec_config_i64(config->i64);
762 case EC_CONFIG_TYPE_UINT64:
763 return ec_config_u64(config->u64);
764 case EC_CONFIG_TYPE_STRING:
765 return ec_config_string(config->string);
766 case EC_CONFIG_TYPE_NODE:
767 return ec_config_node(ec_node_clone(config->node));
768 case EC_CONFIG_TYPE_LIST:
769 return ec_config_list_dup(&config->list);
770 case EC_CONFIG_TYPE_DICT:
771 return ec_config_dict_dup(config->dict);
781 ec_config_list_dump(FILE *out, const char *key,
782 const struct ec_config_list *list, size_t indent)
784 const struct ec_config *v;
786 fprintf(out, "%*s" "%s%s%stype=list\n", (int)indent * 4, "",
791 TAILQ_FOREACH(v, list, next) {
792 if (__ec_config_dump(out, NULL, v, indent + 1) < 0)
800 ec_config_dict_dump(FILE *out, const char *key, const struct ec_keyval *dict,
803 const struct ec_config *value;
804 struct ec_keyval_iter *iter;
807 fprintf(out, "%*s" "%s%s%stype=dict\n", (int)indent * 4, "",
812 for (iter = ec_keyval_iter(dict);
813 ec_keyval_iter_valid(iter);
814 ec_keyval_iter_next(iter)) {
815 k = ec_keyval_iter_get_key(iter);
816 value = ec_keyval_iter_get_val(iter);
817 if (__ec_config_dump(out, k, value, indent + 1) < 0)
820 ec_keyval_iter_free(iter);
824 ec_keyval_iter_free(iter);
829 __ec_config_dump(FILE *out, const char *key, const struct ec_config *value,
832 char *val_str = NULL;
834 switch (value->type) {
835 case EC_CONFIG_TYPE_BOOL:
837 ec_asprintf(&val_str, "true");
839 ec_asprintf(&val_str, "false");
841 case EC_CONFIG_TYPE_INT64:
842 ec_asprintf(&val_str, "%"PRIu64, value->u64);
844 case EC_CONFIG_TYPE_UINT64:
845 ec_asprintf(&val_str, "%"PRIi64, value->i64);
847 case EC_CONFIG_TYPE_STRING:
848 ec_asprintf(&val_str, "%s", value->string);
850 case EC_CONFIG_TYPE_NODE:
851 ec_asprintf(&val_str, "%p", value->node);
853 case EC_CONFIG_TYPE_LIST:
854 return ec_config_list_dump(out, key, &value->list, indent);
855 case EC_CONFIG_TYPE_DICT:
856 return ec_config_dict_dump(out, key, value->dict, indent);
862 /* errno is already set on error */
866 fprintf(out, "%*s" "%s%s%stype=%s val=%s\n", (int)indent * 4, "",
870 ec_config_type_str(value->type), val_str);
881 ec_config_dump(FILE *out, const struct ec_config *config)
883 fprintf(out, "------------------- config dump:\n");
885 if (config == NULL) {
886 fprintf(out, "no config\n");
890 if (__ec_config_dump(out, NULL, config, 0) < 0)
891 fprintf(out, "error while dumping\n");
894 /* LCOV_EXCL_START */
895 static const struct ec_config_schema sch_intlist_elt[] = {
897 .desc = "This is a description for int",
898 .type = EC_CONFIG_TYPE_INT64,
901 .type = EC_CONFIG_TYPE_NONE,
905 static const struct ec_config_schema sch_dict[] = {
908 .desc = "This is a description for int",
909 .type = EC_CONFIG_TYPE_INT64,
913 .desc = "This is a description for int2",
914 .type = EC_CONFIG_TYPE_INT64,
917 .type = EC_CONFIG_TYPE_NONE,
921 static const struct ec_config_schema sch_dictlist_elt[] = {
923 .desc = "This is a description for dict",
924 .type = EC_CONFIG_TYPE_DICT,
925 .subschema = sch_dict,
928 .type = EC_CONFIG_TYPE_NONE,
932 static const struct ec_config_schema sch_baseconfig[] = {
935 .desc = "This is a description for bool",
936 .type = EC_CONFIG_TYPE_BOOL,
940 .desc = "This is a description for int",
941 .type = EC_CONFIG_TYPE_INT64,
945 .desc = "This is a description for string",
946 .type = EC_CONFIG_TYPE_STRING,
950 .desc = "This is a description for node",
951 .type = EC_CONFIG_TYPE_NODE,
955 .desc = "This is a description for list",
956 .type = EC_CONFIG_TYPE_LIST,
957 .subschema = sch_intlist_elt,
960 .key = "my_dictlist",
961 .desc = "This is a description for list",
962 .type = EC_CONFIG_TYPE_LIST,
963 .subschema = sch_dictlist_elt,
966 .type = EC_CONFIG_TYPE_NONE,
970 static int ec_config_testcase(void)
972 struct ec_node *node = NULL;
973 struct ec_keyval *dict = NULL;
974 const struct ec_config *value = NULL;
975 struct ec_config *config = NULL, *config2 = NULL;
976 struct ec_config *list = NULL, *subconfig = NULL;
977 struct ec_config *list_, *config_;
981 testres |= EC_TEST_CHECK(ec_config_key_is_reserved("id"),
982 "'id' should be reserved");
983 testres |= EC_TEST_CHECK(!ec_config_key_is_reserved("foo"),
984 "'foo' should not be reserved");
986 node = ec_node("empty", EC_NO_ID);
990 if (ec_config_schema_validate(sch_baseconfig) < 0) {
991 EC_LOG(EC_LOG_ERR, "invalid config schema\n");
995 ec_config_schema_dump(stdout, sch_baseconfig);
997 config = ec_config_dict();
1001 ret = ec_config_dict_set(config, "my_bool", ec_config_bool(true));
1002 testres |= EC_TEST_CHECK(ret == 0, "cannot set boolean");
1003 value = ec_config_dict_get(config, "my_bool");
1004 testres |= EC_TEST_CHECK(
1006 value->type == EC_CONFIG_TYPE_BOOL &&
1007 value->boolean == true,
1008 "unexpected boolean value");
1010 ret = ec_config_dict_set(config, "my_int", ec_config_i64(1234));
1011 testres |= EC_TEST_CHECK(ret == 0, "cannot set int");
1012 value = ec_config_dict_get(config, "my_int");
1013 testres |= EC_TEST_CHECK(
1015 value->type == EC_CONFIG_TYPE_INT64 &&
1017 "unexpected int value");
1019 testres |= EC_TEST_CHECK(
1020 ec_config_validate(config, sch_baseconfig) == 0,
1021 "cannot validate config\n");
1023 ret = ec_config_dict_set(config, "my_string", ec_config_string("toto"));
1024 testres |= EC_TEST_CHECK(ret == 0, "cannot set string");
1025 value = ec_config_dict_get(config, "my_string");
1026 testres |= EC_TEST_CHECK(
1028 value->type == EC_CONFIG_TYPE_STRING &&
1029 !strcmp(value->string, "toto"),
1030 "unexpected string value");
1032 list = ec_config_list();
1036 subconfig = ec_config_dict();
1037 if (subconfig == NULL)
1040 ret = ec_config_dict_set(subconfig, "my_int", ec_config_i64(1));
1041 testres |= EC_TEST_CHECK(ret == 0, "cannot set int");
1042 value = ec_config_dict_get(subconfig, "my_int");
1043 testres |= EC_TEST_CHECK(
1045 value->type == EC_CONFIG_TYPE_INT64 &&
1047 "unexpected int value");
1049 ret = ec_config_dict_set(subconfig, "my_int2", ec_config_i64(2));
1050 testres |= EC_TEST_CHECK(ret == 0, "cannot set int");
1051 value = ec_config_dict_get(subconfig, "my_int2");
1052 testres |= EC_TEST_CHECK(
1054 value->type == EC_CONFIG_TYPE_INT64 &&
1056 "unexpected int value");
1058 testres |= EC_TEST_CHECK(
1059 ec_config_validate(subconfig, sch_dict) == 0,
1060 "cannot validate subconfig\n");
1062 ret = ec_config_list_add(list, subconfig);
1063 subconfig = NULL; /* freed */
1064 testres |= EC_TEST_CHECK(ret == 0, "cannot add in list");
1066 subconfig = ec_config_dict();
1067 if (subconfig == NULL)
1070 ret = ec_config_dict_set(subconfig, "my_int", ec_config_i64(3));
1071 testres |= EC_TEST_CHECK(ret == 0, "cannot set int");
1072 value = ec_config_dict_get(subconfig, "my_int");
1073 testres |= EC_TEST_CHECK(
1075 value->type == EC_CONFIG_TYPE_INT64 &&
1077 "unexpected int value");
1079 ret = ec_config_dict_set(subconfig, "my_int2", ec_config_i64(4));
1080 testres |= EC_TEST_CHECK(ret == 0, "cannot set int");
1081 value = ec_config_dict_get(subconfig, "my_int2");
1082 testres |= EC_TEST_CHECK(
1084 value->type == EC_CONFIG_TYPE_INT64 &&
1086 "unexpected int value");
1088 testres |= EC_TEST_CHECK(
1089 ec_config_validate(subconfig, sch_dict) == 0,
1090 "cannot validate subconfig\n");
1092 ret = ec_config_list_add(list, subconfig);
1093 subconfig = NULL; /* freed */
1094 testres |= EC_TEST_CHECK(ret == 0, "cannot add in list");
1096 ret = ec_config_dict_set(config, "my_dictlist", list);
1098 testres |= EC_TEST_CHECK(ret == 0, "cannot set list");
1100 testres |= EC_TEST_CHECK(
1101 ec_config_validate(config, sch_baseconfig) == 0,
1102 "cannot validate config\n");
1104 list_ = ec_config_dict_get(config, "my_dictlist");
1105 for (config_ = ec_config_list_first(list_); config_ != NULL;
1106 config_ = ec_config_list_next(list_, config_)) {
1107 ec_config_dump(stdout, config_);
1110 ec_config_dump(stdout, config);
1112 config2 = ec_config_dup(config);
1113 testres |= EC_TEST_CHECK(config2 != NULL, "cannot duplicate config");
1114 testres |= EC_TEST_CHECK(
1115 ec_config_cmp(config, config2) == 0,
1116 "fail to compare config");
1117 ec_config_free(config2);
1120 /* remove the first element */
1121 ec_config_list_del(list_, ec_config_list_first(list_));
1122 testres |= EC_TEST_CHECK(
1123 ec_config_validate(config, sch_baseconfig) == 0,
1124 "cannot validate config\n");
1126 ec_config_dump(stdout, config);
1128 ec_config_free(list);
1129 ec_config_free(subconfig);
1130 ec_config_free(config);
1131 ec_keyval_free(dict);
1137 ec_config_free(list);
1138 ec_config_free(subconfig);
1139 ec_config_free(config);
1140 ec_config_free(config2);
1141 ec_keyval_free(dict);
1146 /* LCOV_EXCL_STOP */
1148 static struct ec_test ec_config_test = {
1150 .test = ec_config_testcase,
1153 EC_TEST_REGISTER(ec_config_test);