aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/data/rc12
-rw-r--r--t/test.c16
-rw-r--r--t/test_configuration.c4
-rw-r--r--t/test_curl.c15
-rw-r--r--t/test_packages.c106
-rw-r--r--t/test_transaction.c1
6 files changed, 128 insertions, 16 deletions
diff --git a/t/data/rc1 b/t/data/rc1
index 991717c..15c0129 100644
--- a/t/data/rc1
+++ b/t/data/rc1
@@ -1,3 +1,3 @@
WORKINGDIR=data/slapt-get
EXCLUDE=^kernel-.*,^alsa-.*,^glibc.*,.*-[0-9]+dl$,^devs$,^udev$,aaa_elflibs,x86_64
-SOURCE=http://software.jaos.org/slackpacks/11.0/
+SOURCE=http://software.jaos.org/slackpacks/12.1/
diff --git a/t/test.c b/t/test.c
index 5b67cad..2834f63 100644
--- a/t/test.c
+++ b/t/test.c
@@ -17,9 +17,23 @@ slapt_pkg_info_t pkg = {
"",
".tgz",
115,
- 440
+ 440,
+ SLAPT_PRIORITY_DEFAULT,
+ SLAPT_TRUE
};
+int _progress_cb(void *clientp, double dltotal, double dlnow,
+ double ultotal, double ulnow)
+{
+ (void) clientp;
+ (void) dltotal;
+ (void) dlnow;
+ (void) ultotal;
+ (void) ulnow;
+ return 0;
+}
+
+
Suite *slapt_test_suite()
{
Suite *s = suite_create ("Slapt");
diff --git a/t/test_configuration.c b/t/test_configuration.c
index 36d23ca..5a3d150 100644
--- a/t/test_configuration.c
+++ b/t/test_configuration.c
@@ -68,11 +68,13 @@ END_TEST
START_TEST (test_source_list)
{
+ slapt_source_t *src = slapt_init_source("http://www.test.org/dist");
struct slapt_source_list *s = slapt_init_source_list();
fail_if (s == NULL);
fail_if (s->count != 0);
- slapt_add_source(s,"http://www.test.org/dist/");
+ fail_if (src == NULL);
+ slapt_add_source(s, src);
fail_if (s->count != 1);
slapt_remove_source (s,"http://www.test.org/dist/");
diff --git a/t/test_curl.c b/t/test_curl.c
index 276ce48..a7f792e 100644
--- a/t/test_curl.c
+++ b/t/test_curl.c
@@ -1,24 +1,15 @@
#include "test_curl.h"
extern slapt_pkg_info_t pkg;
-
-static int _progress_cb(void *clientp, double dltotal, double dlnow,
- double ultotal, double ulnow)
-{
- (void) clientp;
- (void) dltotal;
- (void) dlnow;
- (void) ultotal;
- (void) ulnow;
- return 0;
-}
+extern int _progress_cb(void *clientp, double dltotal, double dlnow,
+ double ultotal, double ulnow);
START_TEST (test_slapt_get_mirror_data_from_source)
{
FILE *f = NULL;
const char *err = NULL;
slapt_rc_config *rc = slapt_read_rc_config("./data/rc1");
- const char *url = "http://software.jaos.org/slackpacks/10.0/";
+ const char *url = rc->sources->src[0]->url;
char *packages = "PACKAGES.TXT";
char *packages_gz = "PACKAGES.TXT.gz";
char *checksums = "CHECKSUMS.md5";
diff --git a/t/test_packages.c b/t/test_packages.c
index 5969655..5fcda61 100644
--- a/t/test_packages.c
+++ b/t/test_packages.c
@@ -1,6 +1,8 @@
#include "test_packages.h"
extern slapt_pkg_info_t pkg;
+extern int _progress_cb(void *clientp, double dltotal, double dlnow,
+ double ultotal, double ulnow);
START_TEST (test_struct_pkg)
{
@@ -71,6 +73,9 @@ START_TEST (test_pkg_info)
/* retrieve the packages changelog entry, if any. Returns NULL otherwise */
/* char *slapt_get_pkg_changelog(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);
}
END_TEST
@@ -163,6 +168,98 @@ START_TEST (test_pkgtool)
}
END_TEST
+/*
+http://software.jaos.org/pipermail/slapt-get-devel/2008-November/000762.html
+
+* When comparing two packages on mirrors:
+
+ - The package with the highest priority wins, but:
+ - If the priorities tie, then the package with the highest version
+ number wins.
+
+ * When comparing an installed package with a mirror package:
+
+ - If the two packages have *exactly* the same version string, then they
+ compare equal, regardless of priorities.
+ - Otherwise, the package with the highest priority wins. (Taking the
+ priority of the installed package as zero). But:
+ - If the priorities tie, then the package with the highest version
+ number wins.
+*/
+START_TEST (test_pkg_version)
+{
+ slapt_pkg_info_t mirror_pkg1 = {
+ "8598a2a6d683d098b09cdc938de1e3c7",
+ "gslapt",
+ "0.3.15-i386-1",
+ "http://software.jaos.org/slackpacks/11.0/",
+ ".",
+ "gslapt: gslapt (GTK slapt-get, an APT like system for Slackware)\n",
+ "",
+ "",
+ "",
+ ".tgz",
+ 115,
+ 440,
+ SLAPT_PRIORITY_PREFERRED,
+ SLAPT_FALSE
+ };
+ slapt_pkg_info_t mirror_pkg2 = {
+ "8598a2a6d683d098b09cdc938de1e3c7",
+ "gslapt",
+ "0.3.15-i386-2",
+ "http://software.jaos.org/slackpacks/11.0/",
+ ".",
+ "gslapt: gslapt (GTK slapt-get, an APT like system for Slackware)\n",
+ "",
+ "",
+ "",
+ ".tgz",
+ 115,
+ 440,
+ SLAPT_PRIORITY_DEFAULT,
+ SLAPT_FALSE
+ };
+ slapt_pkg_info_t installed_pkg = {
+ "8598a2a6d683d098b09cdc938de1e3c7",
+ "gslapt",
+ "0.3.15-i386-1",
+ "http://software.jaos.org/slackpacks/11.0/",
+ ".",
+ "gslapt: gslapt (GTK slapt-get, an APT like system for Slackware)\n",
+ "",
+ "",
+ "",
+ ".tgz",
+ 115,
+ 440,
+ SLAPT_PRIORITY_DEFAULT,
+ SLAPT_TRUE
+ };
+
+ /* mirror_pkg1 has a higher priority, and should win */
+ fail_unless (slapt_cmp_pkgs(&mirror_pkg1,&mirror_pkg2) == 1);
+
+ /* both have the same priority, mirror_pkg2 has a higher version and should win */
+ mirror_pkg1.priority = SLAPT_PRIORITY_DEFAULT;
+ fail_unless (slapt_cmp_pkgs(&mirror_pkg1,&mirror_pkg2) == -1);
+
+ /* installed_pkg and mirror_pkg1 have the exact same version and should be
+ equal regardless of priority */
+ fail_unless (slapt_cmp_pkgs(&installed_pkg,&mirror_pkg1) == 0);
+
+ /* installed_pkg has a higher priority and should win, regardless of the
+ fact that mirror_pkg2 has a higher version */
+ installed_pkg.priority = SLAPT_PRIORITY_PREFERRED;
+ fail_unless (slapt_cmp_pkgs(&installed_pkg,&mirror_pkg2) == 1);
+
+ /* when the priorities are the same, the package with the higher version
+ always wins */
+ installed_pkg.priority = SLAPT_PRIORITY_DEFAULT;
+ fail_unless (slapt_cmp_pkgs(&installed_pkg,&mirror_pkg2) == -1);
+
+}
+END_TEST
START_TEST (test_version)
{
@@ -256,10 +353,12 @@ 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 (slapt_update_pkg_cache(rc) == 0); */
+ chdir(rc->working_dir);
/* write pkg data to disk
void slapt_write_pkg_data(const char *source_url,FILE *d_file,
@@ -277,7 +376,11 @@ START_TEST (test_network)
const char *url);
*/
+ fail_unless (slapt_update_pkg_cache(rc) == 0);
+
+ chdir(cwd);
slapt_free_rc_config(rc);
+ free(cwd);
}
END_TEST
@@ -293,6 +396,7 @@ Suite *packages_test_suite()
tcase_add_test (tc, test_pkg_list);
tcase_add_test (tc, test_pkg_search);
tcase_add_test (tc, test_pkgtool);
+ tcase_add_test (tc, test_pkg_version);
tcase_add_test (tc, test_version);
tcase_add_test (tc, test_dependency);
tcase_add_test (tc, test_cache);
diff --git a/t/test_transaction.c b/t/test_transaction.c
index 2452944..4cfb95c 100644
--- a/t/test_transaction.c
+++ b/t/test_transaction.c
@@ -74,6 +74,7 @@ START_TEST (test_transaction_dependencies)
in the transaction
void slapt_generate_suggestions(slapt_transaction_t *tran);
*/
+ slapt_generate_suggestions(t);
slapt_free_transaction(t);
slapt_free_rc_config(rc);