9 #include "solverdebug.h"
12 static struct resultflags2str {
15 } resultflags2str[] = {
16 { TESTCASE_RESULT_TRANSACTION, "transaction" },
17 { TESTCASE_RESULT_PROBLEMS, "problems" },
18 { TESTCASE_RESULT_ORPHANED, "orphaned" },
19 { TESTCASE_RESULT_RECOMMENDED, "recommended" },
20 { TESTCASE_RESULT_UNNEEDED, "unneeded" },
27 fprintf(ex ? stderr : stdout, "Usage: testsolv <testcase>\n");
32 main(int argc, char **argv)
50 while ((c = getopt(argc, argv, "vrhl:s:")) >= 0)
67 if ((p = strchr(optarg, ':')))
68 queue_push2(&solq, atoi(optarg), atoi(p + 1));
70 queue_push2(&solq, 1, atoi(optarg));
79 for (; optind < argc; optind++)
82 pool_setdebuglevel(pool, debuglevel);
84 fp = fopen(argv[optind], "r");
95 solv = testcase_read(pool, fp, argv[optind], &job, &result, &resultflags);
102 if (!multijob && !feof(fp))
106 printf("test %d:\n", multijob++);
110 selection_make(pool, &job, list, SELECTION_NAME|SELECTION_PROVIDES|SELECTION_FILELIST|SELECTION_CANON|SELECTION_DOTARCH|SELECTION_REL|SELECTION_GLOB|SELECTION_FLAT);
112 printf("No match\n");
118 selection_solvables(pool, &job, &q);
119 for (i = 0; i < q.count; i++)
120 printf(" - %s\n", testcase_solvid2str(pool, q.elements[i]));
124 else if (result || writeresult)
126 char *myresult, *resultdiff;
127 solver_solve(solv, &job);
129 resultflags = TESTCASE_RESULT_TRANSACTION | TESTCASE_RESULT_PROBLEMS;
130 myresult = testcase_solverresult(solv, resultflags);
142 for (i = 0; resultflags2str[i].str; i++)
143 if ((resultflags & resultflags2str[i].flag) != 0)
145 printf(p, resultflags2str[i].str);
148 printf(" <inline>\n");
152 const char *p2 = strchr(p, '\n');
153 p2 = p2 ? p2 + 1 : p + strlen(p);
154 printf("#>%.*s", (int)(p2 - p), p);
159 printf("%s", myresult);
164 resultdiff = testcase_resultdiff(result, myresult);
167 printf("Results differ:\n%s", resultdiff);
169 solv_free(resultdiff);
177 int pcnt = solver_solve(solv, &job);
178 if (pcnt && solq.count)
181 for (i = 0; i < solq.count; i += 2)
183 if (solq.elements[i] > 0 && solq.elements[i] <= pcnt)
184 if (solq.elements[i + 1] > 0 && solq.elements[i + 1] <= solver_solution_count(solv, solq.elements[i]))
186 printf("problem %d: taking solution %d\n", solq.elements[i], solq.elements[i + 1]);
187 solver_take_solution(solv, solq.elements[i], solq.elements[i + 1], &job);
192 pcnt = solver_solve(solv, &job);
196 int problem, solution, scnt;
197 printf("Found %d problems:\n", pcnt);
198 for (problem = 1; problem <= pcnt; problem++)
200 printf("Problem %d:\n", problem);
202 solver_printprobleminfo(solv, problem);
208 solver_findallproblemrules(solv, problem, &pq);
209 for (j = 0; j < pq.count; j++)
210 solver_printproblemruleinfo(solv, pq.elements[j]);
215 scnt = solver_solution_count(solv, problem);
216 for (solution = 1; solution <= scnt; solution++)
218 printf("Solution %d:\n", solution);
219 solver_printsolution(solv, problem, solution);
226 Transaction *trans = solver_create_transaction(solv);
227 printf("Transaction summary:\n\n");
228 transaction_print(trans);
229 transaction_free(trans);