8 #include "solverdebug.h"
11 static struct resultflags2str {
14 } resultflags2str[] = {
15 { TESTCASE_RESULT_TRANSACTION, "transaction" },
16 { TESTCASE_RESULT_PROBLEMS, "problems" },
17 { TESTCASE_RESULT_ORPHANED, "orphaned" },
18 { TESTCASE_RESULT_RECOMMENDED, "recommended" },
19 { TESTCASE_RESULT_UNNEEDED, "unneeded" },
26 fprintf(ex ? stderr : stdout, "Usage: testsolv <testcase>\n");
31 main(int argc, char **argv)
45 while ((c = getopt(argc, argv, "vrh")) >= 0)
65 for (; optind < argc; optind++)
68 pool_setdebuglevel(pool, debuglevel);
70 fp = fopen(argv[optind], "r");
81 solv = testcase_read(pool, fp, argv[optind], &job, &result, &resultflags);
88 if (!multijob && !feof(fp))
92 printf("test %d:\n", multijob++);
93 if (result || writeresult)
95 char *myresult, *resultdiff;
96 solver_solve(solv, &job);
98 resultflags = TESTCASE_RESULT_TRANSACTION | TESTCASE_RESULT_PROBLEMS;
99 myresult = testcase_solverresult(solv, resultflags);
111 for (i = 0; resultflags2str[i].str; i++)
112 if ((resultflags & resultflags2str[i].flag) != 0)
114 printf(p, resultflags2str[i].str);
117 printf(" <inline>\n");
121 const char *p2 = strchr(p, '\n');
122 p2 = p2 ? p2 + 1 : p + strlen(p);
123 printf("#>%.*s", (int)(p2 - p), p);
128 printf("%s", myresult);
133 resultdiff = testcase_resultdiff(result, myresult);
136 printf("Results differ:\n%s", resultdiff);
138 solv_free(resultdiff);
146 if (solver_solve(solv, &job))
148 int problem, solution, pcnt, scnt;
149 pcnt = solver_problem_count(solv);
150 printf("Found %d problems:\n", pcnt);
151 for (problem = 1; problem <= pcnt; problem++)
153 printf("Problem %d:\n", problem);
154 solver_printprobleminfo(solv, problem);
156 scnt = solver_solution_count(solv, problem);
157 for (solution = 1; solution <= scnt; solution++)
159 printf("Solution %d:\n", solution);
160 solver_printsolution(solv, problem, solution);
167 Transaction *trans = solver_create_transaction(solv);
168 printf("Transaction summary:\n\n");
169 transaction_print(trans);
170 transaction_free(trans);