Skip to content

Commit 0077ef2

Browse files
committed
testcase_read: error out if repos are added or the system is changed too late
We must not add new solvables after the considered map was created, the solver was created, or jobs were added. We may not changed the system after jobs have been added. (Jobs may point inside the whatproviedes array, so we must not invalidate this area.)
1 parent 926244b commit 0077ef2

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

ext/testcase.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,6 +1991,7 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
19911991
Id *genid = 0;
19921992
int ngenid = 0;
19931993
Queue autoinstq;
1994+
int oldjobsize = job ? job->count : 0;
19941995

19951996
if (resultp)
19961997
*resultp = 0;
@@ -2065,6 +2066,21 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
20652066
int prio, subprio;
20662067
const char *rdata;
20672068

2069+
if (pool->considered)
2070+
{
2071+
pool_error(pool, 0, "testcase_read: cannot add repos after packages were disabled");
2072+
continue;
2073+
}
2074+
if (solv)
2075+
{
2076+
pool_error(pool, 0, "testcase_read: cannot add repos after the solver was created");
2077+
continue;
2078+
}
2079+
if (job && job->count != oldjobsize)
2080+
{
2081+
pool_error(pool, 0, "testcase_read: cannot add repos after jobs have been created");
2082+
continue;
2083+
}
20682084
prepared = 0;
20692085
if (!poolflagsreset)
20702086
{
@@ -2125,6 +2141,11 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
21252141
int i;
21262142

21272143
/* must set the disttype before the arch */
2144+
if (job && job->count != oldjobsize)
2145+
{
2146+
pool_error(pool, 0, "testcase_read: cannot change the system after jobs have been created");
2147+
continue;
2148+
}
21282149
prepared = 0;
21292150
if (strcmp(pieces[2], "*") != 0)
21302151
{

0 commit comments

Comments
 (0)