From: Michael Schroeder Date: Wed, 4 Oct 2017 08:58:16 +0000 (+0200) Subject: Add --testcase option to example solver X-Git-Tag: 0.6.30~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9be637db07b34c491bd767f5d99daf7f5943523;p=thirdparty%2Flibsolv.git Add --testcase option to example solver --- diff --git a/examples/solv/solv.c b/examples/solv/solv.c index 615c83dd..5ee42979 100644 --- a/examples/solv/solv.c +++ b/examples/solv/solv.c @@ -36,6 +36,7 @@ #include "solver.h" #include "solverdebug.h" #include "transaction.h" +#include "testcase.h" #ifdef SUSE #include "repo_autopattern.h" #endif @@ -228,6 +229,7 @@ main(int argc, char **argv) int keyname_depstr = 0; int debuglevel = 0; int answer, acnt = 0; + char *testcase = 0; argc--; argv++; @@ -326,6 +328,12 @@ main(int argc, char **argv) argc -= 2; argv += 2; } + else if (argc > 2 && !strcmp(argv[1], "--testcase")) + { + testcase = argv[2]; + argc -= 2; + argv += 2; + } else break; } @@ -679,7 +687,15 @@ rerunsolver: Id problem, solution; int pcnt, scnt; - if (!solver_solve(solv, &job)) + pcnt = solver_solve(solv, &job); + if (testcase) + { + printf("Writing solver testcase:\n"); + if (!testcase_write(solv, testcase, TESTCASE_RESULT_TRANSACTION | TESTCASE_RESULT_PROBLEMS, 0, 0)) + printf("%s\n", pool_errstr(pool)); + testcase = 0; + } + if (!pcnt) break; pcnt = solver_problem_count(solv); printf("Found %d problems:\n", pcnt);