+static struct reason2str {
+ Id reason;
+ const char *str;
+} reason2str[] = {
+ { SOLVER_REASON_UNRELATED, "unrelated" },
+ { SOLVER_REASON_UNIT_RULE, "unit" },
+ { SOLVER_REASON_KEEP_INSTALLED, "keep" },
+ { SOLVER_REASON_RESOLVE_JOB, "job" },
+ { SOLVER_REASON_UPDATE_INSTALLED, "update" },
+ { SOLVER_REASON_CLEANDEPS_ERASE, "cleandeps" },
+ { SOLVER_REASON_RESOLVE, "resolve" },
+ { SOLVER_REASON_WEAKDEP, "weakdep" },
+ { SOLVER_REASON_RESOLVE_ORPHAN, "orphan" },
+
+ { SOLVER_REASON_RECOMMENDED, "recommended" },
+ { SOLVER_REASON_SUPPLEMENTED, "supplemented" },
+ { 0, 0 }
+};
+
+static const char *
+testcase_reason2str(Id reason)
+{
+ int i;
+ for (i = 0; reason2str[i].str; i++)
+ if (reason == reason2str[i].reason)
+ return reason2str[i].str;
+ return "?";
+}
+
+static struct rclass2str {
+ Id rclass;
+ const char *str;
+} rclass2str[] = {
+ { SOLVER_RULE_PKG, "pkg" },
+ { SOLVER_RULE_UPDATE, "update" },
+ { SOLVER_RULE_FEATURE, "feature" },
+ { SOLVER_RULE_JOB, "job" },
+ { SOLVER_RULE_DISTUPGRADE, "distupgrade" },
+ { SOLVER_RULE_INFARCH, "infarch" },
+ { SOLVER_RULE_CHOICE, "choice" },
+ { SOLVER_RULE_LEARNT, "learnt" },
+ { SOLVER_RULE_BEST, "best" },
+ { SOLVER_RULE_YUMOBS, "yumobs" },
+ { 0, 0 }
+};
+
+static const char *
+testcase_rclass2str(Id rclass)
+{
+ int i;
+ for (i = 0; rclass2str[i].str; i++)
+ if (rclass == rclass2str[i].rclass)
+ return rclass2str[i].str;
+ return "unknown";
+}
+
+static int
+dump_genid(Pool *pool, Strqueue *sq, Id id, int cnt)
+{
+ struct oplist *op;
+ char cntbuf[20];
+ const char *s;
+
+ if (ISRELDEP(id))
+ {
+ Reldep *rd = GETRELDEP(pool, id);
+ for (op = oplist; op->flags; op++)
+ if (rd->flags == op->flags)
+ break;
+ cnt = dump_genid(pool, sq, rd->name, cnt);
+ cnt = dump_genid(pool, sq, rd->evr, cnt);
+ sprintf(cntbuf, "genid %2d: genid ", cnt++);
+ s = pool_tmpjoin(pool, cntbuf, "op ", op->flags ? op->opname : "unknown");
+ }
+ else
+ {
+ sprintf(cntbuf, "genid %2d: genid ", cnt++);
+ s = pool_tmpjoin(pool, cntbuf, id ? "lit " : "null", id ? pool_id2str(pool, id) : 0);
+ }
+ strqueue_push(sq, s);
+ return cnt;
+}
+