int ec_test_check_complete(struct ec_node *tk, ...)
{
struct ec_completed *c = NULL;
- struct ec_completed_item *item;
struct ec_strvec *vec = NULL;
- const char *s, *expected;
+ const char *s;
int ret = 0;
unsigned int count = 0;
va_list ap;
goto out;
}
+ /* for each expected completion, check it is there */
for (s = va_arg(ap, const char *);
s != EC_NODE_ENDLIST;
s = va_arg(ap, const char *)) {
+ struct ec_completed_iter *iter;
+ const struct ec_completed_item *item;
+
if (s == NULL) {
ret = -1;
goto out;
}
count++;
- TAILQ_FOREACH(item, &c->items, next) {
- /* only check matching completions */
- if (item->add != NULL && strcmp(item->add, s) == 0)
+
+ /* only check matching completions */
+ iter = ec_completed_iter(c, EC_MATCH);
+ while ((item = ec_completed_iter_next(iter)) != NULL) {
+ if (item->str != NULL && strcmp(item->str, s) == 0)
break;
}
"completion <%s> not in list\n", s);
ret = -1;
}
+ ec_completed_iter_free(iter);
}
+ /* check if we have more completions (or less) than expected */
if (count != ec_completed_count(c, EC_MATCH)) {
ec_log(EC_LOG_ERR,
"nb_completion (%d) does not match (%d)\n",
count, ec_completed_count(c, EC_MATCH));
ec_completed_dump(stdout, c);
ret = -1;
- }
-
-
- expected = va_arg(ap, const char *);
- s = ec_completed_smallest_start(c);
- if (strcmp(s, expected)) {
- ret = -1;
- ec_log(EC_LOG_ERR,
- "should complete with <%s> but completes with <%s>\n",
- expected, s);
- }
+ } else
+ ec_completed_dump(stdout, c); //XXX
out:
ec_strvec_free(vec);