2 * Copyright (c) 2012, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
19 #include "poolvendor.h"
21 #include "repo_solv.h"
23 #include "solverdebug.h"
26 #include "solv_xfopen.h"
29 #include "tools_util.h"
31 static struct job2str {
35 { SOLVER_NOOP, "noop" },
36 { SOLVER_INSTALL, "install" },
37 { SOLVER_ERASE, "erase" },
38 { SOLVER_UPDATE, "update" },
39 { SOLVER_WEAKENDEPS, "weakendeps" },
40 { SOLVER_NOOBSOLETES, "noobsoletes" },
41 { SOLVER_LOCK, "lock" },
42 { SOLVER_DISTUPGRADE, "distupgrade" },
43 { SOLVER_VERIFY, "verify" },
44 { SOLVER_DROP_ORPHANED, "droporphaned" },
45 { SOLVER_USERINSTALLED, "userinstalled" },
49 static struct jobflags2str {
53 { SOLVER_WEAK, "weak" },
54 { SOLVER_ESSENTIAL, "essential" },
55 { SOLVER_CLEANDEPS, "cleandeps" },
56 { SOLVER_ORUPDATE, "orupdate" },
57 { SOLVER_FORCEBEST, "forcebest" },
58 { SOLVER_SETEV, "setev" },
59 { SOLVER_SETEVR, "setevr" },
60 { SOLVER_SETARCH, "setarch" },
61 { SOLVER_SETVENDOR, "setvendor" },
62 { SOLVER_SETREPO, "setrepo" },
63 { SOLVER_NOAUTOSET, "noautoset" },
67 static struct resultflags2str {
70 } resultflags2str[] = {
71 { TESTCASE_RESULT_TRANSACTION, "transaction" },
72 { TESTCASE_RESULT_PROBLEMS, "problems" },
73 { TESTCASE_RESULT_ORPHANED, "orphaned" },
74 { TESTCASE_RESULT_RECOMMENDED, "recommended" },
75 { TESTCASE_RESULT_UNNEEDED, "unneeded" },
79 static struct solverflags2str {
83 } solverflags2str[] = {
84 { SOLVER_FLAG_ALLOW_DOWNGRADE, "allowdowngrade", 0 },
85 { SOLVER_FLAG_ALLOW_NAMECHANGE, "allownamechange", 1 },
86 { SOLVER_FLAG_ALLOW_ARCHCHANGE, "allowarchchange", 0 },
87 { SOLVER_FLAG_ALLOW_VENDORCHANGE, "allowvendorchange", 0 },
88 { SOLVER_FLAG_ALLOW_UNINSTALL, "allowuninstall", 0 },
89 { SOLVER_FLAG_NO_UPDATEPROVIDE, "noupdateprovide", 0 },
90 { SOLVER_FLAG_SPLITPROVIDES, "splitprovides", 0 },
91 { SOLVER_FLAG_IGNORE_RECOMMENDED, "ignorerecommended", 0 },
92 { SOLVER_FLAG_ADD_ALREADY_RECOMMENDED, "addalreadyrecommended", 0 },
93 { SOLVER_FLAG_NO_INFARCHCHECK, "noinfarchcheck", 0 },
94 { SOLVER_FLAG_KEEP_EXPLICIT_OBSOLETES, "keepexplicitobsoletes", 0 },
98 static struct poolflags2str {
102 } poolflags2str[] = {
103 { POOL_FLAG_PROMOTEEPOCH, "promoteepoch", 0 },
104 { POOL_FLAG_FORBIDSELFCONFLICTS, "forbidselfconflicts", 0 },
105 { POOL_FLAG_OBSOLETEUSESPROVIDES, "obsoleteusesprovides", 0 },
106 { POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES, "implicitobsoleteusesprovides", 0 },
107 { POOL_FLAG_OBSOLETEUSESCOLORS, "obsoleteusescolors", 0 },
108 { POOL_FLAG_NOINSTALLEDOBSOLETES, "noinstalledobsoletes", 0 },
109 { POOL_FLAG_HAVEDISTEPOCH, "havedistepoch", 0 },
113 static struct disttype2str {
117 { DISTTYPE_RPM, "rpm" },
118 { DISTTYPE_DEB, "deb" },
119 { DISTTYPE_ARCH, "arch" },
123 typedef struct strqueue {
128 #define STRQUEUE_BLOCK 63
131 strqueue_init(Strqueue *q)
138 strqueue_free(Strqueue *q)
141 for (i = 0; i < q->nstr; i++)
142 solv_free(q->str[i]);
143 q->str = solv_free(q->str);
148 strqueue_push(Strqueue *q, const char *s)
150 q->str = solv_extend(q->str, q->nstr, 1, sizeof(*q->str), STRQUEUE_BLOCK);
151 q->str[q->nstr++] = solv_strdup(s);
155 strqueue_pushjoin(Strqueue *q, const char *s1, const char *s2, const char *s3)
157 q->str = solv_extend(q->str, q->nstr, 1, sizeof(*q->str), STRQUEUE_BLOCK);
158 q->str[q->nstr++] = solv_dupjoin(s1, s2, s3);
162 strqueue_sort_cmp(const void *ap, const void *bp, void *dp)
164 const char *a = *(const char **)ap;
165 const char *b = *(const char **)bp;
166 return strcmp(a ? a : "", b ? b : "");
170 strqueue_sort(Strqueue *q)
173 solv_sort(q->str, q->nstr, sizeof(*q->str), strqueue_sort_cmp, 0);
177 strqueue_sort_u(Strqueue *q)
181 for (i = j = 0; i < q->nstr; i++)
182 if (!j || strqueue_sort_cmp(q->str + i, q->str + j - 1, 0) != 0)
183 q->str[j++] = q->str[i];
188 strqueue_join(Strqueue *q)
192 for (i = 0; i < q->nstr; i++)
194 l += strlen(q->str[i]) + 1;
195 l++; /* trailing \0 */
198 for (i = 0; i < q->nstr; i++)
201 strcpy(rp, q->str[i]);
210 strqueue_split(Strqueue *q, const char *s)
215 while ((p = strchr(s, '\n')) != 0)
217 q->str = solv_extend(q->str, q->nstr, 1, sizeof(*q->str), STRQUEUE_BLOCK);
218 q->str[q->nstr] = solv_malloc(p - s + 1);
220 memcpy(q->str[q->nstr], s, p - s);
221 q->str[q->nstr][p - s] = 0;
230 strqueue_diff(Strqueue *sq1, Strqueue *sq2, Strqueue *osq)
233 while (i < sq1->nstr && j < sq2->nstr)
235 int r = strqueue_sort_cmp(sq1->str + i, sq2->str + j, 0);
239 strqueue_pushjoin(osq, "-", sq1->str[i++], 0);
241 strqueue_pushjoin(osq, "+", sq2->str[j++], 0);
243 while (i < sq1->nstr)
244 strqueue_pushjoin(osq, "-", sq1->str[i++], 0);
245 while (j < sq2->nstr)
246 strqueue_pushjoin(osq, "+", sq2->str[j++], 0);
250 pool_isknownarch(Pool *pool, Id id)
252 if (!id || id == ID_EMPTY)
254 if (id == ARCH_SRC || id == ARCH_NOSRC || id == ARCH_NOARCH)
256 if (!pool->id2arch || (id > pool->lastarch || !pool->id2arch[id]))
262 testcase_str2dep(Pool *pool, char *s)
268 if ((n = strchr(s, '|')) != 0)
270 id = testcase_str2dep(pool, n + 1);
272 id = pool_rel2id(pool, testcase_str2dep(pool, s), id, REL_OR, 1);
276 while (*s == ' ' || *s == '\t')
279 while (*s && *s != ' ' && *s != '\t' && *s != '<' && *s != '=' && *s != '>')
283 while (*s && *s != ')')
289 if ((a = strchr(n, '.')) != 0 && a + 1 < s && s[-1] != ')')
291 Id archid = pool_strn2id(pool, a + 1, s - (a + 1), 0);
292 if (pool_isknownarch(pool, archid))
294 id = pool_strn2id(pool, n, a - n, 1);
295 id = pool_rel2id(pool, id, archid, REL_ARCH, 1);
298 id = pool_strn2id(pool, n, s - n, 1);
301 id = pool_strn2id(pool, n, s - n, 1);
304 while (*s == ' ' || *s == '\t')
320 while (*s == ' ' || *s == '\t')
323 while (*s && *s != ' ' && *s != '\t')
325 return pool_rel2id(pool, id, pool_strn2id(pool, n, s - n, 1), flags, 1);
329 testcase_repoid2str(Pool *pool, Id repoid)
331 Repo *repo = pool_id2repo(pool, repoid);
334 char *r = pool_tmpjoin(pool, repo->name, 0, 0);
336 for (rp = r; *rp; rp++)
337 if (*rp == ' ' || *rp == '\t')
344 sprintf(buf, "#%d", repoid);
345 return pool_tmpjoin(pool, buf, 0, 0);
350 testcase_solvid2str(Pool *pool, Id p)
352 Solvable *s = pool->solvables + p;
353 const char *n, *e, *a;
356 if (p == SYSTEMSOLVABLE)
358 n = pool_id2str(pool, s->name);
359 e = pool_id2str(pool, s->evr);
360 a = pool_id2str(pool, s->arch);
361 str = pool_alloctmpspace(pool, strlen(n) + strlen(e) + strlen(a) + 3);
362 sprintf(str, "%s-%s.%s", n, e, a);
364 return pool_tmpappend(pool, str, "@", 0);
368 char *str2 = pool_tmpappend(pool, str, "@", s->repo->name);
370 if (str2[l] == ' ' || str2[l] == '\t')
374 sprintf(buf, "@#%d", s->repo->repoid);
375 return pool_tmpappend(pool, str, buf, 0);
379 testcase_str2repo(Pool *pool, const char *str)
383 if (str[0] == '#' && (str[1] >= '0' && str[1] <= '9'))
387 for (j = 1; str[j] >= '0' && str[j] <= '9'; j++)
388 repoid = repoid * 10 + (str[j] - '0');
389 if (!str[j] && repoid > 0 && repoid < pool->nrepos)
390 repo = pool_id2repo(pool, repoid);
394 FOR_REPOS(repoid, repo)
399 l = strlen(repo->name);
400 for (i = 0; i < l; i++)
402 int c = repo->name[i];
403 if (c == ' ' || c == '\t')
408 if (i == l && !str[l])
411 if (repoid >= pool->nrepos)
418 testcase_str2solvid(Pool *pool, const char *str)
420 int i, l = strlen(str);
427 if (*str == '@' && !strcmp(str, "@SYSTEM"))
428 return SYSTEMSOLVABLE;
430 for (i = l - 1; i >= 0; i--)
431 if (str[i] == '@' && (repo = testcase_str2repo(pool, str + i + 1)) != 0)
436 /* now find the arch (if present) */
438 for (i = repostart - 1; i > 0; i--)
441 arch = pool_strn2id(pool, str + i + 1, repostart - (i + 1), 0);
446 /* now find the name */
447 for (i = repostart - 1; i > 0; i--)
451 Id nid, evrid, p, pp;
452 nid = pool_strn2id(pool, str, i, 0);
455 evrid = pool_strn2id(pool, str + i + 1, repostart - (i + 1), 0);
458 FOR_PROVIDES(p, pp, nid)
460 Solvable *s = pool->solvables + p;
461 if (s->name != nid || s->evr != evrid)
463 if (repo && s->repo != repo)
465 if (arch && s->arch != arch)
475 testcase_job2str(Pool *pool, Id how, Id what)
482 Id select = how & SOLVER_SELECTMASK;
484 for (i = 0; job2str[i].str; i++)
485 if ((how & SOLVER_JOBMASK) == job2str[i].job)
487 jobstr = job2str[i].str ? job2str[i].str : "unknown";
488 if (select == SOLVER_SOLVABLE)
491 pkgstr = testcase_solvid2str(pool, what);
493 else if (select == SOLVER_SOLVABLE_NAME)
496 pkgstr = pool_dep2str(pool, what);
498 else if (select == SOLVER_SOLVABLE_PROVIDES)
500 selstr = " provides ";
501 pkgstr = pool_dep2str(pool, what);
503 else if (select == SOLVER_SOLVABLE_ONE_OF)
508 while ((p = pool->whatprovidesdata[what++]) != 0)
510 const char *s = testcase_solvid2str(pool, p);
513 pkgstr = pool_tmpappend(pool, pkgstr, " ", s);
514 pool_freetmpspace(pool, s);
522 else if (select == SOLVER_SOLVABLE_REPO)
524 Repo *repo = pool_id2repo(pool, what);
529 sprintf(buf, "#%d", repo->repoid);
530 pkgstr = pool_tmpjoin(pool, buf, 0, 0);
533 pkgstr = pool_tmpjoin(pool, repo->name, 0, 0);
535 else if (select == SOLVER_SOLVABLE_ALL)
542 selstr = " unknown ";
545 ret = pool_tmpjoin(pool, jobstr, selstr, pkgstr);
547 ret = pool_tmpappend(pool, ret, " ", 0);
548 for (i = 0; jobflags2str[i].str; i++)
549 if ((how & jobflags2str[i].flag) != 0)
550 ret = pool_tmpappend(pool, ret, ",", jobflags2str[i].str);
556 ret = pool_tmpappend(pool, ret, "]", 0);
562 testcase_str2job(Pool *pool, const char *str, Id *whatp)
572 /* so we can patch it */
573 s = pool_tmpjoin(pool, str, 0, 0);
574 /* split it in pieces */
577 while (*s == ' ' || *s == '\t')
581 pieces = solv_extend(pieces, npieces, 1, sizeof(*pieces), 7);
582 pieces[npieces++] = s;
583 while (*s && *s != ' ' && *s != '\t')
590 pool_debug(pool, SOLV_ERROR, "str2job: bad line '%s'\n", str);
595 for (i = 0; job2str[i].str; i++)
596 if (!strcmp(pieces[0], job2str[i].str))
600 pool_debug(pool, SOLV_ERROR, "str2job: unknown job '%s'\n", str);
604 job = job2str[i].job;
607 char *flags = pieces[npieces - 1];
609 if (*flags == '[' && flags[strlen(flags) - 1] == ']')
613 flags[strlen(flags) - 1] = ',';
616 for (nf = flags; *nf != ','; nf++)
619 for (i = 0; jobflags2str[i].str; i++)
620 if (!strcmp(flags, jobflags2str[i].str))
622 if (!jobflags2str[i].str)
624 pool_debug(pool, SOLV_ERROR, "str2job: unknown jobflags in '%s'\n", str);
628 job |= jobflags2str[i].flag;
633 if (!strcmp(pieces[1], "pkg"))
637 pool_debug(pool, SOLV_ERROR, "str2job: bad pkg selector in '%s'\n", str);
641 job |= SOLVER_SOLVABLE;
642 what = testcase_str2solvid(pool, pieces[2]);
645 pool_debug(pool, SOLV_ERROR, "str2job: unknown package '%s'\n", pieces[2]);
650 else if (!strcmp(pieces[1], "name") || !strcmp(pieces[1], "provides"))
652 /* join em again for dep2str... */
654 for (sp = pieces[2]; sp < pieces[npieces - 1]; sp++)
657 what = testcase_str2dep(pool, pieces[2]);
658 if (pieces[1][0] == 'n')
659 job |= SOLVER_SOLVABLE_NAME;
661 job |= SOLVER_SOLVABLE_PROVIDES;
663 else if (!strcmp(pieces[1], "oneof"))
666 job |= SOLVER_SOLVABLE_ONE_OF;
668 if (npieces > 3 && strcmp(pieces[2], "nothing") != 0)
670 for (i = 2; i < npieces; i++)
672 Id p = testcase_str2solvid(pool, pieces[i]);
675 pool_debug(pool, SOLV_ERROR, "str2job: unknown package '%s'\n", pieces[i]);
683 what = pool_queuetowhatprovides(pool, &q);
686 else if (!strcmp(pieces[1], "repo"))
691 pool_debug(pool, SOLV_ERROR, "str2job: bad line '%s'\n", str);
695 repo = testcase_str2repo(pool, pieces[2]);
698 pool_debug(pool, SOLV_ERROR, "str2job: unknown repo '%s'\n", pieces[2]);
702 job |= SOLVER_SOLVABLE_REPO;
705 else if (!strcmp(pieces[1], "all"))
707 if (npieces != 3 && strcmp(pieces[2], "packages") != 0)
709 pool_debug(pool, SOLV_ERROR, "str2job: bad line '%s'\n", str);
713 job |= SOLVER_SOLVABLE_ALL;
718 pool_debug(pool, SOLV_ERROR, "str2job: unknown selection in '%s'\n", str);
728 writedeps(Repo *repo, FILE *fp, const char *tag, Id key, Solvable *s, Offset off)
730 Pool *pool = repo->pool;
737 dp = repo->idarraydata + off;
739 while ((id = *dp++) != 0)
741 if (key == SOLVABLE_REQUIRES && id == SOLVABLE_PREREQMARKER)
744 fprintf(fp, "-%s\n", tag);
749 if (key == SOLVABLE_PROVIDES && id == SOLVABLE_FILEMARKER)
754 idstr = pool_dep2str(pool, id);
757 Reldep *rd = GETRELDEP(pool, id);
758 if (key == SOLVABLE_CONFLICTS && rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_OTHERPROVIDERS)
760 if (!strncmp(idstr, "namespace:", 10))
763 if (key == SOLVABLE_SUPPLEMENTS)
765 if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_FILESYSTEM)
767 if (!strncmp(idstr, "namespace:", 10))
770 else if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_MODALIAS)
772 if (!strncmp(idstr, "namespace:", 10))
775 else if (rd->flags == REL_AND)
777 /* either packageand chain or modalias */
779 if (ISRELDEP(rd->evr))
781 Reldep *mrd = GETRELDEP(pool, rd->evr);
782 if (mrd->flags == REL_NAMESPACE && mrd->name == NAMESPACE_MODALIAS)
784 idstr = pool_tmpjoin(pool, "modalias(", pool_dep2str(pool, rd->name), ":");
785 idstr = pool_tmpappend(pool, idstr, pool_dep2str(pool, mrd->evr), ")");
787 else if (mrd->flags >= 8)
792 /* must be and chain */
793 idstr = pool_dep2str(pool, rd->evr);
799 rd = GETRELDEP(pool, id);
800 if (rd->flags != REL_AND)
802 idstr = pool_tmpjoin(pool, pool_dep2str(pool, rd->evr), ":", idstr);
804 idstr = pool_tmpjoin(pool, pool_dep2str(pool, id), ":", idstr);
805 idstr = pool_tmpjoin(pool, "packageand(", idstr, ")");
808 else if (rd->flags >= 8)
814 fprintf(fp, "+%s\n", tag);
817 fprintf(fp, "%s\n", idstr);
819 if (key == SOLVABLE_PROVIDES)
821 /* add the filelist */
823 dataiterator_init(&di, pool, repo, s - pool->solvables, SOLVABLE_FILELIST, 0, 0);
824 while (dataiterator_step(&di))
826 const char *s = repodata_dir2str(di.data, di.kv.id, di.kv.str);
829 Id id = pool_str2id(pool, s, 0);
832 for (dp = prvdp; *dp; dp++)
836 continue; /* already included */
841 fprintf(fp, "+%s", tag);
844 fprintf(fp, "%s\n", s);
848 fprintf(fp, "-%s\n", tag);
852 testcase_write_testtags(Repo *repo, FILE *fp)
854 Pool *pool = repo->pool;
864 fprintf(fp, "=Ver: 2.0\n");
865 FOR_REPO_SOLVABLES(repo, p, s)
867 name = pool_id2str(pool, s->name);
868 evr = pool_id2str(pool, s->evr);
869 arch = pool_id2str(pool, s->arch);
870 release = strrchr(evr, '-');
872 release = evr + strlen(evr);
873 fprintf(fp, "=Pkg: %s %.*s %s %s\n", name, (int)(release - evr), evr, *release && release[1] ? release + 1 : "-", arch);
874 tmp = solvable_lookup_str(s, SOLVABLE_SUMMARY);
876 fprintf(fp, "=Sum: %s\n", tmp);
877 writedeps(repo, fp, "Req:", SOLVABLE_REQUIRES, s, s->requires);
878 writedeps(repo, fp, "Prv:", SOLVABLE_PROVIDES, s, s->provides);
879 writedeps(repo, fp, "Obs:", SOLVABLE_OBSOLETES, s, s->obsoletes);
880 writedeps(repo, fp, "Con:", SOLVABLE_CONFLICTS, s, s->conflicts);
881 writedeps(repo, fp, "Rec:", SOLVABLE_RECOMMENDS, s, s->recommends);
882 writedeps(repo, fp, "Sup:", SOLVABLE_SUPPLEMENTS, s, s->supplements);
883 writedeps(repo, fp, "Sug:", SOLVABLE_SUGGESTS, s, s->suggests);
884 writedeps(repo, fp, "Enh:", SOLVABLE_ENHANCES, s, s->enhances);
886 fprintf(fp, "=Vnd: %s\n", pool_id2str(pool, s->vendor));
887 ti = solvable_lookup_num(s, SOLVABLE_BUILDTIME, 0);
889 fprintf(fp, "=Tim: %u\n", ti);
895 adddep(Repo *repo, Offset olddeps, char *str, Id marker)
897 Id id = *str == '/' ? pool_str2id(repo->pool, str, 1) : testcase_str2dep(repo->pool, str);
898 return repo_addid_dep(repo, olddeps, id, marker);
902 finish_solvable(Pool *pool, Repodata *data, Solvable *s, char *filelist, int nfilelist)
908 for (l = 0; l < nfilelist; l += strlen(filelist + l) + 1)
910 char *p = strrchr(filelist + l, '/');
914 did = repodata_str2dir(data, filelist + l, 1);
917 did = repodata_str2dir(data, "/", 1);
918 repodata_add_dirstr(data, s - pool->solvables, SOLVABLE_FILELIST, did, p);
921 if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
922 s->provides = repo_addid_dep(s->repo, s->provides, pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
923 s->supplements = repo_fix_supplements(s->repo, s->provides, s->supplements, 0);
924 s->conflicts = repo_fix_conflicts(s->repo, s->conflicts);
927 /* stripped down version of susetags parser used for testcases */
929 testcase_add_testtags(Repo *repo, FILE *fp, int flags)
931 Pool *pool = repo->pool;
944 data = repo_add_repodata(repo, flags);
949 line = solv_malloc(aline);
953 if (linep - line + 16 > aline)
955 aline = linep - line;
956 line = solv_realloc(line, aline + 512);
957 linep = line + aline;
960 if (!fgets(linep, aline - (linep - line), fp))
962 linep += strlen(linep);
963 if (linep == line || linep[-1] != '\n')
966 linep = line + intag;
969 if (line[intag] == '-' && !strncmp(line + 1, line + intag + 1, intag - 2))
976 else if (line[0] == '+' && line[1] && line[1] != ':')
978 char *tagend = strchr(line, ':');
983 intag = tagend + 2 - line;
984 linep = line + intag;
987 if (*line != '=' || !line[1] || !line[2] || !line[3] || line[4] != ':')
989 tag = line[1] << 16 | line[2] << 8 | line[3];
992 case 'P' << 16 | 'k' << 8 | 'g':
994 finish_solvable(pool, data, s, filelist, nfilelist);
996 if (split(line + 5, sp, 5) != 4)
998 s = pool_id2solvable(pool, repo_add_solvable(repo));
999 s->name = pool_str2id(pool, sp[0], 1);
1000 /* join back version and release */
1001 if (sp[2] && !(sp[2][0] == '-' && !sp[2][1]))
1003 s->evr = makeevr(pool, sp[1]);
1004 s->arch = pool_str2id(pool, sp[3], 1);
1006 case 'S' << 16 | 'u' << 8 | 'm':
1007 repodata_set_str(data, s - pool->solvables, SOLVABLE_SUMMARY, line + 6);
1009 case 'V' << 16 | 'n' << 8 | 'd':
1010 s->vendor = pool_str2id(pool, line + 6, 1);
1012 case 'T' << 16 | 'i' << 8 | 'm':
1015 repodata_set_num(data, s - pool->solvables, SOLVABLE_BUILDTIME, t);
1017 case 'R' << 16 | 'e' << 8 | 'q':
1018 s->requires = adddep(repo, s->requires, line + 6, -SOLVABLE_PREREQMARKER);
1020 case 'P' << 16 | 'r' << 8 | 'q':
1021 s->requires = adddep(repo, s->requires, line + 6, SOLVABLE_PREREQMARKER);
1023 case 'P' << 16 | 'r' << 8 | 'v':
1026 int l = strlen(line + 6) + 1;
1027 if (nfilelist + l > afilelist)
1029 afilelist = nfilelist + l + 512;
1030 filelist = solv_realloc(filelist, afilelist);
1032 memcpy(filelist + nfilelist, line + 6, l);
1039 for (l = 0; l < nfilelist; l += strlen(filelist + l) + 1)
1040 s->provides = repo_addid_dep(repo, s->provides, pool_str2id(pool, filelist + l, 1), 0);
1043 s->provides = adddep(repo, s->provides, line + 6, 0);
1045 case 'O' << 16 | 'b' << 8 | 's':
1046 s->obsoletes = adddep(repo, s->obsoletes, line + 6, 0);
1048 case 'C' << 16 | 'o' << 8 | 'n':
1049 s->conflicts = adddep(repo, s->conflicts, line + 6, 0);
1051 case 'R' << 16 | 'e' << 8 | 'c':
1052 s->recommends = adddep(repo, s->recommends, line + 6, 0);
1054 case 'S' << 16 | 'u' << 8 | 'p':
1055 s->supplements = adddep(repo, s->supplements, line + 6, 0);
1057 case 'S' << 16 | 'u' << 8 | 'g':
1058 s->suggests = adddep(repo, s->suggests, line + 6, 0);
1060 case 'E' << 16 | 'n' << 8 | 'h':
1061 s->enhances = adddep(repo, s->enhances, line + 6, 0);
1068 finish_solvable(pool, data, s, filelist, nfilelist);
1070 solv_free(filelist);
1071 repodata_free_dircache(data);
1072 if (!(flags & REPO_NO_INTERNALIZE))
1073 repodata_internalize(data);
1078 testcase_getpoolflags(Pool *pool)
1080 const char *str = 0;
1082 for (i = 0; poolflags2str[i].str; i++)
1084 v = pool_get_flag(pool, poolflags2str[i].flag);
1085 if (v == poolflags2str[i].def)
1087 str = pool_tmpappend(pool, str, v ? " " : " !", poolflags2str[i].str);
1089 return str ? str + 1 : "";
1093 testcase_setpoolflags(Pool *pool, const char *str)
1095 const char *p = str, *s;
1099 while (*p == ' ' || *p == '\t' || *p == ',')
1110 while (*p && *p != ' ' && *p != '\t' && *p != ',')
1112 for (i = 0; poolflags2str[i].str; i++)
1113 if (!strncmp(poolflags2str[i].str, s, p - s) && poolflags2str[i].str[p - s] == 0)
1115 if (!poolflags2str[i].str)
1117 pool_debug(pool, SOLV_ERROR, "setpoolflags: unknown flag '%.*s'\n", (int)(p - s), s);
1120 pool_set_flag(pool, poolflags2str[i].flag, v);
1126 testcase_resetpoolflags(Pool *pool)
1129 for (i = 0; poolflags2str[i].str; i++)
1130 pool_set_flag(pool, poolflags2str[i].flag, poolflags2str[i].def);
1134 testcase_getsolverflags(Solver *solv)
1136 Pool *pool = solv->pool;
1137 const char *str = 0;
1139 for (i = 0; solverflags2str[i].str; i++)
1141 v = solver_get_flag(solv, solverflags2str[i].flag);
1142 if (v == solverflags2str[i].def)
1144 str = pool_tmpappend(pool, str, v ? " " : " !", solverflags2str[i].str);
1146 return str ? str + 1 : "";
1150 testcase_setsolverflags(Solver *solv, const char *str)
1152 const char *p = str, *s;
1156 while (*p == ' ' || *p == '\t' || *p == ',')
1167 while (*p && *p != ' ' && *p != '\t' && *p != ',')
1169 for (i = 0; solverflags2str[i].str; i++)
1170 if (!strncmp(solverflags2str[i].str, s, p - s) && solverflags2str[i].str[p - s] == 0)
1172 if (!solverflags2str[i].str)
1174 pool_debug(solv->pool, SOLV_ERROR, "setsolverflags: unknown flag '%.*s'\n", (int)(p - s), s);
1177 solver_set_flag(solv, solverflags2str[i].flag, v);
1183 testcase_resetsolverflags(Solver *solv)
1186 for (i = 0; solverflags2str[i].str; i++)
1187 solver_set_flag(solv, solverflags2str[i].flag, solverflags2str[i].def);
1191 testcase_ruleid(Solver *solv, Id rid)
1197 const unsigned char *md5;
1203 solver_ruleliterals(solv, rid, &q);
1204 for (i = 0; i < q.count; i++)
1206 Id p = q.elements[i];
1207 s = testcase_solvid2str(solv->pool, p > 0 ? p : -p);
1209 s = pool_tmpjoin(solv->pool, "!", s, 0);
1210 strqueue_push(&sq, s);
1213 strqueue_sort_u(&sq);
1214 chk = solv_chksum_create(REPOKEY_TYPE_MD5);
1215 for (i = 0; i < sq.nstr; i++)
1216 solv_chksum_add(chk, sq.str[i], strlen(sq.str[i]) + 1);
1217 md5 = solv_chksum_get(chk, &md5l);
1218 s = pool_bin2hex(solv->pool, md5, md5l);
1219 chk = solv_chksum_free(chk, 0);
1225 testcase_problemid(Solver *solv, Id problem)
1230 const unsigned char *md5;
1234 /* we build a hash of all rules that define the problem */
1237 solver_findallproblemrules(solv, problem, &q);
1238 for (i = 0; i < q.count; i++)
1239 strqueue_push(&sq, testcase_ruleid(solv, q.elements[i]));
1241 strqueue_sort_u(&sq);
1242 chk = solv_chksum_create(REPOKEY_TYPE_MD5);
1243 for (i = 0; i < sq.nstr; i++)
1244 solv_chksum_add(chk, sq.str[i], strlen(sq.str[i]) + 1);
1245 md5 = solv_chksum_get(chk, &md5l);
1246 s = pool_bin2hex(solv->pool, md5, 4);
1247 chk = solv_chksum_free(chk, 0);
1253 testcase_solutionid(Solver *solv, Id problem, Id solution)
1257 const unsigned char *md5;
1261 intid = solver_solutionelement_internalid(solv, problem, solution);
1262 /* internal stuff! handle with care! */
1266 s = testcase_job2str(solv->pool, solv->job.elements[-intid - 1], solv->job.elements[-intid]);
1271 s = testcase_ruleid(solv, intid);
1273 chk = solv_chksum_create(REPOKEY_TYPE_MD5);
1274 solv_chksum_add(chk, s, strlen(s) + 1);
1275 md5 = solv_chksum_get(chk, &md5l);
1276 s = pool_bin2hex(solv->pool, md5, 4);
1277 chk = solv_chksum_free(chk, 0);
1281 static struct class2str {
1285 { SOLVER_TRANSACTION_ERASE, "erase" },
1286 { SOLVER_TRANSACTION_INSTALL, "install" },
1287 { SOLVER_TRANSACTION_REINSTALLED, "reinstall" },
1288 { SOLVER_TRANSACTION_DOWNGRADED, "downgrade" },
1289 { SOLVER_TRANSACTION_CHANGED, "change" },
1290 { SOLVER_TRANSACTION_UPGRADED, "upgrade" },
1291 { SOLVER_TRANSACTION_OBSOLETED, "obsolete" },
1292 { SOLVER_TRANSACTION_MULTIINSTALL, "multiinstall" },
1293 { SOLVER_TRANSACTION_MULTIREINSTALL, "multireinstall" },
1298 testcase_solverresult(Solver *solv, int resultflags)
1300 Pool *pool = solv->pool;
1308 if ((resultflags & TESTCASE_RESULT_TRANSACTION) != 0)
1310 Transaction *trans = solver_create_transaction(solv);
1314 for (i = 0; class2str[i].str; i++)
1317 transaction_classify_pkgs(trans, SOLVER_TRANSACTION_KEEP_PSEUDO, class2str[i].class, 0, 0, &q);
1318 for (j = 0; j < q.count; j++)
1322 if (pool->installed && pool->solvables[p].repo == pool->installed)
1323 op = transaction_obs_pkg(trans, p);
1324 s = pool_tmpjoin(pool, class2str[i].str, " ", testcase_solvid2str(pool, p));
1326 s = pool_tmpjoin(pool, s, " ", testcase_solvid2str(pool, op));
1327 strqueue_push(&sq, s);
1331 transaction_free(trans);
1333 if ((resultflags & TESTCASE_RESULT_PROBLEMS) != 0)
1335 char *probprefix, *solprefix;
1336 int problem, solution, element;
1339 pcnt = solver_problem_count(solv);
1340 for (problem = 1; problem <= pcnt; problem++)
1342 Id rid, from, to, dep;
1343 SolverRuleinfo rinfo;
1344 rid = solver_findproblemrule(solv, problem);
1345 s = testcase_problemid(solv, problem);
1346 probprefix = solv_dupjoin("problem ", s, 0);
1347 rinfo = solver_ruleinfo(solv, rid, &from, &to, &dep);
1348 s = pool_tmpjoin(pool, probprefix, " info ", solver_problemruleinfo2str(solv, rinfo, from, to, dep));
1349 strqueue_push(&sq, s);
1350 scnt = solver_solution_count(solv, problem);
1351 for (solution = 1; solution <= scnt; solution++)
1353 s = testcase_solutionid(solv, problem, solution);
1354 solprefix = solv_dupjoin(probprefix, " solution ", s);
1356 while ((element = solver_next_solutionelement(solv, problem, solution, element, &p, &op)) != 0)
1358 if (p == SOLVER_SOLUTION_JOB)
1359 s = pool_tmpjoin(pool, solprefix, " deljob ", testcase_job2str(pool, solv->job.elements[op - 1], solv->job.elements[op]));
1360 else if (p > 0 && op == 0)
1361 s = pool_tmpjoin(pool, solprefix, " erase ", testcase_solvid2str(pool, p));
1362 else if (p > 0 && op > 0)
1364 s = pool_tmpjoin(pool, solprefix, " replace ", testcase_solvid2str(pool, p));
1365 s = pool_tmpappend(pool, s, " ", testcase_solvid2str(pool, op));
1367 else if (p < 0 && op > 0)
1368 s = pool_tmpjoin(pool, solprefix, " allow ", testcase_solvid2str(pool, op));
1370 s = pool_tmpjoin(pool, solprefix, " unknown", 0);
1371 strqueue_push(&sq, s);
1373 solv_free(solprefix);
1375 solv_free(probprefix);
1379 if ((resultflags & TESTCASE_RESULT_ORPHANED) != 0)
1384 solver_get_orphaned(solv, &q);
1385 for (i = 0; i < q.count; i++)
1387 s = pool_tmpjoin(pool, "orphaned ", testcase_solvid2str(pool, q.elements[i]), 0);
1388 strqueue_push(&sq, s);
1393 if ((resultflags & TESTCASE_RESULT_RECOMMENDED) != 0)
1399 solver_get_recommendations(solv, &qr, &qs, 0);
1400 for (i = 0; i < qr.count; i++)
1402 s = pool_tmpjoin(pool, "recommended ", testcase_solvid2str(pool, qr.elements[i]), 0);
1403 strqueue_push(&sq, s);
1405 for (i = 0; i < qs.count; i++)
1407 s = pool_tmpjoin(pool, "suggested ", testcase_solvid2str(pool, qs.elements[i]), 0);
1408 strqueue_push(&sq, s);
1414 if ((resultflags & TESTCASE_RESULT_UNNEEDED) != 0)
1419 solver_get_unneeded(solv, &q, 0);
1420 for (i = 0; i < q.count; i++)
1422 s = pool_tmpjoin(pool, "unneeded ", testcase_solvid2str(pool, q.elements[i]), 0);
1423 strqueue_push(&sq, s);
1429 result = strqueue_join(&sq);
1436 testcase_write(Solver *solv, char *dir, int resultflags, const char *testcasename, const char *resultname)
1438 Pool *pool = solv->pool;
1449 testcasename = "testcase.t";
1451 resultname = "solver.result";
1453 if (mkdir(dir, 0777) && errno != EEXIST)
1455 pool_debug(solv->pool, SOLV_ERROR, "testcase_write: could not create directory '%s'\n", dir);
1459 FOR_REPOS(repoid, repo)
1461 const char *name = testcase_repoid2str(pool, repoid);
1463 if (repo->subpriority)
1464 sprintf(priobuf, "%d.%d", repo->priority, repo->subpriority);
1466 sprintf(priobuf, "%d", repo->priority);
1467 out = pool_tmpjoin(pool, name, ".repo", ".gz");
1468 cmd = pool_tmpjoin(pool, "repo ", name, " ");
1469 cmd = pool_tmpappend(pool, cmd, priobuf, " ");
1470 cmd = pool_tmpappend(pool, cmd, "testtags ", out);
1471 strqueue_push(&sq, cmd);
1472 out = pool_tmpjoin(pool, dir, "/", out);
1473 if (!(fp = solv_xfopen(out, "w")))
1475 pool_debug(solv->pool, SOLV_ERROR, "testcase_write: could not open '%s' for writing\n", out);
1479 testcase_write_testtags(repo, fp);
1482 pool_debug(solv->pool, SOLV_ERROR, "testcase_write: write error\n");
1487 /* hmm, this is not optimal... we currently search for the lowest score */
1489 arch = pool->solvables[SYSTEMSOLVABLE].arch;
1490 for (i = 0; i < pool->lastarch; i++)
1492 if (pool->id2arch[i] == 1 && !lowscore)
1494 if (pool->id2arch[i] > 0x10000 && (!lowscore || pool->id2arch[i] < lowscore))
1497 lowscore = pool->id2arch[i];
1500 cmd = pool_tmpjoin(pool, "system ", pool->lastarch ? pool_id2str(pool, arch) : "unset", 0);
1501 for (i = 0; disttype2str[i].str != 0; i++)
1502 if (pool->disttype == disttype2str[i].type)
1504 pool_tmpappend(pool, cmd, " ", disttype2str[i].str ? disttype2str[i].str : "unknown");
1505 if (pool->installed)
1506 cmd = pool_tmpappend(pool, cmd, " ", testcase_repoid2str(pool, pool->installed->repoid));
1507 strqueue_push(&sq, cmd);
1508 s = testcase_getpoolflags(solv->pool);
1511 cmd = pool_tmpjoin(pool, "poolflags ", s, 0);
1512 strqueue_push(&sq, cmd);
1515 if (pool->vendorclasses)
1518 for (i = 0; pool->vendorclasses[i]; i++)
1520 cmd = pool_tmpappend(pool, cmd ? cmd : "vendorclass", " ", pool->vendorclasses[i]);
1521 if (!pool->vendorclasses[i + 1])
1523 strqueue_push(&sq, cmd);
1530 s = testcase_getsolverflags(solv);
1533 cmd = pool_tmpjoin(pool, "solverflags ", s, 0);
1534 strqueue_push(&sq, cmd);
1537 /* now dump all the ns callback values we know */
1538 if (pool->nscallback)
1542 for (rid = 1; rid < pool->nrels; rid++)
1544 Reldep *rd = pool->rels + rid;
1545 if (rd->flags != REL_NAMESPACE || rd->name == NAMESPACE_OTHERPROVIDERS)
1547 /* evaluate all namespace ids, skip empty results */
1548 d = pool_whatprovides(pool, MAKERELDEP(rid));
1549 if (!d || !pool->whatprovidesdata[d])
1551 cmd = pool_tmpjoin(pool, "namespace ", pool_id2str(pool, rd->name), "(");
1552 cmd = pool_tmpappend(pool, cmd, pool_id2str(pool, rd->evr), ")");
1553 for (; pool->whatprovidesdata[d]; d++)
1554 cmd = pool_tmpappend(pool, cmd, " ", testcase_solvid2str(pool, pool->whatprovidesdata[d]));
1555 strqueue_push(&sq, cmd);
1559 for (i = 0; i < solv->job.count; i += 2)
1561 cmd = (char *)testcase_job2str(pool, solv->job.elements[i], solv->job.elements[i + 1]);
1562 cmd = pool_tmpjoin(pool, "job ", cmd, 0);
1563 strqueue_push(&sq, cmd);
1570 for (i = 0; resultflags2str[i].str; i++)
1571 if ((resultflags & resultflags2str[i].flag) != 0)
1572 cmd = pool_tmpappend(pool, cmd, cmd ? "," : 0, resultflags2str[i].str);
1573 cmd = pool_tmpjoin(pool, "result ", cmd ? cmd : "?", 0);
1574 cmd = pool_tmpappend(pool, cmd, " ", resultname);
1575 strqueue_push(&sq, cmd);
1576 result = testcase_solverresult(solv, resultflags);
1577 if (!strcmp(resultname, "<inline>"))
1581 strqueue_init(&rsq);
1582 strqueue_split(&rsq, result);
1583 for (i = 0; i < rsq.nstr; i++)
1585 cmd = pool_tmpjoin(pool, "#>", rsq.str[i], 0);
1586 strqueue_push(&sq, cmd);
1588 strqueue_free(&rsq);
1592 out = pool_tmpjoin(pool, dir, "/", resultname);
1593 if (!(fp = fopen(out, "w")))
1595 pool_debug(solv->pool, SOLV_ERROR, "testcase_write: could not open '%s' for writing\n", out);
1600 if (result && *result && fwrite(result, strlen(result), 1, fp) != 1)
1602 pool_debug(solv->pool, SOLV_ERROR, "testcase_write: write error\n");
1609 pool_debug(solv->pool, SOLV_ERROR, "testcase_write: write error\n");
1617 cmd = strqueue_join(&sq);
1618 out = pool_tmpjoin(pool, dir, "/", testcasename);
1619 if (!(fp = fopen(out, "w")))
1621 pool_debug(solv->pool, SOLV_ERROR, "testcase_write: could not open '%s' for writing\n", out);
1625 if (*cmd && fwrite(cmd, strlen(cmd), 1, fp) != 1)
1627 pool_debug(solv->pool, SOLV_ERROR, "testcase_write: write error\n");
1633 pool_debug(solv->pool, SOLV_ERROR, "testcase_write: write error\n");
1643 read_inline_file(FILE *fp, char **bufp, char **bufpp, int *buflp)
1645 char *result = solv_malloc(1024);
1652 if (rp - result + 256 >= resultl)
1654 resultl = rp - result;
1655 result = solv_realloc(result, resultl + 1024);
1656 rp = result + resultl;
1659 if (!fgets(rp, resultl - (rp - result), fp))
1662 if (rl && (rp == result || rp[-1] == '\n'))
1664 if (rl > 1 && rp[0] == '#' && rp[1] == '>')
1666 memmove(rp, rp + 2, rl - 2);
1671 while (rl + 16 > *buflp)
1673 *bufp = solv_realloc(*bufp, *buflp + 512);
1676 memmove(*bufp, rp, rl);
1677 if ((*bufp)[rl - 1] == '\n')
1683 (*bufpp) = *bufp + rl;
1700 char *result = solv_malloc(1024);
1707 if (rp - result + 256 >= resultl)
1709 resultl = rp - result;
1710 result = solv_realloc(result, resultl + 1024);
1711 rp = result + resultl;
1714 rl = fread(rp, 1, resultl - (rp - result), fp);
1726 testcase_read(Pool *pool, FILE *fp, char *testcase, Queue *job, char **resultp, int *resultflagsp)
1731 char *testcasedir, *s;
1737 int poolflagsreset = 0;
1739 if (!fp && !(fp = fopen(testcase, "r")))
1741 pool_debug(pool, SOLV_ERROR, "testcase_read: could not open '%s'\n", testcase);
1744 testcasedir = solv_strdup(testcase);
1745 if ((s = strrchr(testcasedir, '/')) != 0)
1750 buf = solv_malloc(bufl);
1755 if (bufp - buf + 16 > bufl)
1758 buf = solv_realloc(buf, bufl + 512);
1762 if (!fgets(bufp, bufl - (bufp - buf), fp))
1766 if (!l || buf[l - 1] != '\n')
1773 while (*s && (*s == ' ' || *s == '\t'))
1775 if (!*s || *s == '#')
1778 /* split it in pieces */
1781 while (*s == ' ' || *s == '\t')
1785 pieces = solv_extend(pieces, npieces, 1, sizeof(*pieces), 7);
1786 pieces[npieces++] = s;
1787 while (*s && *s != ' ' && *s != '\t')
1792 pieces = solv_extend(pieces, npieces, 1, sizeof(*pieces), 7);
1793 pieces[npieces] = 0;
1794 if (!strcmp(pieces[0], "repo") && npieces >= 4)
1796 Repo *repo = repo_create(pool, pieces[1]);
1802 if (!poolflagsreset)
1805 testcase_resetpoolflags(pool); /* hmm */
1807 if (sscanf(pieces[2], "%d.%d", &prio, &subprio) != 2)
1810 prio = atoi(pieces[2]);
1812 repo->priority = prio;
1813 repo->subpriority = subprio;
1814 if (strcmp(pieces[3], "empty") != 0)
1816 const char *repotype = pool_tmpjoin(pool, pieces[3], 0, 0); /* gets overwritten in <inline> case */
1817 if (!strcmp(pieces[4], "<inline>"))
1819 char *idata = read_inline_file(fp, &buf, &bufp, &bufl);
1821 rfp = solv_xfopen_buf(rdata, &idata, 0, "rf");
1825 rdata = pool_tmpjoin(pool, testcasedir, pieces[4], 0);
1826 rfp = solv_xfopen(rdata, "r");
1830 pool_debug(pool, SOLV_ERROR, "testcase_read: could not open '%s'\n", rdata);
1832 else if (!strcmp(repotype, "testtags"))
1834 testcase_add_testtags(repo, rfp, 0);
1837 else if (!strcmp(repotype, "solv"))
1839 repo_add_solv(repo, rfp, 0);
1845 pool_debug(pool, SOLV_ERROR, "testcase_read: unknown repo type for repo '%s'\n", repo->name);
1849 else if (!strcmp(pieces[0], "system") && npieces >= 3)
1853 /* must set the disttype before the arch */
1854 for (i = 0; disttype2str[i].str != 0; i++)
1855 if (!strcmp(disttype2str[i].str, pieces[2]))
1857 if (!disttype2str[i].str)
1858 pool_debug(pool, SOLV_ERROR, "testcase_read: system: unknown disttype '%s'\n", pieces[2]);
1859 else if (pool->disttype != disttype2str[i].type)
1861 #ifdef MULTI_SEMANTICS
1862 pool_setdisttype(pool, disttype2str[i].type);
1864 pool_debug(pool, SOLV_ERROR, "testcase_read: system: cannot change disttype to '%s'\n", pieces[2]);
1867 if (strcmp(pieces[1], "unset") != 0)
1868 pool_setarch(pool, pieces[1]);
1870 pool_setarch(pool, 0);
1873 Repo *repo = testcase_str2repo(pool, pieces[3]);
1875 pool_debug(pool, SOLV_ERROR, "testcase_read: system: unknown repo '%s'\n", pieces[3]);
1877 pool_set_installed(pool, repo);
1880 else if (!strcmp(pieces[0], "job") && npieces > 1)
1886 pool_addfileprovides(pool);
1887 pool_createwhatprovides(pool);
1891 for (sp = pieces[1]; sp < pieces[npieces - 1]; sp++)
1894 how = testcase_str2job(pool, pieces[1], &what);
1895 if (how >= 0 && job)
1896 queue_push2(job, how, what);
1898 else if (!strcmp(pieces[0], "vendorclass") && npieces > 1)
1900 pool_addvendorclass(pool, (const char **)(pieces + 1));
1902 else if (!strcmp(pieces[0], "namespace") && npieces > 1)
1904 int i = strlen(pieces[1]);
1905 s = strchr(pieces[1], '(');
1906 if (!s && pieces[1][i - 1] != ')')
1908 pool_debug(pool, SOLV_ERROR, "testcase_read: bad namespace '%s'\n", pieces[1]);
1916 pieces[1][i - 1] = 0;
1917 name = pool_str2id(pool, pieces[1], 1);
1918 evr = pool_str2id(pool, s + 1, 1);
1920 pieces[1][i - 1] = ')';
1921 id = pool_rel2id(pool, name, evr, REL_NAMESPACE, 1);
1922 for (i = 2; i < npieces; i++)
1923 queue_push(&q, testcase_str2solvid(pool, pieces[i]));
1924 /* now do the callback */
1927 pool_addfileprovides(pool);
1928 pool_createwhatprovides(pool);
1931 pool->whatprovides_rel[GETRELID(id)] = pool_queuetowhatprovides(pool, &q);
1935 else if (!strcmp(pieces[0], "poolflags"))
1938 if (!poolflagsreset)
1941 testcase_resetpoolflags(pool); /* hmm */
1943 for (i = 1; i < npieces; i++)
1944 testcase_setpoolflags(pool, pieces[i]);
1946 else if (!strcmp(pieces[0], "solverflags") && npieces > 1)
1951 solv = solver_create(pool);
1952 testcase_resetsolverflags(solv);
1954 for (i = 1; i < npieces; i++)
1955 testcase_setsolverflags(solv, pieces[i]);
1957 else if (!strcmp(pieces[0], "result") && npieces > 2)
1961 int resultflags = 0;
1962 char *s = pieces[1];
1966 char *se = strchr(s, ',');
1969 for (i = 0; resultflags2str[i].str; i++)
1970 if (!strcmp(s, resultflags2str[i].str))
1972 resultflags |= resultflags2str[i].flag;
1975 if (!resultflags2str[i].str)
1976 pool_debug(pool, SOLV_ERROR, "result: unknown flag '%s'\n", s);
1980 rdata = pool_tmpjoin(pool, testcasedir, pieces[2], 0);
1981 if (!strcmp(pieces[2], "<inline>"))
1982 result = read_inline_file(fp, &buf, &bufp, &bufl);
1985 FILE *rfp = fopen(rdata, "r");
1987 pool_debug(pool, SOLV_ERROR, "testcase_read: could not open '%s'\n", rdata);
1990 result = read_file(rfp);
1999 *resultflagsp = resultflags;
2001 else if (!strcmp(pieces[0], "nextjob") && npieces == 1)
2007 pool_debug(pool, SOLV_ERROR, "testcase_read: cannot parse command '%s'\n", pieces[0]);
2010 buf = solv_free(buf);
2011 pieces = solv_free(pieces);
2012 solv_free(testcasedir);
2015 pool_addfileprovides(pool);
2016 pool_createwhatprovides(pool);
2020 solv = solver_create(pool);
2021 testcase_resetsolverflags(solv);
2029 testcase_resultdiff(char *result1, char *result2)
2031 Strqueue sq1, sq2, osq;
2033 strqueue_init(&sq1);
2034 strqueue_init(&sq2);
2035 strqueue_init(&osq);
2036 strqueue_split(&sq1, result1);
2037 strqueue_split(&sq2, result2);
2038 strqueue_sort(&sq1);
2039 strqueue_sort(&sq2);
2040 strqueue_diff(&sq1, &sq2, &osq);
2041 r = osq.nstr ? strqueue_join(&osq) : 0;
2042 strqueue_free(&sq1);
2043 strqueue_free(&sq2);
2044 strqueue_free(&osq);