Ejemplo n.º 1
0
END_TEST

START_TEST(test_goal_installonly_limit_with_modules)
{
    // most complex installonly test case, includes the k-m packages
    const char *installonly[] = {"k", "k-m", NULL};
    HySack sack = test_globals.sack;
    hy_sack_set_installonly(sack, installonly);
    hy_sack_set_installonly_limit(sack, 3);
    sack->running_kernel_fn = mock_running_kernel;

    HyGoal goal = hy_goal_create(sack);
    hy_goal_upgrade_all(goal);
    fail_if(hy_goal_run_flags(goal, 0));

    assert_iueo(goal, 2, 0, 5, 0);
    HyPackageList erasures = hy_goal_list_erasures(goal);
    assert_nevra_eq(hy_packagelist_get(erasures, 0), "k-1-0.x86_64");
    assert_nevra_eq(hy_packagelist_get(erasures, 1), "k-m-1-0.x86_64");
    assert_nevra_eq(hy_packagelist_get(erasures, 2), "k-freak-1-0-1-0.x86_64");
    assert_nevra_eq(hy_packagelist_get(erasures, 3), "k-2-0.x86_64");
    assert_nevra_eq(hy_packagelist_get(erasures, 4), "k-m-2-0.x86_64");
    hy_packagelist_free(erasures);

    hy_goal_free(goal);
}
Ejemplo n.º 2
0
void fixture_reset(void)
{
    HySack sack = test_globals.sack;
    hy_sack_set_installonly(sack, NULL);
    hy_sack_set_installonly_limit(sack, 0);
    hy_sack_set_excludes(sack, NULL);
    hy_sack_repo_enabled(sack, "main", 1);
    hy_sack_repo_enabled(sack, "updates", 1);
}
Ejemplo n.º 3
0
END_TEST

START_TEST(test_goal_installonly)
{
    const char *installonly[] = {"fool", NULL};

    HySack sack = test_globals.sack;
    hy_sack_set_installonly(sack, installonly);
    hy_sack_set_installonly_limit(sack, 2);
    HyPackage pkg = get_latest_pkg(sack, "fool");
    HyGoal goal = hy_goal_create(sack);
    fail_if(hy_goal_upgrade_to_flags(goal, pkg, HY_CHECK_INSTALLED));
    hy_package_free(pkg);
    fail_if(hy_goal_run(goal));
    assert_iueo(goal, 1, 0, 1, 0);
    hy_goal_free(goal);
}
Ejemplo n.º 4
0
END_TEST

START_TEST(test_goal_installonly_limit_disabled)
{
    // test that setting limit to 0 does not cause all intallonlies to be
    // uninstalled
    const char *installonly[] = {"k", NULL};
    HySack sack = test_globals.sack;
    hy_sack_set_installonly(sack, installonly);
    hy_sack_set_installonly_limit(sack, 0);
    sack->running_kernel_fn = mock_running_kernel_no;

    HyGoal goal = hy_goal_create(sack);
    hy_goal_upgrade_all(goal);
    fail_if(hy_goal_run_flags(goal, 0));

    assert_iueo(goal, 1, 1, 0, 0);
    hy_goal_free(goal);
}
Ejemplo n.º 5
0
END_TEST

START_TEST(test_goal_installonly_limit)
{
    const char *installonly[] = {"k", NULL};
    HySack sack = test_globals.sack;
    hy_sack_set_installonly(sack, installonly);
    hy_sack_set_installonly_limit(sack, 3);
    sack->running_kernel_fn = mock_running_kernel_no;

    HyGoal goal = hy_goal_create(sack);
    hy_goal_upgrade_all(goal);
    fail_if(hy_goal_run_flags(goal, 0));

    assert_iueo(goal, 1, 1, 3, 0); // k-m is just upgraded
    HyPackageList erasures = hy_goal_list_erasures(goal);
    assert_nevra_eq(hy_packagelist_get(erasures, 0), "k-1-0.x86_64");
    assert_nevra_eq(hy_packagelist_get(erasures, 1), "k-freak-1-0-1-0.x86_64");
    assert_nevra_eq(hy_packagelist_get(erasures, 2), "k-1-1.x86_64");
    hy_packagelist_free(erasures);

    hy_goal_free(goal);
}
Ejemplo n.º 6
0
END_TEST

