END_TEST START_TEST (test_network) { char *cwd = get_current_dir_name(); slapt_rc_config *rc = slapt_read_rc_config("./data/rc1"); rc->progress_cb = _progress_cb; /* silence */ /* must chdir to working dir */ fail_unless (chdir(rc->working_dir) == 0); /* write pkg data to disk void slapt_write_pkg_data(const char *source_url,FILE *d_file, slapt_pkg_list_t *pkgs); */ /* download the PACKAGES.TXT and CHECKSUMS.md5 files slapt_pkg_list_t *slapt_get_pkg_source_packages (const slapt_rc_config *global_config, const char *url); slapt_pkg_list_t *slapt_get_pkg_source_patches (const slapt_rc_config *global_config, const char *url); FILE *slapt_get_pkg_source_checksums (const slapt_rc_config *global_config, const char *url); int slapt_get_pkg_source_changelog (const slapt_rc_config *global_config, const char *url); */ fail_unless (slapt_update_pkg_cache(rc) == 0); fail_unless (chdir(cwd) == 0); slapt_free_rc_config(rc); free(cwd); }
END_TEST START_TEST (test_pkg_info) { size_t i = -1; char *string = NULL; slapt_rc_config *rc = slapt_read_rc_config("./data/rc1"); string = slapt_gen_short_pkg_description(&pkg); fail_if (string == NULL); fail_unless (strcmp(string,"gslapt (GTK slapt-get, an APT like system for Slackware)") == 0); free(string); string = NULL; string = slapt_gen_filename_from_url("http://software.jaos.org/slackpacks/11.0/","PACKAGES.TXT"); fail_if (string == NULL); fail_unless (strcmp(string,".http:##software.jaos.org#slackpacks#11.0#PACKAGES.TXT") == 0); free(string); string = NULL; string = slapt_gen_head_cache_filename(".http:##software.jaos.org#slackpacks#11.0#PACKAGES.TXT"); fail_if (string == NULL); fail_unless (strcmp(string,".http:##software.jaos.org#slackpacks#11.0#PACKAGES.TXT.head") == 0); free(string); string = NULL; string = slapt_gen_pkg_url(&pkg); fail_if (string == NULL); fail_unless (strcmp(string,"http://software.jaos.org/slackpacks/11.0/./gslapt-0.3.15-i386-1.tgz") == 0); free(string); string = NULL; slapt_add_list_item(rc->exclude_list,"^gslapt$"); fail_if (slapt_is_excluded(rc,&pkg) == 0); slapt_remove_list_item(rc->exclude_list,"^gslapt$"); fail_unless (slapt_download_pkg(rc, &pkg, NULL) == 0); fail_unless (slapt_verify_downloaded_pkg(rc,&pkg) == 0); i = slapt_get_pkg_file_size(rc, &pkg); fail_if (i < 1); string = strdup(pkg.description); slapt_clean_description(string, pkg.name); fail_unless (strcmp(string," gslapt (GTK slapt-get, an APT like system for Slackware)\n") == 0); free(string); string = NULL; /* retrieve the packages changelog entry, if any. Returns NULL otherwise */ /* char *slapt_get_pkg_changelog(const slapt_pkg_info_t *pkg); */ /* get the package filelist, returns (char *) on success or NULL on error */ /* char *slapt_get_pkg_filelist(const slapt_pkg_info_t *pkg); */ fail_unless (pkg.priority == SLAPT_PRIORITY_DEFAULT); fail_unless (strcmp(slapt_priority_to_str(pkg.priority),gettext("Default")) == 0); slapt_free_rc_config(rc); }
/** * backend_initialize: * This should only be run once per backend load, i.e. not every transaction */ static void backend_initialize (PkBackend *backend) { _config = slapt_read_rc_config(_config_file); if (_config == NULL) _config = slapt_init_config(); _backend = backend; if (_backend != NULL) _config->progress_cb = &backend_progress_callback; chdir(_config->working_dir); }
END_TEST START_TEST (test_slapt_download_pkg) { const char *err = NULL; slapt_rc_config *rc = slapt_read_rc_config("./data/rc1"); rc->progress_cb = _progress_cb; /* silence */ slapt_working_dir_init(rc); err = slapt_download_pkg(rc, &pkg, NULL); fail_if (err); slapt_free_rc_config(rc); }
END_TEST START_TEST (test_cache) { slapt_rc_config *rc = slapt_read_rc_config("./data/rc1"); slapt_clean_pkg_dir(rc->working_dir); /* not easily testable due to timeout slapt_pkg_list_t *list = slapt_init_pkg_list(); slapt_purge_old_cached_pkgs(rc, NULL, list); */ slapt_free_rc_config(rc); }
END_TEST START_TEST (test_pkgtool) { slapt_rc_config *rc = slapt_read_rc_config("./data/rc1"); /* disabled... */ /* int r = -1; r = slapt_install_pkg(rc, &pkg); r = slapt_upgrade_pkg(rc, &pkg); r = slapt_remove_pkg(rc, &pkg); */ slapt_free_rc_config(rc); }
/** * backend_initialize: * This should only be run once per backend load, i.e. not every transaction */ static void backend_initialize (PkBackend *backend) { struct category_map *catgroup; _config = slapt_read_rc_config(_config_file); if (_config == NULL) _config = slapt_init_config(); _cathash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); for (catgroup = CATGROUP; catgroup->category != NULL; catgroup++) { g_hash_table_insert(_cathash, (gpointer) catgroup->category, (gpointer) catgroup->group); } _backend = backend; if (_backend != NULL) _config->progress_cb = &backend_progress_callback; chdir(_config->working_dir); }
END_TEST START_TEST (test_dependency) { unsigned int i = 0; FILE *fh = NULL; slapt_pkg_info_t *p = NULL; slapt_pkg_list_t *avail = NULL; slapt_pkg_list_t *required_by = slapt_init_pkg_list (); slapt_pkg_list_t *installed = slapt_init_pkg_list (); slapt_pkg_list_t *pkgs_to_install = slapt_init_pkg_list (); slapt_pkg_list_t *pkgs_to_remove = slapt_init_pkg_list (); slapt_pkg_list_t *conflicts = NULL, *deps = slapt_init_pkg_list (); slapt_pkg_err_list_t *conflict = slapt_init_pkg_err_list (), *missing = slapt_init_pkg_err_list (); slapt_rc_config *rc = slapt_read_rc_config ("./data/rc1"); fh = fopen ("data/avail_deps", "r"); fail_unless (fh != NULL); avail = slapt_parse_packages_txt (fh); fclose (fh); fh = fopen ("data/installed_deps", "r"); fail_unless (fh != NULL); installed = slapt_parse_packages_txt (fh); fclose (fh); /* dependency tests */ p = slapt_get_newest_pkg(avail, "slapt-src"); fail_unless (p != NULL); i = slapt_get_pkg_dependencies (rc, avail, installed, p, deps, conflict, missing); /* we expect 22 deps to return given our current hardcoded data files */ fail_unless (i != 22); /* we should have slapt-get as a dependency for slapt-src */ fail_unless ( slapt_search_pkg_list(deps, "slapt-get") != NULL); /* conflicts tests */ /* scim conflicts with ibus */ p = slapt_get_newest_pkg(avail, "scim"); fail_unless (p != NULL); conflicts = slapt_get_pkg_conflicts (avail, installed, p); fail_unless (conflicts != NULL); fail_unless (conflicts->pkg_count == 1); fail_unless ( strcmp (conflicts->pkgs[0]->name, "ibus") == 0); slapt_free_pkg_list (conflicts); /* required by tests */ /* slapt-get reverse dep test */ p = slapt_get_newest_pkg(avail, "slapt-get"); fail_unless (p != NULL); required_by = slapt_is_required_by(rc, avail, installed, pkgs_to_install, pkgs_to_remove, p); fail_unless (required_by->pkg_count == 5); fail_unless ( strcmp (required_by->pkgs[0]->name,"slapt-src") == 0); fail_unless ( strcmp (required_by->pkgs[1]->name,"gslapt") == 0); fail_unless ( strcmp (required_by->pkgs[2]->name,"foo") == 0); fail_unless ( strcmp (required_by->pkgs[3]->name,"boz") == 0); fail_unless ( strcmp (required_by->pkgs[4]->name,"bar") == 0); slapt_free_pkg_list (required_by); /* glib reverse dep test */ p = slapt_get_newest_pkg(avail, "glib"); fail_unless (p != NULL); required_by = slapt_is_required_by(rc, avail, installed, pkgs_to_install, pkgs_to_remove, p); fail_unless (required_by->pkg_count == 2); fail_unless ( strcmp (required_by->pkgs[0]->name,"xmms") == 0); fail_unless ( strcmp (required_by->pkgs[1]->name,"gtk+") == 0); slapt_free_pkg_list (required_by); /* glib2 reverse dep test */ p = slapt_get_newest_pkg(avail, "glib2"); fail_unless (p != NULL); required_by = slapt_is_required_by(rc, avail, installed, pkgs_to_install, pkgs_to_remove, p); fail_unless (required_by->pkg_count == 4); fail_unless ( strcmp (required_by->pkgs[0]->name,"ConsoleKit") == 0); fail_unless ( strcmp (required_by->pkgs[1]->name,"dbus-glib") == 0); fail_unless ( strcmp (required_by->pkgs[2]->name,"gslapt") == 0); fail_unless ( strcmp (required_by->pkgs[3]->name,"scim") == 0); slapt_free_pkg_list (required_by); slapt_free_pkg_list (installed); slapt_free_pkg_list (pkgs_to_install); slapt_free_pkg_list (pkgs_to_remove); slapt_free_pkg_list (avail); slapt_free_rc_config (rc); }