END_TEST START_TEST(test_two_sacks) { /* This clumsily mimics create_ut_sack() and setup_with() to * create a second HySack. */ char *tmpdir = solv_dupjoin(test_globals.tmpdir, "/tmp", NULL); HySack sack1 = hy_sack_create(tmpdir, TEST_FIXED_ARCH, NULL, NULL, HY_MAKE_CACHE_DIR); Pool *pool1 = sack_pool(sack1); const char *path = pool_tmpjoin(pool1, test_globals.repo_dir, "change.repo", NULL); fail_if(load_repo(pool1, "change", path, 0)); HyPackage pkg1 = by_name(sack1, "penny-lib"); fail_if(pkg1 == NULL); HySack sack2 = test_globals.sack; Pool *pool2 = sack_pool(sack2); HyPackage pkg2 = by_name(sack2, "penny-lib"); fail_if(pkg2 == NULL); /* "penny-lib" is in both pools but at different offsets */ Solvable *s1 = pool_id2solvable(pool1, pkg1->id); Solvable *s2 = pool_id2solvable(pool2, pkg2->id); fail_if(s1->name == s2->name); fail_if(hy_package_cmp(pkg1, pkg2) != 0); hy_package_free(pkg1); hy_package_free(pkg2); hy_sack_free(sack1); solv_free(tmpdir); }
HyReldepList hy_reldeplist_create(HySack sack) { HyReldepList reldeplist = solv_calloc(1, sizeof(*reldeplist)); reldeplist->pool = sack_pool(sack); queue_init(&reldeplist->queue); return reldeplist; }
static void add_cmdline(HySack sack) { Pool *pool = sack_pool(sack); const char *path = pool_tmpjoin(pool, test_globals.repo_dir, "yum/tour-4-6.noarch.rpm", NULL); HyPackage pkg = hy_sack_add_cmdline_package(sack, path); hy_package_free(pkg); }
END_TEST START_TEST(test_sack_create) { fail_unless(hy_get_errno() == 0); HySack sack = hy_sack_create(test_globals.tmpdir, NULL, NULL, NULL, HY_MAKE_CACHE_DIR); fail_if(sack == NULL, NULL); fail_if(sack_pool(sack) == NULL, NULL); hy_sack_free(sack); }
PyObject * new_reldep(PyObject *sack, Id r_id) { HySack csack = sackFromPyObject(sack); if (csack == NULL) return NULL; _ReldepObject *self = reldep_new_core(&reldep_Type, sack); if (self == NULL) return NULL; self->reldep = reldep_create(sack_pool(csack), r_id); return (PyObject*)self; }
END_TEST START_TEST(test_presto_from_cache) { HySack sack = hy_sack_create(test_globals.tmpdir, TEST_FIXED_ARCH, NULL, NULL, HY_MAKE_CACHE_DIR); setup_yum_sack(sack, YUM_REPO_NAME); HyRepo repo = hrepo_by_name(sack, YUM_REPO_NAME); fail_unless(repo->state_presto == _HY_LOADED_CACHE); check_prestoinfo(sack_pool(sack)); hy_sack_free(sack); }
END_TEST START_TEST(test_upgrades_sanity) { Pool *pool = sack_pool(test_globals.sack); Repo *r = NULL; int i; FOR_REPOS(i, r) if (!strcmp(r->name, "updates")) break; fail_unless(r != NULL); fail_unless(r->nsolvables == TEST_EXPECT_UPDATES_NSOLVABLES); }
static void queue_pkg_name(HySack sack, Queue *queue, const char *provide, int flags) { Pool *pool = sack_pool(sack); if (!flags) { Id id = pool_str2id(pool, provide, 0); if (id == 0) return; Id p, pp; FOR_PKG_PROVIDES(p, pp, id) { Solvable *s = pool_id2solvable(pool, p); if (s->name == id) queue_push(queue, p); }
void setup_yum_sack(HySack sack, const char *yum_repo_name) { Pool *pool = sack_pool(sack); const char *repo_path = pool_tmpjoin(pool, test_globals.repo_dir, YUM_DIR_SUFFIX, NULL); fail_if(access(repo_path, X_OK)); HyRepo repo = glob_for_repofiles(pool, yum_repo_name, repo_path); fail_if(hy_sack_load_repo(sack, repo, HY_BUILD_CACHE | HY_LOAD_FILELISTS | HY_LOAD_UPDATEINFO | HY_LOAD_PRESTO)); fail_unless(hy_sack_count(sack) == TEST_EXPECT_YUM_NSOLVABLES); hy_repo_free(repo); }
HyReldep hy_reldep_create(HySack sack, const char *name, int cmp_type, const char *evr) { Pool *pool = sack_pool(sack); Id id = pool_str2id(pool, name, 0); if (id == STRID_NULL || id == STRID_EMPTY) // stop right there, this will never match anything. return NULL; if (evr) { assert(cmp_type); Id ievr = pool_str2id(pool, evr, 1); int flags = cmptype2relflags(cmp_type); id = pool_rel2id(pool, id, ievr, flags, 1); } return reldep_create(pool, id); }
static int setup_with(HySack sack, ...) { Pool *pool = sack_pool(sack); va_list names; int ret = 0; va_start(names, sack); const char *name = va_arg(names, const char *); while (name) { const char *path = pool_tmpjoin(pool, test_globals.repo_dir, name, ".repo"); int installed = !strncmp(name, HY_SYSTEM_REPO_NAME, strlen(HY_SYSTEM_REPO_NAME)); ret |= load_repo(pool, name, path, installed); name = va_arg(names, const char *); } va_end(names); return ret; }
static int setarch(HySack sack, const char *req_arch) { int ret = 0; Pool *pool = sack_pool(sack); const char *arch = req_arch; char *detected = NULL; if (arch == NULL) { ret = hy_detect_arch(&detected); if (ret) { HY_LOG_ERROR("hy_detect_arch() failed: %d", ret); return ret; } arch = detected; } HY_LOG_INFO("Architecture is: %s", arch); pool_setarch(pool, arch); if (!strcmp(arch, "noarch")) // noarch never fails goto done; /* pool_setarch() doesn't tell us when it defaulted to 'noarch' but we consider it a failure. the only way to find out is count the architectures known to the Pool. */ int count = 0; for (Id id = 0; id <= pool->lastarch; ++id) if (pool->id2arch[id]) count++; if (count < 2) ret = HY_E_FAILED; done: solv_free(detected); return ret; }
void sack_recompute_considered(HySack sack) { Pool *pool = sack_pool(sack); if (sack->considered_uptodate) return; if (!pool->considered) { if (!sack->repo_excludes && !sack->pkg_excludes) return; pool->considered = solv_calloc(1, sizeof(Map)); map_init(pool->considered, pool->nsolvables); } else map_grow(pool->considered, pool->nsolvables); // considered = (all - repo_excludes - pkg_excludes) and pkg_includes map_setall(pool->considered); if (sack->repo_excludes) map_subtract(pool->considered, sack->repo_excludes); if (sack->pkg_excludes) map_subtract(pool->considered, sack->pkg_excludes); if (sack->pkg_includes) map_and(pool->considered, sack->pkg_includes); sack->considered_uptodate = 1; }
Pool * package_pool(HyPackage pkg) { return sack_pool(pkg->sack); }