make repodata_stringify return the result string
[platform/upstream/libsolv.git] / ext / testcase.c
index 1cc1900..70d98b3 100644 (file)
 #include "poolarch.h"
 #include "poolvendor.h"
 #include "repo.h"
-#include "repo_susetags.h"
+#include "repo_solv.h"
 #include "solver.h"
 #include "solverdebug.h"
 #include "chksum.h"
 #include "testcase.h"
+#include "selection.h"
 #include "solv_xfopen.h"
 
+#define DISABLE_JOIN2
+#include "tools_util.h"
 
 static struct job2str {
   Id job;
@@ -35,7 +38,8 @@ static struct job2str {
   { SOLVER_ERASE,         "erase" },
   { SOLVER_UPDATE,        "update" },
   { SOLVER_WEAKENDEPS,    "weakendeps" },
-  { SOLVER_NOOBSOLETES,   "noobsoletes" },
+  { SOLVER_MULTIVERSION,  "multiversion" },
+  { SOLVER_MULTIVERSION,  "noobsoletes" },     /* old name */
   { SOLVER_LOCK,          "lock" },
   { SOLVER_DISTUPGRADE,   "distupgrade" },
   { SOLVER_VERIFY,        "verify" },
@@ -51,6 +55,10 @@ static struct jobflags2str {
   { SOLVER_WEAK,      "weak" },
   { SOLVER_ESSENTIAL, "essential" },
   { SOLVER_CLEANDEPS, "cleandeps" },
+  { SOLVER_ORUPDATE,  "orupdate" },
+  { SOLVER_FORCEBEST, "forcebest" },
+  { SOLVER_TARGETED,  "targeted" },
+  { SOLVER_NOTBYUSER, "notbyuser" },
   { SOLVER_SETEV,     "setev" },
   { SOLVER_SETEVR,    "setevr" },
   { SOLVER_SETARCH,   "setarch" },
@@ -60,23 +68,91 @@ static struct jobflags2str {
   { 0, 0 }
 };
 
+static struct resultflags2str {
+  Id flag;
+  const char *str;
+} resultflags2str[] = {
+  { TESTCASE_RESULT_TRANSACTION,       "transaction" },
+  { TESTCASE_RESULT_PROBLEMS,          "problems" },
+  { TESTCASE_RESULT_ORPHANED,          "orphaned" },
+  { TESTCASE_RESULT_RECOMMENDED,       "recommended" },
+  { TESTCASE_RESULT_UNNEEDED,          "unneeded" },
+  { 0, 0 }
+};
+
 static struct solverflags2str {
   Id flag;
   const char *str;
   int def;
 } solverflags2str[] = {
   { SOLVER_FLAG_ALLOW_DOWNGRADE,            "allowdowngrade", 0 },
+  { SOLVER_FLAG_ALLOW_NAMECHANGE,           "allownamechange", 1 },
   { SOLVER_FLAG_ALLOW_ARCHCHANGE,           "allowarchchange", 0 },
   { SOLVER_FLAG_ALLOW_VENDORCHANGE,         "allowvendorchange", 0 },
   { SOLVER_FLAG_ALLOW_UNINSTALL,            "allowuninstall", 0 },
   { SOLVER_FLAG_NO_UPDATEPROVIDE,           "noupdateprovide", 0 },
   { SOLVER_FLAG_SPLITPROVIDES,              "splitprovides", 0 },
   { SOLVER_FLAG_IGNORE_RECOMMENDED,         "ignorerecommended", 0 },
-  { SOLVER_FLAG_IGNORE_ALREADY_RECOMMENDED, "ignorealreadyrecommended", 0 },
+  { SOLVER_FLAG_ADD_ALREADY_RECOMMENDED,    "addalreadyrecommended", 0 },
   { SOLVER_FLAG_NO_INFARCHCHECK,            "noinfarchcheck", 0 },
+  { SOLVER_FLAG_KEEP_EXPLICIT_OBSOLETES,    "keepexplicitobsoletes", 0 },
+  { SOLVER_FLAG_BEST_OBEY_POLICY,           "bestobeypolicy", 0 },
+  { SOLVER_FLAG_NO_AUTOTARGET,              "noautotarget", 0 },
+  { SOLVER_FLAG_DUP_ALLOW_DOWNGRADE,        "dupallowdowngrade", 1 },
+  { SOLVER_FLAG_DUP_ALLOW_ARCHCHANGE,       "dupallowarchchange", 1 },
+  { SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE,     "dupallowvendorchange", 1 },
+  { SOLVER_FLAG_DUP_ALLOW_NAMECHANGE,       "dupallownamechange", 1 },
+  { 0, 0, 0 }
+};
+
+static struct poolflags2str {
+  Id flag;
+  const char *str;
+  int def;
+} poolflags2str[] = {
+  { POOL_FLAG_PROMOTEEPOCH,                 "promoteepoch", 0 },
+  { POOL_FLAG_FORBIDSELFCONFLICTS,          "forbidselfconflicts", 0 },
+  { POOL_FLAG_OBSOLETEUSESPROVIDES,         "obsoleteusesprovides", 0 },
+  { POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES, "implicitobsoleteusesprovides", 0 },
+  { POOL_FLAG_OBSOLETEUSESCOLORS,           "obsoleteusescolors", 0 },
+  { POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS,   "implicitobsoleteusescolors", 0 },
+  { POOL_FLAG_NOINSTALLEDOBSOLETES,         "noinstalledobsoletes", 0 },
+  { POOL_FLAG_HAVEDISTEPOCH,                "havedistepoch", 0 },
+  { POOL_FLAG_NOOBSOLETESMULTIVERSION,      "noobsoletesmultiversion", 0 },
+  { POOL_FLAG_ADDFILEPROVIDESFILTERED,      "addfileprovidesfiltered", 0 },
   { 0, 0, 0 }
 };
 
+static struct disttype2str {
+  Id type;
+  const char *str;
+} disttype2str[] = {
+  { DISTTYPE_RPM,  "rpm" },
+  { DISTTYPE_DEB,  "deb" },
+  { DISTTYPE_ARCH, "arch" },
+  { DISTTYPE_HAIKU, "haiku" },
+  { 0, 0 }
+};
+
+static struct selflags2str {
+  Id flag;
+  const char *str;
+} selflags2str[] = {
+  { SELECTION_NAME, "name" },
+  { SELECTION_PROVIDES, "provides" },
+  { SELECTION_FILELIST, "filelist" },
+  { SELECTION_CANON, "canon" },
+  { SELECTION_DOTARCH, "dotarch" },
+  { SELECTION_REL, "rel" },
+  { SELECTION_INSTALLED_ONLY, "installedonly" },
+  { SELECTION_GLOB, "glob" },
+  { SELECTION_FLAT, "flat" },
+  { SELECTION_NOCASE, "nocase" },
+  { SELECTION_SOURCE_ONLY, "sourceonly" },
+  { SELECTION_WITH_SOURCE, "withsource" },
+  { 0, 0 }
+};
+
 
 typedef struct strqueue {
   char **str;
@@ -168,6 +244,8 @@ static void
 strqueue_split(Strqueue *q, const char *s)
 {
   const char *p;
+  if (!s)
+    return;
   while ((p = strchr(s, '\n')) != 0)
     {
       q->str = solv_extend(q->str, q->nstr, 1, sizeof(*q->str), STRQUEUE_BLOCK);
@@ -209,32 +287,33 @@ pool_isknownarch(Pool *pool, Id id)
     return 0;
   if (id == ARCH_SRC || id == ARCH_NOSRC || id == ARCH_NOARCH)
     return 1;
-  if (pool->id2arch && (id > pool->lastarch || !pool->id2arch[id]))
+  if (!pool->id2arch || (id > pool->lastarch || !pool->id2arch[id]))
     return 0;
   return 1;
 }
 
-Id
-testcase_str2dep(Pool *pool, char *s)
+static Id
+testcase_str2dep_simple(Pool *pool, const char **sp)
 {
-  char *n, *a;
-  Id id;
+  const char *s = *sp;
+  const char *n, *a;
+  Id id, evr;
   int flags;
 
-  if ((n = strchr(s, '|')) != 0)
-    {    
-      id = testcase_str2dep(pool, n + 1);
-      *n = 0; 
-      id = pool_rel2id(pool, testcase_str2dep(pool, s), id, REL_OR, 1);
-      *n = '|'; 
-      return id;
-    }
   while (*s == ' ' || *s == '\t')
     s++;
   n = s;
   while (*s && *s != ' ' && *s != '\t' && *s != '<' && *s != '=' && *s != '>')
-    s++;
-  if ((a = strchr(n, '.')) != 0 && a + 1 < s)
+    {
+      if (*s == '(')
+       {
+         while (*s && *s != ')')
+           s++;
+         continue;
+       }
+      s++;
+    }
+  if ((a = strchr(n, '.')) != 0 && a + 1 < s && s[-1] != ')')
     {
       Id archid = pool_strn2id(pool, a + 1, s - (a + 1), 0);
       if (pool_isknownarch(pool, archid))
@@ -245,32 +324,105 @@ testcase_str2dep(Pool *pool, char *s)
       else
         id = pool_strn2id(pool, n, s - n, 1);
     }
+  else if (s - n > 4 && s[-4] == ':' && !strncmp(s - 4, ":any", 4))
+    {
+      id = pool_strn2id(pool, n, s - n - 4, 1);
+      id = pool_rel2id(pool, id, ARCH_ANY, REL_MULTIARCH, 1);
+    }
   else
     id = pool_strn2id(pool, n, s - n, 1);
   if (!*s)
-    return id;
+    {
+      *sp = s;
+      return id;
+    }
   while (*s == ' ' || *s == '\t')
     s++;
   flags = 0;
+  if (*s == '!' && s[1] == '=')        /* support != as synonym for <> */
+    {
+      flags = REL_LT | REL_GT;
+      s += 2;
+    }
   for (;;s++)
-    {  
+    {
       if (*s == '<')
-        flags |= REL_LT;
+       flags |= REL_LT;
       else if (*s == '=')
-        flags |= REL_EQ;
+       flags |= REL_EQ;
       else if (*s == '>')
-        flags |= REL_GT;
+       flags |= REL_GT;
       else
-        break;
+       break;
     }
   if (!flags)
-    return id;
+    {
+      *sp = s;
+      return id;
+    }
   while (*s == ' ' || *s == '\t')
     s++;
   n = s;
   while (*s && *s != ' ' && *s != '\t')
     s++;
-  return pool_rel2id(pool, id, pool_strn2id(pool, n, s - n, 1), flags, 1);
+  evr = pool_strn2id(pool, n, s - n, 1);
+  if (*s == ' ' && !strcmp(s, " compat >= "))
+    {
+      s += 11;
+      while (*s == ' ' || *s == '\t')
+       s++;
+      n = s;
+      while (*s && *s != ' ' && *s != '\t')
+       s++;
+      evr = pool_rel2id(pool, evr, pool_strn2id(pool, n, s - n, 1), REL_COMPAT, 1);
+    }
+  *sp = s;
+  return pool_rel2id(pool, id, evr, flags, 1);
+}
+
+static Id
+testcase_str2dep_complex(Pool *pool, const char **sp)
+{
+  const char *s = *sp;
+  Id id;
+#ifdef ENABLE_COMPLEX_DEPS
+  while (*s == ' ' || *s == '\t')
+    s++;
+  if (*s == '(')
+    {
+      s++;
+      id = testcase_str2dep_complex(pool, &s);
+      if (*s == ')')
+       s++;
+      while (*s == ' ' || *s == '\t')
+       s++;
+    }
+  else
+#endif
+    id = testcase_str2dep_simple(pool, &s);
+  if (*s == '|')
+    {
+      s++;
+      id = pool_rel2id(pool, id, testcase_str2dep_complex(pool, &s), REL_OR, 1);
+    }
+  else if (*s == '&')
+    {
+      s++;
+      id = pool_rel2id(pool, id, testcase_str2dep_complex(pool, &s), REL_AND, 1);
+    }
+  else if (*s == 'I' && s[1] == 'F' && (s[2] == ' ' || s[2] == '\t'))
+    {
+      s += 2;
+      id = pool_rel2id(pool, id, testcase_str2dep_complex(pool, &s), REL_COND, 1);
+    }
+  *sp = s;
+  return id;
+}
+
+Id
+testcase_str2dep(Pool *pool, const char *s)
+{
+  return testcase_str2dep_complex(pool, &s);
 }
 
 const char *
@@ -289,7 +441,7 @@ testcase_repoid2str(Pool *pool, Id repoid)
   else
     {
       char buf[20];
-      sprintf(buf, "@#%d", repoid);
+      sprintf(buf, "#%d", repoid);
       return pool_tmpjoin(pool, buf, 0, 0);
     }
 }
@@ -298,12 +450,16 @@ const char *
 testcase_solvid2str(Pool *pool, Id p)
 {
   Solvable *s = pool->solvables + p;
-  const char *str;
-  char buf[20];
+  const char *n, *e, *a;
+  char *str, buf[20];
 
   if (p == SYSTEMSOLVABLE)
     return "@SYSTEM";
-  str = pool_solvid2str(pool, p);
+  n = pool_id2str(pool, s->name);
+  e = pool_id2str(pool, s->evr);
+  a = pool_id2str(pool, s->arch);
+  str = pool_alloctmpspace(pool, strlen(n) + strlen(e) + strlen(a) + 3);
+  sprintf(str, "%s-%s.%s", n, e, a);
   if (!s->repo)
     return pool_tmpappend(pool, str, "@", 0);
   if (s->repo->name)
@@ -502,6 +658,50 @@ testcase_job2str(Pool *pool, Id how, Id what)
   return ret;
 }
 
+static int
+str2selflags(Pool *pool, char *s)      /* modifies the string! */
+{
+  int i, selflags = 0;
+  while (s)
+    {
+      char *se = strchr(s, ',');
+      if (se)
+       *se++ = 0;
+      for (i = 0; selflags2str[i].str; i++)
+       if (!strcmp(s, selflags2str[i].str))
+         {
+           selflags |= selflags2str[i].flag;
+           break;
+         }
+      if (!selflags2str[i].str)
+       pool_debug(pool, SOLV_ERROR, "str2job: unknown selection flag '%s'\n", s);
+      s = se;
+    }
+  return selflags;
+}
+
+static int
+str2jobflags(Pool *pool, char *s)      /* modifies the string */
+{
+  int i, jobflags = 0;
+  while (s)
+    {
+      char *se = strchr(s, ',');
+      if (se)
+       *se++ = 0;
+      for (i = 0; jobflags2str[i].str; i++)
+       if (!strcmp(s, jobflags2str[i].str))
+         {
+           jobflags |= jobflags2str[i].flag;
+           break;
+         }
+      if (!jobflags2str[i].str)
+       pool_debug(pool, SOLV_ERROR, "str2job: unknown job flag '%s'\n", s);
+      s = se;
+    }
+  return jobflags;
+}
+
 Id
 testcase_str2job(Pool *pool, const char *str, Id *whatp)
 {
@@ -532,7 +732,8 @@ testcase_str2job(Pool *pool, const char *str, Id *whatp)
   if (npieces < 3)
     {
       pool_debug(pool, SOLV_ERROR, "str2job: bad line '%s'\n", str);
-      return 0;
+      solv_free(pieces);
+      return -1;
     }
 
   for (i = 0; job2str[i].str; i++)
@@ -541,34 +742,20 @@ testcase_str2job(Pool *pool, const char *str, Id *whatp)
   if (!job2str[i].str)
     {
       pool_debug(pool, SOLV_ERROR, "str2job: unknown job '%s'\n", str);
-      return 0;
+      solv_free(pieces);
+      return -1;
     }
   job = job2str[i].job;
+  what = 0;
   if (npieces > 3)
     {
       char *flags = pieces[npieces - 1];
-      char *nf;
       if (*flags == '[' && flags[strlen(flags) - 1] == ']')
        {
          npieces--;
          flags++;
-         flags[strlen(flags) - 1] = ',';
-         while (*flags)
-           {
-             for (nf = flags; *nf != ','; nf++)
-               ;
-             *nf++ = 0;
-             for (i = 0; jobflags2str[i].str; i++)
-               if (!strcmp(flags, jobflags2str[i].str))
-                 break;
-             if (!jobflags2str[i].str)
-               {
-                 pool_debug(pool, SOLV_ERROR, "str2job: unknown jobflags in '%s'\n", str);
-                 return 0;
-               }
-             job |= jobflags2str[i].flag;
-             flags = nf;
-           }
+         flags[strlen(flags) - 1] = 0;
+         job |= str2jobflags(pool, flags);
        }
     }
   if (!strcmp(pieces[1], "pkg"))
@@ -576,14 +763,16 @@ testcase_str2job(Pool *pool, const char *str, Id *whatp)
       if (npieces != 3)
        {
          pool_debug(pool, SOLV_ERROR, "str2job: bad pkg selector in '%s'\n", str);
-         return 0;
+         solv_free(pieces);
+         return -1;
        }
       job |= SOLVER_SOLVABLE;
       what = testcase_str2solvid(pool, pieces[2]);
       if (!what)
        {
          pool_debug(pool, SOLV_ERROR, "str2job: unknown package '%s'\n", pieces[2]);
-         return 0;
+         solv_free(pieces);
+         return -1;
        }
     }
   else if (!strcmp(pieces[1], "name") || !strcmp(pieces[1], "provides"))
@@ -593,7 +782,25 @@ testcase_str2job(Pool *pool, const char *str, Id *whatp)
       for (sp = pieces[2]; sp < pieces[npieces - 1]; sp++)
        if (*sp == 0)
          *sp = ' ';
-      what = testcase_str2dep(pool, pieces[2]);
+      what = 0;
+      if (pieces[1][0] == 'p' && strncmp(pieces[2], "namespace:", 10) == 0)
+       {
+         char *spe = strchr(pieces[2], '(');
+         int l = strlen(pieces[2]);
+         if (spe && pieces[2][l - 1] == ')')
+           {
+             /* special namespace provides */
+             if (strcmp(spe, "(<NULL>)") != 0)
+               {
+                 pieces[2][l - 1] = 0;
+                 what = testcase_str2dep(pool, spe + 1);
+                 pieces[2][l - 1] = ')';
+               }
+             what = pool_rel2id(pool, pool_strn2id(pool, pieces[2], spe - pieces[2], 1), what, REL_NAMESPACE, 1);
+           }
+       }
+      if (!what)
+        what = testcase_str2dep(pool, pieces[2]);
       if (pieces[1][0] == 'n')
        job |= SOLVER_SOLVABLE_NAME;
       else
@@ -613,7 +820,8 @@ testcase_str2job(Pool *pool, const char *str, Id *whatp)
                {
                  pool_debug(pool, SOLV_ERROR, "str2job: unknown package '%s'\n", pieces[i]);
                  queue_free(&q);
-                 return 0;
+                 solv_free(pieces);
+                 return -1;
                }
              queue_push(&q, p);
            }
@@ -627,13 +835,15 @@ testcase_str2job(Pool *pool, const char *str, Id *whatp)
       if (npieces != 3)
        {
          pool_debug(pool, SOLV_ERROR, "str2job: bad line '%s'\n", str);
-         return 0;
+         solv_free(pieces);
+         return -1;
        }
       repo = testcase_str2repo(pool, pieces[2]);
       if (!repo)
        {
          pool_debug(pool, SOLV_ERROR, "str2job: unknown repo '%s'\n", pieces[2]);
-         return 0;
+         solv_free(pieces);
+         return -1;
        }
       job |= SOLVER_SOLVABLE_REPO;
       what = repo->repoid;
@@ -643,7 +853,8 @@ testcase_str2job(Pool *pool, const char *str, Id *whatp)
       if (npieces != 3 && strcmp(pieces[2], "packages") != 0)
        {
          pool_debug(pool, SOLV_ERROR, "str2job: bad line '%s'\n", str);
-         return 0;
+         solv_free(pieces);
+         return -1;
        }
       job |= SOLVER_SOLVABLE_ALL;
       what = 0;
@@ -651,12 +862,56 @@ testcase_str2job(Pool *pool, const char *str, Id *whatp)
   else
     {
       pool_debug(pool, SOLV_ERROR, "str2job: unknown selection in '%s'\n", str);
-      return 0;
+      solv_free(pieces);
+      return -1;
     }
   *whatp = what;
+  solv_free(pieces);
   return job;
 }
 
+int
+addselectionjob(Pool *pool, char **pieces, int npieces, Queue *jobqueue)
+{
+  Id job;
+  int i, r;
+  int selflags;
+  Queue sel;
+
+  for (i = 0; job2str[i].str; i++)
+    if (!strcmp(pieces[0], job2str[i].str))
+      break;
+  if (!job2str[i].str)
+    {
+      pool_debug(pool, SOLV_ERROR, "selstr2job: unknown job '%s'\n", pieces[0]);
+      return -1;
+    }
+  job = job2str[i].job;
+  if (npieces > 3)
+    {
+      char *flags = pieces[npieces - 1];
+      if (*flags == '[' && flags[strlen(flags) - 1] == ']')
+       {
+         npieces--;
+         flags++;
+         flags[strlen(flags) - 1] = 0;
+         job |= str2jobflags(pool, flags);
+       }
+    }
+  if (npieces < 4)
+    {
+      pool_debug(pool, SOLV_ERROR, "selstr2job: no selection flags\n");
+      return -1;
+    }
+  selflags = str2selflags(pool, pieces[3]);
+  queue_init(&sel);
+  r = selection_make(pool, &sel, pieces[2], selflags);
+  for (i = 0; i < sel.count; i += 2)
+    queue_push2(jobqueue, job | sel.elements[i], sel.elements[i + 1]);
+  queue_free(&sel);
+  return r;
+}
+
 static void
 writedeps(Repo *repo, FILE *fp, const char *tag, Id key, Solvable *s, Offset off)
 {
@@ -681,7 +936,7 @@ writedeps(Repo *repo, FILE *fp, const char *tag, Id key, Solvable *s, Offset off
        }
       if (key == SOLVABLE_PROVIDES && id == SOLVABLE_FILEMARKER)
        {
-         prvdp = dp + 1;
+         prvdp = dp;
          continue;
        }
       idstr = pool_dep2str(pool, id);
@@ -782,7 +1037,7 @@ writedeps(Repo *repo, FILE *fp, const char *tag, Id key, Solvable *s, Offset off
 }
 
 int
-testcase_write_susetags(Repo *repo, FILE *fp)
+testcase_write_testtags(Repo *repo, FILE *fp)
 {
   Pool *pool = repo->pool;
   Solvable *s;
@@ -791,11 +1046,6 @@ testcase_write_susetags(Repo *repo, FILE *fp)
   const char *evr;
   const char *arch;
   const char *release;
-#if 0
-  const char *chksum;
-  Id chksumtype, type;
-  unsigned int medianr;
-#endif
   const char *tmp;
   unsigned int ti;
 
@@ -808,15 +1058,10 @@ testcase_write_susetags(Repo *repo, FILE *fp)
       release = strrchr(evr, '-');
       if (!release)
        release = evr + strlen(evr);
-      fprintf(fp, "=Pkg: %s %.*s %s %s\n", name, release - evr, evr, *release && release[1] ? release + 1 : "0", arch);
+      fprintf(fp, "=Pkg: %s %.*s %s %s\n", name, (int)(release - evr), evr, *release && release[1] ? release + 1 : "-", arch);
       tmp = solvable_lookup_str(s, SOLVABLE_SUMMARY);
       if (tmp)
         fprintf(fp, "=Sum: %s\n", tmp);
-#if 0
-      chksum = solvable_lookup_checksum(s, SOLVABLE_CHECKSUM, &chksumtype);
-      if (chksum)
-       fprintf(fp, "=Cks: %s %s\n", solv_chksum_type2str(chksumtype), chksum);
-#endif
       writedeps(repo, fp, "Req:", SOLVABLE_REQUIRES, s, s->requires);
       writedeps(repo, fp, "Prv:", SOLVABLE_PROVIDES, s, s->provides);
       writedeps(repo, fp, "Obs:", SOLVABLE_OBSOLETES, s, s->obsoletes);
@@ -825,55 +1070,255 @@ testcase_write_susetags(Repo *repo, FILE *fp)
       writedeps(repo, fp, "Sup:", SOLVABLE_SUPPLEMENTS, s, s->supplements);
       writedeps(repo, fp, "Sug:", SOLVABLE_SUGGESTS, s, s->suggests);
       writedeps(repo, fp, "Enh:", SOLVABLE_ENHANCES, s, s->enhances);
-#if 0
-      tmp = solvable_lookup_str(s, SOLVABLE_GROUP);
-      if (tmp)
-       fprintf(fp, "=Grp: %s\n", tmp);
-      tmp = solvable_lookup_str(s, SOLVABLE_LICENSE);
-      if (tmp)
-       fprintf(fp, "=Lic: %s\n", tmp);
-#endif
       if (s->vendor)
        fprintf(fp, "=Vnd: %s\n", pool_id2str(pool, s->vendor));
-#if 0
-      type = solvable_lookup_type(s, SOLVABLE_SOURCENAME);
-      if (type)
+      ti = solvable_lookup_num(s, SOLVABLE_BUILDTIME, 0);
+      if (ti)
+       fprintf(fp, "=Tim: %u\n", ti);
+    }
+  return 0;
+}
+
+static inline Offset
+adddep(Repo *repo, Offset olddeps, char *str, Id marker)
+{
+  Id id = *str == '/' ? pool_str2id(repo->pool, str, 1) : testcase_str2dep(repo->pool, str);
+  return repo_addid_dep(repo, olddeps, id, marker);
+}
+
+static void
+finish_solvable(Pool *pool, Repodata *data, Solvable *s, char *filelist, int nfilelist)
+{
+  if (nfilelist)
+    {
+      int l;
+      Id did;
+      for (l = 0; l < nfilelist; l += strlen(filelist + l) + 1)
+       {
+         char *p = strrchr(filelist + l, '/');
+         if (!p)
+           continue;
+         *p++ = 0;
+         did = repodata_str2dir(data, filelist + l, 1);
+         p[-1] = '/';
+         if (!did)
+           did = repodata_str2dir(data, "/", 1);
+         repodata_add_dirstr(data, s - pool->solvables, SOLVABLE_FILELIST, did, p);
+       }
+    }
+  if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
+    s->provides = repo_addid_dep(s->repo, s->provides, pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
+  s->supplements = repo_fix_supplements(s->repo, s->provides, s->supplements, 0);
+  s->conflicts = repo_fix_conflicts(s->repo, s->conflicts);
+}
+
+/* stripped down version of susetags parser used for testcases */
+int
+testcase_add_testtags(Repo *repo, FILE *fp, int flags)
+{
+  Pool *pool = repo->pool;
+  char *line, *linep;
+  int aline;
+  int tag;
+  Repodata *data;
+  Solvable *s;
+  char *sp[5];
+  unsigned int t;
+  int intag;
+  char *filelist = 0;
+  int afilelist = 0;
+  int nfilelist = 0;
+
+  data = repo_add_repodata(repo, flags);
+  s = 0;
+  intag = 0;
+
+  aline = 1024;
+  line = solv_malloc(aline);
+  linep = line;
+  for (;;)
+    {
+      if (linep - line + 16 > aline)
+       {
+         aline = linep - line;
+         line = solv_realloc(line, aline + 512);
+         linep = line + aline;
+         aline += 512;
+       }
+      if (!fgets(linep, aline - (linep - line), fp))
+       break;
+      linep += strlen(linep);
+      if (linep == line || linep[-1] != '\n')
+       continue;
+      linep[-1] = 0;
+      linep = line + intag;
+      if (intag)
        {
-         if (type != REPOKEY_TYPE_VOID)
-           name = solvable_lookup_str(s, SOLVABLE_SOURCENAME);
-         type = solvable_lookup_type(s, SOLVABLE_SOURCEEVR);
-         if (type)
+         if (line[intag] == '-' && !strncmp(line + 1, line + intag + 1, intag - 2))
            {
-             if (type != REPOKEY_TYPE_VOID)
-               evr = solvable_lookup_str(s, SOLVABLE_SOURCEEVR);
-             release = strrchr(evr, '-');
-             if (!release)
-               release = evr + strlen(evr);
-             fprintf(fp, "=Src: %s %.*s %s %s\n", name, release - evr, evr, *release && release[1] ? release + 1 : "0", solvable_lookup_str(s, SOLVABLE_SOURCEARCH));
+             intag = 0;
+             linep = line;
+             continue;
            }
        }
-#endif
-      ti = solvable_lookup_num(s, SOLVABLE_BUILDTIME, 0);
-      if (ti)
-       fprintf(fp, "=Tim: %u\n", ti);
-#if 0
-      tmp = solvable_get_location(s, &medianr);
-      if (tmp)
+      else if (line[0] == '+' && line[1] && line[1] != ':')
        {
-         const char *base = strrchr(tmp, '/');
-         if (!base)
-            fprintf(fp, "=Loc: %d %s\n", medianr, tmp);
-         else if (strlen(arch) == base - tmp && !strncmp(tmp, arch, base - tmp))
-            fprintf(fp, "=Loc: %d %s\n", medianr, base + 1);
-         else
-            fprintf(fp, "=Loc: %d %s %.*s\n", medianr, base + 1, base - tmp, tmp);
+         char *tagend = strchr(line, ':');
+         if (!tagend)
+           continue;
+         line[0] = '=';
+         tagend[1] = ' ';
+         intag = tagend + 2 - line;
+         linep = line + intag;
+         continue;
        }
-#endif
+      if (*line != '=' || !line[1] || !line[2] || !line[3] || line[4] != ':')
+       continue;
+      tag = line[1] << 16 | line[2] << 8 | line[3];
+      switch(tag)
+        {
+       case 'P' << 16 | 'k' << 8 | 'g':
+         if (s)
+           finish_solvable(pool, data, s, filelist, nfilelist);
+         nfilelist = 0;
+         if (split(line + 5, sp, 5) != 4)
+           break;
+         s = pool_id2solvable(pool, repo_add_solvable(repo));
+         s->name = pool_str2id(pool, sp[0], 1);
+         /* join back version and release */
+         if (sp[2] && !(sp[2][0] == '-' && !sp[2][1]))
+           sp[2][-1] = '-';
+         s->evr = makeevr(pool, sp[1]);
+         s->arch = pool_str2id(pool, sp[3], 1);
+         break;
+       case 'S' << 16 | 'u' << 8 | 'm':
+         repodata_set_str(data, s - pool->solvables, SOLVABLE_SUMMARY, line + 6);
+         break;
+       case 'V' << 16 | 'n' << 8 | 'd':
+         s->vendor = pool_str2id(pool, line + 6, 1);
+         break;
+       case 'T' << 16 | 'i' << 8 | 'm':
+         t = atoi(line + 6);
+         if (t)
+           repodata_set_num(data, s - pool->solvables, SOLVABLE_BUILDTIME, t);
+         break;
+       case 'R' << 16 | 'e' << 8 | 'q':
+         s->requires = adddep(repo, s->requires, line + 6, -SOLVABLE_PREREQMARKER);
+         break;
+       case 'P' << 16 | 'r' << 8 | 'q':
+         s->requires = adddep(repo, s->requires, line + 6, SOLVABLE_PREREQMARKER);
+         break;
+       case 'P' << 16 | 'r' << 8 | 'v':
+         if (line[6] == '/')
+           {
+             int l = strlen(line + 6) + 1;
+             if (nfilelist + l > afilelist)
+               {
+                 afilelist = nfilelist + l + 512;
+                 filelist = solv_realloc(filelist, afilelist);
+               }
+             memcpy(filelist + nfilelist, line + 6, l);
+             nfilelist += l;
+             break;
+           }
+         if (nfilelist)
+           {
+             int l;
+             for (l = 0; l < nfilelist; l += strlen(filelist + l) + 1)
+                s->provides = repo_addid_dep(repo, s->provides, pool_str2id(pool, filelist + l, 1), 0);
+              nfilelist = 0;
+           }
+         s->provides = adddep(repo, s->provides, line + 6, 0);
+         break;
+       case 'O' << 16 | 'b' << 8 | 's':
+         s->obsoletes = adddep(repo, s->obsoletes, line + 6, 0);
+         break;
+       case 'C' << 16 | 'o' << 8 | 'n':
+         s->conflicts = adddep(repo, s->conflicts, line + 6, 0);
+         break;
+       case 'R' << 16 | 'e' << 8 | 'c':
+         s->recommends = adddep(repo, s->recommends, line + 6, 0);
+         break;
+       case 'S' << 16 | 'u' << 8 | 'p':
+         s->supplements = adddep(repo, s->supplements, line + 6, 0);
+         break;
+       case 'S' << 16 | 'u' << 8 | 'g':
+         s->suggests = adddep(repo, s->suggests, line + 6, 0);
+         break;
+       case 'E' << 16 | 'n' << 8 | 'h':
+         s->enhances = adddep(repo, s->enhances, line + 6, 0);
+         break;
+        default:
+         break;
+        }
     }
+  if (s)
+    finish_solvable(pool, data, s, filelist, nfilelist);
+  solv_free(line);
+  solv_free(filelist);
+  repodata_free_dircache(data);
+  if (!(flags & REPO_NO_INTERNALIZE))
+    repodata_internalize(data);
   return 0;
 }
 
 const char *
+testcase_getpoolflags(Pool *pool)
+{
+  const char *str = 0;
+  int i, v;
+  for (i = 0; poolflags2str[i].str; i++)
+    {
+      v = pool_get_flag(pool, poolflags2str[i].flag);
+      if (v == poolflags2str[i].def)
+       continue;
+      str = pool_tmpappend(pool, str, v ? " " : " !", poolflags2str[i].str);
+    }
+  return str ? str + 1 : "";
+}
+
+int
+testcase_setpoolflags(Pool *pool, const char *str)
+{
+  const char *p = str, *s;
+  int i, v;
+  for (;;)
+    {
+      while (*p == ' ' || *p == '\t' || *p == ',')
+       p++;
+      v = 1;
+      if (*p == '!')
+       {
+         p++;
+         v = 0;
+       }
+      if (!*p)
+       break;
+      s = p;
+      while (*p && *p != ' ' && *p != '\t' && *p != ',')
+       p++;
+      for (i = 0; poolflags2str[i].str; i++)
+       if (!strncmp(poolflags2str[i].str, s, p - s) && poolflags2str[i].str[p - s] == 0)
+         break;
+      if (!poolflags2str[i].str)
+       {
+         pool_debug(pool, SOLV_ERROR, "setpoolflags: unknown flag '%.*s'\n", (int)(p - s), s);
+         return 0;
+       }
+      pool_set_flag(pool, poolflags2str[i].flag, v);
+    }
+  return 1;
+}
+
+void
+testcase_resetpoolflags(Pool *pool)
+{
+  int i;
+  for (i = 0; poolflags2str[i].str; i++)
+    pool_set_flag(pool, poolflags2str[i].flag, poolflags2str[i].def);
+}
+
+const char *
 testcase_getsolverflags(Solver *solv)
 {
   Pool *pool = solv->pool;
@@ -914,7 +1359,7 @@ testcase_setsolverflags(Solver *solv, const char *str)
          break;
       if (!solverflags2str[i].str)
        {
-         pool_debug(solv->pool, SOLV_ERROR, "setsolverflags: unknown flag '%.*s'\n", p - s, s);
+         pool_debug(solv->pool, SOLV_ERROR, "setsolverflags: unknown flag '%.*s'\n", (int)(p - s), s);
          return 0;
        }
       solver_set_flag(solv, solverflags2str[i].flag, v);
@@ -936,7 +1381,7 @@ testcase_ruleid(Solver *solv, Id rid)
   Strqueue sq;
   Queue q;
   int i;
-  void *chk;
+  Chksum *chk;
   const unsigned char *md5;
   int md5l;
   const char *s;
@@ -969,7 +1414,7 @@ testcase_problemid(Solver *solv, Id problem)
 {
   Strqueue sq;
   Queue q;
-  void *chk;
+  Chksum *chk;
   const unsigned char *md5;
   int i, md5l;
   const char *s;
@@ -996,7 +1441,7 @@ static const char *
 testcase_solutionid(Solver *solv, Id problem, Id solution)
 {
   Id intid;
-  void *chk;
+  Chksum *chk;
   const unsigned char *md5;
   int md5l;
   const char *s;
@@ -1038,77 +1483,144 @@ static struct class2str {
 };
 
 char *
-testcase_solverresult(Solver *solv)
+testcase_solverresult(Solver *solv, int resultflags)
 {
   Pool *pool = solv->pool;
-  Transaction *trans;
-  Queue q;
   int i, j;
   Id p, op;
   const char *s;
-  char *probprefix, *solprefix, *result;
-  int problem, solution, element;
-  int pcnt, scnt;
+  char *result;
   Strqueue sq;
 
   strqueue_init(&sq);
-  trans = solver_create_transaction(solv);
-  queue_init(&q);
-  for (i = 0; class2str[i].str; i++)
+  if ((resultflags & TESTCASE_RESULT_TRANSACTION) != 0)
     {
-      queue_empty(&q);
-      transaction_classify_pkgs(trans, 0, class2str[i].class, 0, 0, &q);
-      for (j = 0; j < q.count; j++)
+      Transaction *trans = solver_create_transaction(solv);
+      Queue q;
+
+      queue_init(&q);
+      for (i = 0; class2str[i].str; i++)
        {
-         p = q.elements[j];
-          op = 0;
-         if (pool->installed && pool->solvables[p].repo == pool->installed)
-           op = transaction_obs_pkg(trans, p);
-         s = pool_tmpjoin(pool, class2str[i].str, " ", testcase_solvid2str(pool, p));
-         if (op)
-           s = pool_tmpjoin(pool, s, " ", testcase_solvid2str(pool, op));
-         strqueue_push(&sq, s);
+         queue_empty(&q);
+         transaction_classify_pkgs(trans, SOLVER_TRANSACTION_KEEP_PSEUDO, class2str[i].class, 0, 0, &q);
+         for (j = 0; j < q.count; j++)
+           {
+             p = q.elements[j];
+             op = 0;
+             if (pool->installed && pool->solvables[p].repo == pool->installed)
+               op = transaction_obs_pkg(trans, p);
+             s = pool_tmpjoin(pool, class2str[i].str, " ", testcase_solvid2str(pool, p));
+             if (op)
+               s = pool_tmpjoin(pool, s, " ", testcase_solvid2str(pool, op));
+             strqueue_push(&sq, s);
+           }
        }
+      queue_free(&q);
+      transaction_free(trans);
     }
-  queue_free(&q);
-  transaction_free(trans);
-  pcnt = solver_problem_count(solv);
-  for (problem = 1; problem <= pcnt; problem++)
-    {
-      Id rid, from, to, dep;
-      SolverRuleinfo rinfo;
-      rid = solver_findproblemrule(solv, problem);
-      s = testcase_problemid(solv, problem);
-      probprefix = solv_dupjoin("problem ", s, 0);
-      rinfo = solver_ruleinfo(solv, rid, &from, &to, &dep);
-      s = pool_tmpjoin(pool, probprefix, " info ", solver_problemruleinfo2str(solv, rinfo, from, to, dep));
-      strqueue_push(&sq, s);
-      scnt = solver_solution_count(solv, problem);
-      for (solution = 1; solution <= scnt; solution++)
+  if ((resultflags & TESTCASE_RESULT_PROBLEMS) != 0)
+    {
+      char *probprefix, *solprefix;
+      int problem, solution, element;
+      int pcnt, scnt;
+
+      pcnt = solver_problem_count(solv);
+      for (problem = 1; problem <= pcnt; problem++)
        {
-         s = testcase_solutionid(solv, problem, solution);
-         solprefix = solv_dupjoin(probprefix, " solution ", s);
-         element = 0;
-         while ((element = solver_next_solutionelement(solv, problem, solution, element, &p, &op)) != 0)
+         Id rid, from, to, dep;
+         SolverRuleinfo rinfo;
+         rid = solver_findproblemrule(solv, problem);
+         s = testcase_problemid(solv, problem);
+         probprefix = solv_dupjoin("problem ", s, 0);
+         rinfo = solver_ruleinfo(solv, rid, &from, &to, &dep);
+         s = pool_tmpjoin(pool, probprefix, " info ", solver_problemruleinfo2str(solv, rinfo, from, to, dep));
+         strqueue_push(&sq, s);
+         scnt = solver_solution_count(solv, problem);
+         for (solution = 1; solution <= scnt; solution++)
            {
-             if (p == SOLVER_SOLUTION_JOB)
-               s = pool_tmpjoin(pool, solprefix, " deljob ", testcase_job2str(pool, solv->job.elements[op - 1], solv->job.elements[op]));
-             else if (p > 0 && op == 0)
-               s = pool_tmpjoin(pool, solprefix, " erase ", testcase_solvid2str(pool, p));
-             else if (p > 0 && op > 0)
+             s = testcase_solutionid(solv, problem, solution);
+             solprefix = solv_dupjoin(probprefix, " solution ", s);
+             element = 0;
+             while ((element = solver_next_solutionelement(solv, problem, solution, element, &p, &op)) != 0)
                {
-                 s = pool_tmpjoin(pool, solprefix, " replace ", testcase_solvid2str(pool, p));
-                 s = pool_tmpappend(pool, s, " ", testcase_solvid2str(pool, op));
+                 if (p == SOLVER_SOLUTION_JOB)
+                   s = pool_tmpjoin(pool, solprefix, " deljob ", testcase_job2str(pool, solv->job.elements[op - 1], solv->job.elements[op]));
+                 else if (p > 0 && op == 0)
+                   s = pool_tmpjoin(pool, solprefix, " erase ", testcase_solvid2str(pool, p));
+                 else if (p > 0 && op > 0)
+                   {
+                     s = pool_tmpjoin(pool, solprefix, " replace ", testcase_solvid2str(pool, p));
+                     s = pool_tmpappend(pool, s, " ", testcase_solvid2str(pool, op));
+                   }
+                 else if (p < 0 && op > 0)
+                   s = pool_tmpjoin(pool, solprefix, " allow ", testcase_solvid2str(pool, op));
+                 else
+                   s = pool_tmpjoin(pool, solprefix, " unknown", 0);
+                 strqueue_push(&sq, s);
                }
-             else if (p < 0 && op > 0)
-               s = pool_tmpjoin(pool, solprefix, " allow ", testcase_solvid2str(pool, op));
-             else
-               s = pool_tmpjoin(pool, solprefix, " unknown", 0);
-             strqueue_push(&sq, s);
+             solv_free(solprefix);
+           }
+         solv_free(probprefix);
+       }
+    }
+
+  if ((resultflags & TESTCASE_RESULT_ORPHANED) != 0)
+    {
+      Queue q;
+
+      queue_init(&q);
+      solver_get_orphaned(solv, &q);
+      for (i = 0; i < q.count; i++)
+       {
+         s = pool_tmpjoin(pool, "orphaned ", testcase_solvid2str(pool, q.elements[i]), 0);
+         strqueue_push(&sq, s);
+       }
+      queue_free(&q);
+    }
+
+  if ((resultflags & TESTCASE_RESULT_RECOMMENDED) != 0)
+    {
+      Queue qr, qs;
+
+      queue_init(&qr);
+      queue_init(&qs);
+      solver_get_recommendations(solv, &qr, &qs, 0);
+      for (i = 0; i < qr.count; i++)
+       {
+         s = pool_tmpjoin(pool, "recommended ", testcase_solvid2str(pool, qr.elements[i]), 0);
+         strqueue_push(&sq, s);
+       }
+      for (i = 0; i < qs.count; i++)
+       {
+         s = pool_tmpjoin(pool, "suggested ", testcase_solvid2str(pool, qs.elements[i]), 0);
+         strqueue_push(&sq, s);
+       }
+      queue_free(&qr);
+      queue_free(&qs);
+    }
+
+  if ((resultflags & TESTCASE_RESULT_UNNEEDED) != 0)
+    {
+      Queue q, qf;
+
+      queue_init(&q);
+      queue_init(&qf);
+      solver_get_unneeded(solv, &q, 0);
+      solver_get_unneeded(solv, &qf, 1);
+      for (i = j = 0; i < q.count; i++)
+       {
+         /* we rely on qf containing a subset of q in the same order */
+         if (j < qf.count && q.elements[i] == qf.elements[j])
+           {
+             s = pool_tmpjoin(pool, "unneeded_filtered ", testcase_solvid2str(pool, q.elements[i]), 0);
+             j++;
            }
-         solv_free(solprefix);
+         else
+           s = pool_tmpjoin(pool, "unneeded ", testcase_solvid2str(pool, q.elements[i]), 0);
+         strqueue_push(&sq, s);
        }
-      solv_free(probprefix);
+      queue_free(&q);
+      queue_free(&qf);
     }
 
   strqueue_sort(&sq);
@@ -1119,7 +1631,7 @@ testcase_solverresult(Solver *solv)
 
 
 int
-testcase_write(Solver *solv, char *dir, int withresult)
+testcase_write(Solver *solv, char *dir, int resultflags, const char *testcasename, const char *resultname)
 {
   Pool *pool = solv->pool;
   Repo *repo;
@@ -1131,6 +1643,11 @@ testcase_write(Solver *solv, char *dir, int withresult)
   char *cmd, *out;
   const char *s;
 
+  if (!testcasename)
+    testcasename = "testcase.t";
+  if (!resultname)
+    resultname = "solver.result";
+
   if (mkdir(dir, 0777) && errno != EEXIST)
     {
       pool_debug(solv->pool, SOLV_ERROR, "testcase_write: could not create directory '%s'\n", dir);
@@ -1148,7 +1665,7 @@ testcase_write(Solver *solv, char *dir, int withresult)
       out = pool_tmpjoin(pool, name, ".repo", ".gz");
       cmd = pool_tmpjoin(pool, "repo ", name, " ");
       cmd = pool_tmpappend(pool, cmd, priobuf, " ");
-      cmd = pool_tmpappend(pool, cmd, "susetags ", out);
+      cmd = pool_tmpappend(pool, cmd, "testtags ", out);
       strqueue_push(&sq, cmd);
       out = pool_tmpjoin(pool, dir, "/", out);
       if (!(fp = solv_xfopen(out, "w")))
@@ -1157,7 +1674,7 @@ testcase_write(Solver *solv, char *dir, int withresult)
          strqueue_free(&sq);
          return 0;
        }
-      testcase_write_susetags(repo, fp);
+      testcase_write_testtags(repo, fp);
       if (fclose(fp))
        {
          pool_debug(solv->pool, SOLV_ERROR, "testcase_write: write error\n");
@@ -1167,7 +1684,7 @@ testcase_write(Solver *solv, char *dir, int withresult)
     }
   /* hmm, this is not optimal... we currently search for the lowest score */
   lowscore = 0;
-  arch = ARCH_NOARCH;
+  arch = pool->solvables[SYSTEMSOLVABLE].arch;
   for (i = 0; i < pool->lastarch; i++)
     {
       if (pool->id2arch[i] == 1 && !lowscore)
@@ -1178,10 +1695,20 @@ testcase_write(Solver *solv, char *dir, int withresult)
          lowscore = pool->id2arch[i];
        }
     }
-  cmd = pool_tmpjoin(pool, "system ", pool_id2str(pool, arch), pool->disttype == DISTTYPE_DEB ? " deb" : " rpm");
+  cmd = pool_tmpjoin(pool, "system ", pool->lastarch ? pool_id2str(pool, arch) : "unset", 0);
+  for (i = 0; disttype2str[i].str != 0; i++)
+    if (pool->disttype == disttype2str[i].type)
+      break;
+  pool_tmpappend(pool, cmd, " ", disttype2str[i].str ? disttype2str[i].str : "unknown");
   if (pool->installed)
     cmd = pool_tmpappend(pool, cmd, " ", testcase_repoid2str(pool, pool->installed->repoid));
   strqueue_push(&sq, cmd);
+  s = testcase_getpoolflags(solv->pool);
+  if (*s)
+    {
+      cmd = pool_tmpjoin(pool, "poolflags ", s, 0);
+      strqueue_push(&sq, cmd);
+    }
 
   if (pool->vendorclasses)
     {
@@ -1215,8 +1742,9 @@ testcase_write(Solver *solv, char *dir, int withresult)
          Reldep *rd = pool->rels + rid;
          if (rd->flags != REL_NAMESPACE || rd->name == NAMESPACE_OTHERPROVIDERS)
            continue;
-         /* check if we evaluated it, also skip empty results */
-         if (!(d = pool->whatprovides_rel[rid]) || !pool->whatprovidesdata[d])
+         /* evaluate all namespace ids, skip empty results */
+         d = pool_whatprovides(pool, MAKERELDEP(rid));
+         if (!d || !pool->whatprovidesdata[d])
            continue;
          cmd = pool_tmpjoin(pool, "namespace ", pool_id2str(pool, rd->name), "(");
          cmd = pool_tmpappend(pool, cmd, pool_id2str(pool, rd->evr), ")");
@@ -1233,47 +1761,71 @@ testcase_write(Solver *solv, char *dir, int withresult)
       strqueue_push(&sq, cmd);
     }
 
-  if (withresult)
+  if (resultflags)
     {
       char *result;
-      out = pool_tmpjoin(pool, dir, "/", "solver.result");
-      if (!(fp = fopen(out, "w")))
+      cmd = 0;
+      for (i = 0; resultflags2str[i].str; i++)
+       if ((resultflags & resultflags2str[i].flag) != 0)
+         cmd = pool_tmpappend(pool, cmd, cmd ? "," : 0, resultflags2str[i].str);
+      cmd = pool_tmpjoin(pool, "result ", cmd ? cmd : "?", 0);
+      cmd = pool_tmpappend(pool, cmd, " ", resultname);
+      strqueue_push(&sq, cmd);
+      result = testcase_solverresult(solv, resultflags);
+      if (!strcmp(resultname, "<inline>"))
        {
-         pool_debug(solv->pool, SOLV_ERROR, "testcase_write: could not open '%s' for writing\n", out);
-         strqueue_free(&sq);
-         return 0;
+         int i;
+         Strqueue rsq;
+         strqueue_init(&rsq);
+         strqueue_split(&rsq, result);
+         for (i = 0; i < rsq.nstr; i++)
+           {
+             cmd = pool_tmpjoin(pool, "#>", rsq.str[i], 0);
+             strqueue_push(&sq, cmd);
+           }
+         strqueue_free(&rsq);
        }
-      result = testcase_solverresult(solv);
-      if (fwrite(result, strlen(result), 1, fp) != 1)
+      else
        {
-         pool_debug(solv->pool, SOLV_ERROR, "testcase_write: write error\n");
-         solv_free(result);
-         strqueue_free(&sq);
-         return 0;
+         out = pool_tmpjoin(pool, dir, "/", resultname);
+         if (!(fp = fopen(out, "w")))
+           {
+             pool_debug(solv->pool, SOLV_ERROR, "testcase_write: could not open '%s' for writing\n", out);
+             solv_free(result);
+             strqueue_free(&sq);
+             return 0;
+           }
+         if (result && *result && fwrite(result, strlen(result), 1, fp) != 1)
+           {
+             pool_debug(solv->pool, SOLV_ERROR, "testcase_write: write error\n");
+             solv_free(result);
+             strqueue_free(&sq);
+             fclose(fp);
+             return 0;
+           }
+         if (fclose(fp))
+           {
+             pool_debug(solv->pool, SOLV_ERROR, "testcase_write: write error\n");
+             strqueue_free(&sq);
+             return 0;
+           }
        }
       solv_free(result);
-      if (fclose(fp))
-       {
-         pool_debug(solv->pool, SOLV_ERROR, "testcase_write: write error\n");
-         strqueue_free(&sq);
-         return 0;
-       }
-      cmd = pool_tmpjoin(pool, "result ", "solver.result", 0);
-      strqueue_push(&sq, cmd);
     }
 
   cmd = strqueue_join(&sq);
-  out = pool_tmpjoin(pool, dir, "/", "testcase.t");
+  out = pool_tmpjoin(pool, dir, "/", testcasename);
   if (!(fp = fopen(out, "w")))
     {
       pool_debug(solv->pool, SOLV_ERROR, "testcase_write: could not open '%s' for writing\n", out);
       strqueue_free(&sq);
       return 0;
     }
-  if (fwrite(cmd, strlen(cmd), 1, fp) != 1)
+  if (*cmd && fwrite(cmd, strlen(cmd), 1, fp) != 1)
     {
       pool_debug(solv->pool, SOLV_ERROR, "testcase_write: write error\n");
       strqueue_free(&sq);
+      fclose(fp);
       return 0;
     }
   if (fclose(fp))
@@ -1287,8 +1839,113 @@ testcase_write(Solver *solv, char *dir, int withresult)
   return 1;
 }
 
+static char *
+read_inline_file(FILE *fp, char **bufp, char **bufpp, int *buflp)
+{
+  char *result = solv_malloc(1024);
+  char *rp = result;
+  int resultl = 1024;
+
+  for (;;)
+    {
+      size_t rl;
+      if (rp - result + 256 >= resultl)
+       {
+         resultl = rp - result;
+         result = solv_realloc(result, resultl + 1024);
+         rp = result + resultl;
+         resultl += 1024;
+       }
+      if (!fgets(rp, resultl - (rp - result), fp))
+       *rp = 0;
+      rl = strlen(rp);
+      if (rl && (rp == result || rp[-1] == '\n'))
+       {
+         if (rl > 1 && rp[0] == '#' && rp[1] == '>')
+           {
+             memmove(rp, rp + 2, rl - 2);
+             rl -= 2;
+           }
+         else
+           {
+             while (rl + 16 > *buflp)
+               {
+                 *bufp = solv_realloc(*bufp, *buflp + 512);
+                 *buflp += 512;
+               }
+             memmove(*bufp, rp, rl);
+             if ((*bufp)[rl - 1] == '\n')
+               {
+                 ungetc('\n', fp);
+                 rl--;
+               }
+             (*bufp)[rl] = 0;
+             (*bufpp) = *bufp + rl;
+             rl = 0;
+           }
+       }
+      if (rl <= 0)
+       {
+         *rp = 0;
+         break;
+       }
+      rp += rl;
+    }
+  return result;
+}
+
+static char *
+read_file(FILE *fp)
+{
+  char *result = solv_malloc(1024);
+  char *rp = result;
+  int resultl = 1024;
+
+  for (;;)
+    {
+      size_t rl;
+      if (rp - result + 256 >= resultl)
+       {
+         resultl = rp - result;
+         result = solv_realloc(result, resultl + 1024);
+         rp = result + resultl;
+         resultl += 1024;
+       }
+      rl = fread(rp, 1, resultl - (rp - result), fp);
+      if (rl <= 0)
+       {
+         *rp = 0;
+         break;
+       }
+      rp += rl;
+    }
+  return result;
+}
+
+static int
+str2resultflags(Pool *pool, char *s)   /* modifies the string! */
+{
+  int i, resultflags = 0;
+  while (s)
+    {
+      char *se = strchr(s, ',');
+      if (se)
+       *se++ = 0;
+      for (i = 0; resultflags2str[i].str; i++)
+       if (!strcmp(s, resultflags2str[i].str))
+         {
+           resultflags |= resultflags2str[i].flag;
+           break;
+         }
+      if (!resultflags2str[i].str)
+       pool_debug(pool, SOLV_ERROR, "result: unknown flag '%s'\n", s);
+      s = se;
+    }
+  return resultflags;
+}
+
 Solver *
-testcase_read(Pool *pool, FILE *fp, char *testcase, Queue *job, char **resultp)
+testcase_read(Pool *pool, FILE *fp, char *testcase, Queue *job, char **resultp, int *resultflagsp)
 {
   Solver *solv;
   char *buf, *bufp;
@@ -1299,6 +1956,7 @@ testcase_read(Pool *pool, FILE *fp, char *testcase, Queue *job, char **resultp)
   int npieces = 0;
   int prepared = 0;
   int closefp = !fp;
+  int poolflagsreset = 0;
 
   if (!fp && !(fp = fopen(testcase, "r")))
     {
@@ -1306,7 +1964,7 @@ testcase_read(Pool *pool, FILE *fp, char *testcase, Queue *job, char **resultp)
       return 0;
     }
   testcasedir = solv_strdup(testcase);
-  if ((s = strchr(testcasedir, '/')) != 0)
+  if ((s = strrchr(testcasedir, '/')) != 0)
     s[1] = 0;
   else
     *testcasedir = 0;
@@ -1363,6 +2021,11 @@ testcase_read(Pool *pool, FILE *fp, char *testcase, Queue *job, char **resultp)
          const char *rdata;
 
          prepared = 0;
+          if (!poolflagsreset)
+           {
+             poolflagsreset = 1;
+             testcase_resetpoolflags(pool);    /* hmm */
+           }
          if (sscanf(pieces[2], "%d.%d", &prio, &subprio) != 2)
            {
              subprio = 0;
@@ -1370,26 +2033,73 @@ testcase_read(Pool *pool, FILE *fp, char *testcase, Queue *job, char **resultp)
            }
           repo->priority = prio;
           repo->subpriority = subprio;
-         rdata = pool_tmpjoin(pool, testcasedir, pieces[4], 0);
-          if ((rfp = solv_xfopen(rdata, "r")) == 0)
+         if (strcmp(pieces[3], "empty") != 0)
            {
-             pool_debug(pool, SOLV_ERROR, "testcase_read: could not open '%s'\n", rdata);
-           }
-         else if (!strcmp(pieces[3], "susetags"))
-           {
-             repo_add_susetags(repo, rfp, 0, 0, 0);
-             fclose(rfp);
-           }
-         else
-           {
-             fclose(rfp);
-             pool_debug(pool, SOLV_ERROR, "testcase_read: unknown repo type for repo '%s'\n", repo->name);
+             const char *repotype = pool_tmpjoin(pool, pieces[3], 0, 0);       /* gets overwritten in <inline> case */
+             if (!strcmp(pieces[4], "<inline>"))
+               {
+                 char *idata = read_inline_file(fp, &buf, &bufp, &bufl);
+                 rdata = "<inline>";
+                 rfp = solv_xfopen_buf(rdata, &idata, 0, "rf");
+               }
+             else
+               {
+                 rdata = pool_tmpjoin(pool, testcasedir, pieces[4], 0);
+                 rfp = solv_xfopen(rdata, "r");
+               }
+             if (!rfp)
+               {
+                 pool_debug(pool, SOLV_ERROR, "testcase_read: could not open '%s'\n", rdata);
+               }
+             else if (!strcmp(repotype, "testtags"))
+               {
+                 testcase_add_testtags(repo, rfp, 0);
+                 fclose(rfp);
+               }
+             else if (!strcmp(repotype, "solv"))
+               {
+                 repo_add_solv(repo, rfp, 0);
+                 fclose(rfp);
+               }
+#if 0
+             else if (!strcmp(repotype, "helix"))
+               {
+                 extern int repo_add_helix(Repo *repo, FILE *fp, int flags);
+                 repo_add_helix(repo, rfp, 0);
+                 fclose(rfp);
+               }
+#endif
+             else
+               {
+                 fclose(rfp);
+                 pool_debug(pool, SOLV_ERROR, "testcase_read: unknown repo type for repo '%s'\n", repo->name);
+               }
            }
        }
       else if (!strcmp(pieces[0], "system") && npieces >= 3)
        {
+         int i;
          prepared = 0;
-         pool_setarch(pool, pieces[1]);
+         /* must set the disttype before the arch */
+         for (i = 0; disttype2str[i].str != 0; i++)
+           if (!strcmp(disttype2str[i].str, pieces[2]))
+             break;
+         if (!disttype2str[i].str)
+           pool_debug(pool, SOLV_ERROR, "testcase_read: system: unknown disttype '%s'\n", pieces[2]);
+         else if (pool->disttype != disttype2str[i].type)
+           {
+#ifdef MULTI_SEMANTICS
+             pool_setdisttype(pool, disttype2str[i].type);
+#else
+             pool_debug(pool, SOLV_ERROR, "testcase_read: system: cannot change disttype to '%s'\n", pieces[2]);
+#endif
+           }
+         if (strcmp(pieces[1], "unset") == 0)
+           pool_setarch(pool, 0);
+         else if (pieces[1][0] == ':')
+           pool_setarchpolicy(pool, pieces[1] + 1);
+         else
+           pool_setarch(pool, pieces[1]);
          if (npieces > 3)
            {
              Repo *repo = testcase_str2repo(pool, pieces[3]);
@@ -1409,6 +2119,11 @@ testcase_read(Pool *pool, FILE *fp, char *testcase, Queue *job, char **resultp)
              pool_createwhatprovides(pool);
              prepared = 1;
            }
+         if (npieces >= 3 && !strcmp(pieces[2], "selection"))
+           {
+             addselectionjob(pool, pieces + 1, npieces - 1, job);
+             continue;
+           }
          /* rejoin */
          for (sp = pieces[1]; sp < pieces[npieces - 1]; sp++)
            if (*sp == 0)
@@ -1454,6 +2169,17 @@ testcase_read(Pool *pool, FILE *fp, char *testcase, Queue *job, char **resultp)
              queue_free(&q);
            }
        }
+      else if (!strcmp(pieces[0], "poolflags"))
+        {
+         int i;
+          if (!poolflagsreset)
+           {
+             poolflagsreset = 1;
+             testcase_resetpoolflags(pool);    /* hmm */
+           }
+         for (i = 1; i < npieces; i++)
+           testcase_setpoolflags(pool, pieces[i]);
+        }
       else if (!strcmp(pieces[0], "solverflags") && npieces > 1)
         {
          int i;
@@ -1467,82 +2193,36 @@ testcase_read(Pool *pool, FILE *fp, char *testcase, Queue *job, char **resultp)
         }
       else if (!strcmp(pieces[0], "result") && npieces > 1)
        {
-         FILE *rfp;
+         char *result = 0;
+         int resultflags = str2resultflags(pool, pieces[1]);
          const char *rdata;
-         rdata = pool_tmpjoin(pool, testcasedir, pieces[1], 0);
-         if (!strcmp(pieces[1], "<inline>"))
-           rfp = fp;
-         else
-            rfp = fopen(rdata, "r");
-          if (!rfp)
-           {
-             pool_debug(pool, SOLV_ERROR, "testcase_read: could not open '%s'\n", rdata);
-           }
-         else
+         if (npieces > 2)
            {
-             /* slurp it in... */
-             char *result = solv_malloc(1024);
-             char *rp = result;
-             int resultl = 1024;
-             for (;;)
+             rdata = pool_tmpjoin(pool, testcasedir, pieces[2], 0);
+             if (!strcmp(pieces[2], "<inline>"))
+               result = read_inline_file(fp, &buf, &bufp, &bufl);
+             else
                {
-                 size_t rl;
-                 if (rp - result + 256 >= resultl)
-                   {
-                     resultl = rp - result;
-                     result = solv_realloc(result, resultl + 1024);
-                     rp = result + resultl;
-                     resultl += 1024;
-                   }
-                 if (fp == rfp)
-                   {
-                     if (!fgets(rp, resultl - (rp - result), fp))
-                       rl = 0;
-                     else
-                       {
-                         rl = strlen(rp);
-                         if (rl && (rp == result || rp[-1] == '\n'))
-                           {
-                             if (rl > 1 && rp[0] == '#' && rp[1] == '>')
-                               {
-                                 memmove(rp, rp + 2, rl - 2);
-                                 rl -= 2;
-                               }
-                             else
-                               {
-                                 while (rl + 16 > bufl)
-                                   {
-                                     buf = solv_realloc(buf, bufl + 512);
-                                     bufl += 512;
-                                   }
-                                 memmove(buf, rp, rl);
-                                 if (buf[rl - 1] == '\n')
-                                   {
-                                     ungetc('\n', fp);
-                                     rl--;
-                                   }
-                                 bufp = buf + rl;
-                                 rl = 0;
-                               }
-                           }
-                       }
-                   }
+                 FILE *rfp = fopen(rdata, "r");
+                 if (!rfp)
+                   pool_debug(pool, SOLV_ERROR, "testcase_read: could not open '%s'\n", rdata);
                  else
-                   rl = fread(rp, 1, resultl - (rp - result), rfp);
-                 if (rl <= 0)
                    {
-                     *rp = 0;
-                     break;
+                     result = read_file(rfp);
+                     fclose(rfp);
                    }
-                 rp += rl;
                }
-             if (rfp != fp)
-               fclose(rfp);
-             if (resultp)
-               *resultp = result;
-             else
-               solv_free(result);
            }
+         if (resultp)
+           *resultp = result;
+         else
+           solv_free(result);
+         if (resultflagsp)
+           *resultflagsp = resultflags;
+       }
+      else if (!strcmp(pieces[0], "nextjob") && npieces == 1)
+       {
+         break;
        }
       else
        {