mirror of
https://github.com/openSUSE/libsolv.git
synced 2026-02-05 12:45:46 +01:00
Add solver reuse testcase
This commit is contained in:
@@ -2272,7 +2272,7 @@ testcase_write_mangled(Solver *solv, const char *dir, int resultflags, const cha
|
||||
strqueue_push(&sq, cmd);
|
||||
}
|
||||
|
||||
if (resultflags)
|
||||
if ((resultflags & ~TESTCASE_RESULT_REUSE_SOLVER) != 0)
|
||||
{
|
||||
char *result;
|
||||
cmd = 0;
|
||||
@@ -2519,6 +2519,10 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
|
||||
int ngenid = 0;
|
||||
Queue autoinstq;
|
||||
|
||||
if (resultp)
|
||||
*resultp = 0;
|
||||
if (resultflagsp)
|
||||
*resultflagsp = 0;
|
||||
if (!fp && !(fp = fopen(testcase, "r")))
|
||||
{
|
||||
pool_debug(pool, SOLV_ERROR, "testcase_read: could not open '%s'\n", testcase);
|
||||
@@ -2799,8 +2803,10 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
|
||||
if (resultflagsp)
|
||||
*resultflagsp = resultflags;
|
||||
}
|
||||
else if (!strcmp(pieces[0], "nextjob") && npieces == 1)
|
||||
else if (!strcmp(pieces[0], "nextjob"))
|
||||
{
|
||||
if (npieces == 2 && resultflagsp && !strcmp(pieces[1], "reusesolver"))
|
||||
*resultflagsp |= TESTCASE_RESULT_REUSE_SOLVER;
|
||||
break;
|
||||
}
|
||||
else if (!strcmp(pieces[0], "disable") && npieces == 3)
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
#define TESTCASE_RESULT_GENID (1 << 7)
|
||||
#define TESTCASE_RESULT_REASON (1 << 8)
|
||||
|
||||
/* reuse solver hack, testsolv use only */
|
||||
#define TESTCASE_RESULT_REUSE_SOLVER (1 << 31)
|
||||
|
||||
extern Id testcase_str2dep(Pool *pool, const char *s);
|
||||
extern const char *testcase_dep2str(Pool *pool, Id id);
|
||||
extern const char *testcase_repoid2str(Pool *pool, Id repoid);
|
||||
|
||||
20
test/testcases/sat/reuse.t
Normal file
20
test/testcases/sat/reuse.t
Normal file
@@ -0,0 +1,20 @@
|
||||
repo system 0 testtags <inline>
|
||||
#>=Pkg: X 1 1 x86_64
|
||||
repo available 0 testtags <inline>
|
||||
#>=Pkg: A 1 1 x86_64
|
||||
#>=Req: X
|
||||
#>=Pkg: B 1 1 x86_64
|
||||
job install name A
|
||||
result transaction,problems,rules <inline>
|
||||
#>install A-1-1.x86_64@available
|
||||
#>install X-1-1.x86_64@system
|
||||
#>rule job 300db6ce502dde94261e267a8c535441 A-1-1.x86_64@available
|
||||
#>rule pkg 11c27e407a56aad27bd6b3eadc17374b X-1-1.x86_64@system
|
||||
#>rule pkg 11c27e407a56aad27bd6b3eadc17374b -A-1-1.x86_64@available
|
||||
nextjob reusesolver
|
||||
job install name B
|
||||
result transaction,problems,rules <inline>
|
||||
#>install B-1-1.x86_64@available
|
||||
#>rule job ad168c1819736b8aa6f507ab075b3494 B-1-1.x86_64@available
|
||||
#>rule pkg 11c27e407a56aad27bd6b3eadc17374b X-1-1.x86_64@system
|
||||
#>rule pkg 11c27e407a56aad27bd6b3eadc17374b -A-1-1.x86_64@available
|
||||
@@ -68,7 +68,7 @@ main(int argc, char **argv)
|
||||
Pool *pool;
|
||||
Queue job;
|
||||
Queue solq;
|
||||
Solver *solv;
|
||||
Solver *solv, *reusesolv = 0;
|
||||
char *result = 0;
|
||||
int resultflags = 0;
|
||||
int debuglevel = 0;
|
||||
@@ -140,7 +140,12 @@ main(int argc, char **argv)
|
||||
pool_free(pool);
|
||||
exit(resultflags == 77 ? 77 : 1);
|
||||
}
|
||||
|
||||
if (reusesolv)
|
||||
{
|
||||
solver_free(solv);
|
||||
solv = reusesolv;
|
||||
reusesolv = 0;
|
||||
}
|
||||
if (!multijob && !feof(fp))
|
||||
multijob = 1;
|
||||
|
||||
@@ -179,8 +184,8 @@ main(int argc, char **argv)
|
||||
solver_solve(solv, &job);
|
||||
solv->solution_callback = 0;
|
||||
solv->solution_callback_data = 0;
|
||||
if (!resultflags)
|
||||
resultflags = TESTCASE_RESULT_TRANSACTION | TESTCASE_RESULT_PROBLEMS;
|
||||
if ((resultflags & ~TESTCASE_RESULT_REUSE_SOLVER) == 0)
|
||||
resultflags |= TESTCASE_RESULT_TRANSACTION | TESTCASE_RESULT_PROBLEMS;
|
||||
myresult = testcase_solverresult(solv, resultflags);
|
||||
if (rescallback && reportsolutiondata.result)
|
||||
{
|
||||
@@ -292,8 +297,13 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
queue_free(&job);
|
||||
solver_free(solv);
|
||||
if ((resultflags & TESTCASE_RESULT_REUSE_SOLVER) != 0 && !feof(fp))
|
||||
reusesolv = solv;
|
||||
else
|
||||
solver_free(solv);
|
||||
}
|
||||
if (reusesolv)
|
||||
solver_free(reusesolv);
|
||||
pool_free(pool);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user