START_TEST(test_goal_installonly_upgrade_all)
{
    const char *installonly[] = {"fool", NULL};
    HySack sack = test_globals.sack;
    HyGoal goal = hy_goal_create(sack);

    hy_sack_set_installonly(sack, installonly);
    hy_sack_set_installonly_limit(sack, 2);

    hy_goal_upgrade_all(goal);
    fail_if(hy_goal_run(goal));

    HyPackageList plist = hy_goal_list_erasures(goal);
    assert_list_names(plist, "penny", NULL);
    hy_packagelist_free(plist);
    plist = hy_goal_list_installs(goal);
    assert_list_names(plist, "fool", NULL);
    hy_packagelist_free(plist);
    assert_iueo(goal, 1, 4, 1, 0);

    hy_goal_free(goal);
}
Ejemplo n.º 7
0
Archivo: hth.c Proyecto: Tojaj/hawkey
int main(int argc, const char **argv)
{
    HySack sack = hy_sack_create(NULL, NULL, NULL, HY_MAKE_CACHE_DIR);
    HyRepo repo;
    char *md_repo;
    char *md_primary_xml;
    char *md_filelists;
    char *md_repo_updates;
    char *md_primary_updates_xml;
    char *md_filelists_updates;
    int ret;

    if (read_repopaths(&md_repo, &md_primary_xml, &md_filelists, &md_repo_updates,
		       &md_primary_updates_xml, &md_filelists_updates)) {
	fprintf(stderr,
		"This is hawkey testing hack, it needs a readable %s file "
		"containing the following paths on separate lines:\n"
		"<main repomd.xml path>\n"
		"<main primary.xml.gz path>\n"
		"<main filelist.xml.gz path>\n"
		"<updates repomd.xml path>\n"
		"<updates primary.xml.gz path>\n"
		"<updates filelists.xml.gz path>\n", CFG_FILE);
	return 1;
    }
    int load_flags = HY_BUILD_CACHE;
    /* rpmdb */
    repo = hy_repo_create(HY_SYSTEM_REPO_NAME);
    hy_sack_load_system_repo(sack, NULL, load_flags);
    hy_repo_free(repo);

    if (need_filelists(argc, argv))
	load_flags |= HY_LOAD_FILELISTS;
    /* Fedora repo */
    repo = config_repo("Fedora", md_repo, md_primary_xml, md_filelists);
    ret = hy_sack_load_yum_repo(sack, repo, load_flags);
    assert(ret == 0); (void)ret;
    hy_repo_free(repo);
    /* Fedora updates repo */
    repo = config_repo("updates", md_repo_updates, md_primary_updates_xml,
		       md_filelists_updates);
    ret = hy_sack_load_yum_repo(sack, repo, load_flags);
    assert(ret == 0); (void)ret;
    hy_repo_free(repo);
    free(md_repo);
    free(md_primary_xml);
    free(md_filelists);
    free(md_repo_updates);
    free(md_primary_updates_xml);
    free(md_filelists_updates);

    hy_sack_set_installonly(sack, installonly);
    hy_sack_set_installonly_limit(sack, 3);

    if (argc == 2 && !strcmp(argv[1], "-o")) {
	obsoletes(sack);
    } else if (argc == 2) {
	search_and_print(sack, argv[1]);
    } else if (argc == 3 && !strcmp(argv[1], "-f")) {
	search_filter_files(sack, argv[2]);
    } else if (argc == 3 && !strcmp(argv[1], "-r")) {
	search_filter_repos(sack, argv[2]);
    } else if (argc == 3 && !strcmp(argv[1], "-u")) {
	updatables_query_name(sack, argv[2]);
    } else if (argc == 3 && !strcmp(argv[1], "-ul")) {
	update_local(sack, argv[2]);
    } else if (argc == 3 && !strcmp(argv[1], "-ur")) {
	update_remote(sack, argv[2]);
    } else if (argc == 3 && !strcmp(argv[1], "-e")) {
	erase(sack, argv[2]);
    } else if (argc == 3) {
	search_anded(sack, argv[1], argv[2]);
    } else if (argc == 4 && !strcmp(argv[1], "-p")) {
	search_provides(sack, argv[2], argv[3]);
    }

    hy_sack_free(sack);

    return 0;
}