]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Add a way to test the suse dep transformation code
authorMichael Schroeder <mls@suse.de>
Mon, 9 Mar 2026 09:06:47 +0000 (10:06 +0100)
committerMichael Schroeder <mls@suse.de>
Mon, 9 Mar 2026 09:15:23 +0000 (10:15 +0100)
The "genid susedep <keyname>" pops a dep from the genid stack
and rewrites it according to the specified keyname.

ext/testcase.c
src/libsolv.ver
src/pool.h
src/suse.c

index f93861ce819c32d25c2d1687e63de7dfff47c167..5532a04efe6e1588e67f75074c1c40cbd88b65a9 100644 (file)
@@ -2585,6 +2585,15 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
            id = 0;
          else if (!strcmp(pieces[1], "dep"))
            id = testcase_str2dep(pool, pieces[2]);
+         else if (!strcmp(pieces[1], "susedep"))
+           {
+             if (ngenid < 1)
+               {
+                 pool_error(pool, 0, "testcase_read: genid: out of stack");
+                 break;
+               }
+             id = pool_rewrite_suse_dep(pool, pool_str2id(pool, pieces[2], -1), genid[--ngenid]);
+           }
          else
            {
              pool_error(pool, 0, "testcase_read: genid: unknown command '%s'", pieces[1]);
index d1e4f83e861f2de4fe042f9f3b68f1759da8f685..a5873f97ced98752c34abbd3a9351021d2b5c795 100644 (file)
@@ -96,6 +96,7 @@ SOLV_1.0 {
                pool_prepend_rootdir_tmp;
                pool_queuetowhatprovides;
                pool_rel2id;
+               pool_rewrite_suse_dep;
                pool_satisfieddep_map;
                pool_search;
                pool_selection2str;
index fa96be2c4f1a00724e5a3938551ecf53dfd42226..e85e96403ddd6a5a14ea361182698edbff8caa6c 100644 (file)
@@ -424,6 +424,7 @@ void pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts);
 /* weird suse stuff */
 void pool_trivial_installable_multiversionmap(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res, Map *multiversionmap);
 void pool_trivial_installable(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res);
+Id pool_rewrite_suse_dep(Pool *pool, Id keyname, Id id);
 
 #ifdef __cplusplus
 }
index 2533af912eccae937ed23456fd8ee8ef12a5faa3..45d1d65c28b751a016cde673f3f5480738788f49 100644 (file)
@@ -244,6 +244,32 @@ repo_rewrite_suse_deps(Solvable *s, Offset freshens)
     s->conflicts = repo_fix_conflicts(s->repo, s->conflicts);
 }
 
+Id
+pool_rewrite_suse_dep(Pool *pool, Id keyname, Id id)
+{
+  /* hack: use a synthetic repo. As this is only for testing it
+   * should not be a problem */
+  Repo repo;
+  Id idarraydata[5];
+  memset(&repo, 0, sizeof(repo));
+  idarraydata[0] = 0;
+  idarraydata[1] = id;
+  idarraydata[2] = 0;
+  idarraydata[3] = 0;
+  idarraydata[4] = 0;
+  repo.pool = pool;
+  repo.idarraydata = idarraydata;
+  repo.idarraysize = 4;
+  repo.lastoff = 3;
+  if (keyname == SOLVABLE_PROVIDES)
+    return idarraydata[repo_fix_supplements(&repo, 1, 3, 0)];
+  if (keyname == SOLVABLE_SUPPLEMENTS)
+    return idarraydata[repo_fix_supplements(&repo, 0, 1, 0)];
+  if (keyname == SOLVABLE_CONFLICTS)
+    return idarraydata[repo_fix_conflicts(&repo, 1)];
+  return 0;
+}
+
 /**********************************************************************************/
 
 static inline Id