Update tests to the new API.

This commit is contained in:
Juan RP 2013-06-20 11:33:50 +02:00
parent 52fc384e4e
commit 5642ca6cfc
5 changed files with 107 additions and 107 deletions

View File

@ -27,36 +27,36 @@
#include <xbps_api.h>
static void
append_file(prop_dictionary_t d, const char *key, const char *fpath)
append_file(xbps_dictionary_t d, const char *key, const char *fpath)
{
prop_array_t a;
prop_dictionary_t filed;
xbps_array_t a;
xbps_dictionary_t filed;
filed = prop_dictionary_create();
a = prop_dictionary_get(d, key);
filed = xbps_dictionary_create();
a = xbps_dictionary_get(d, key);
if (a == NULL) {
a = prop_array_create();
prop_dictionary_set(d, key, a);
a = xbps_array_create();
xbps_dictionary_set(d, key, a);
}
prop_dictionary_set_cstring_nocopy(filed, "file", fpath);
prop_array_add(a, filed);
xbps_dictionary_set_cstring_nocopy(filed, "file", fpath);
xbps_array_add(a, filed);
}
static prop_dictionary_t
static xbps_dictionary_t
create_dict(const char *key, const char *fpath)
{
prop_array_t a;
prop_dictionary_t d, filed;
xbps_array_t a;
xbps_dictionary_t d, filed;
d = prop_dictionary_create();
filed = prop_dictionary_create();
a = prop_array_create();
d = xbps_dictionary_create();
filed = xbps_dictionary_create();
a = xbps_array_create();
prop_dictionary_set_cstring_nocopy(filed, "file", fpath);
prop_dictionary_set_cstring_nocopy(filed, "sha256", "kjaskajsk");
prop_array_add(a, filed);
prop_dictionary_set(d, key, a);
xbps_dictionary_set_cstring_nocopy(filed, "file", fpath);
xbps_dictionary_set_cstring_nocopy(filed, "sha256", "kjaskajsk");
xbps_array_add(a, filed);
xbps_dictionary_set(d, key, a);
return d;
}
@ -70,8 +70,8 @@ ATF_TC_HEAD(find_pkg_obsoletes_test, tc)
ATF_TC_BODY(find_pkg_obsoletes_test, tc)
{
struct xbps_handle xh;
prop_array_t res;
prop_dictionary_t d1, d2;
xbps_array_t res;
xbps_dictionary_t d1, d2;
memset(&xh, 0, sizeof(xh));
xh.rootdir = "/tmp";
@ -82,42 +82,42 @@ ATF_TC_BODY(find_pkg_obsoletes_test, tc)
d2 = create_dict("conf_files", "/etc/foo.conf");
res = xbps_find_pkg_obsoletes(&xh, d1, d2);
ATF_REQUIRE_EQ(prop_array_count(res), 0);
ATF_REQUIRE_EQ(xbps_array_count(res), 0);
res = xbps_find_pkg_obsoletes(&xh, d2, d1);
ATF_REQUIRE_EQ(prop_array_count(res), 0);
ATF_REQUIRE_EQ(xbps_array_count(res), 0);
append_file(d1, "files", "file");
res = xbps_find_pkg_obsoletes(&xh, d1, d2);
ATF_REQUIRE_EQ(prop_array_count(res), 1);
ATF_REQUIRE_EQ(xbps_array_count(res), 1);
append_file(d1, "conf_files", "conf_file");
res = xbps_find_pkg_obsoletes(&xh, d1, d2);
ATF_REQUIRE_EQ(prop_array_count(res), 2);
ATF_REQUIRE_EQ(xbps_array_count(res), 2);
append_file(d1, "links", "link");
res = xbps_find_pkg_obsoletes(&xh, d1, d2);
ATF_REQUIRE_EQ(prop_array_count(res), 3);
ATF_REQUIRE_EQ(xbps_array_count(res), 3);
append_file(d1, "dirs", "dir");
res = xbps_find_pkg_obsoletes(&xh, d1, d2);
ATF_REQUIRE_EQ(prop_array_count(res), 4);
ATF_REQUIRE_EQ(xbps_array_count(res), 4);
append_file(d2, "files", "file");
res = xbps_find_pkg_obsoletes(&xh, d1, d2);
ATF_REQUIRE_EQ(prop_array_count(res), 3);
ATF_REQUIRE_EQ(xbps_array_count(res), 3);
append_file(d2, "conf_files", "conf_file");
res = xbps_find_pkg_obsoletes(&xh, d1, d2);
ATF_REQUIRE_EQ(prop_array_count(res), 2);
ATF_REQUIRE_EQ(xbps_array_count(res), 2);
append_file(d2, "links", "link");
res = xbps_find_pkg_obsoletes(&xh, d1, d2);
ATF_REQUIRE_EQ(prop_array_count(res), 1);
ATF_REQUIRE_EQ(xbps_array_count(res), 1);
append_file(d2, "dirs", "dir");
res = xbps_find_pkg_obsoletes(&xh, d1, d2);
ATF_REQUIRE_EQ(prop_array_count(res), 0);
ATF_REQUIRE_EQ(xbps_array_count(res), 0);
}
ATF_TP_ADD_TCS(tp)

View File

@ -52,9 +52,9 @@ ATF_TC_HEAD(find_pkg_orphans_test, tc)
ATF_TC_BODY(find_pkg_orphans_test, tc)
{
struct xbps_handle xh;
prop_array_t a, res;
prop_dictionary_t pkgd;
prop_string_t pstr;
xbps_array_t a, res;
xbps_dictionary_t pkgd;
xbps_string_t pstr;
const char *pkgver, *tcsdir;
unsigned int i;
@ -66,18 +66,18 @@ ATF_TC_BODY(find_pkg_orphans_test, tc)
xh.metadir = tcsdir;
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
a = prop_array_create();
prop_array_add_cstring_nocopy(a, "xbps-git");
a = xbps_array_create();
xbps_array_add_cstring_nocopy(a, "xbps-git");
pstr = prop_string_create();
pstr = xbps_string_create();
res = xbps_find_pkg_orphans(&xh, a);
for (i = 0; i < prop_array_count(res); i++) {
pkgd = prop_array_get(res, i);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
prop_string_append_cstring(pstr, pkgver);
prop_string_append_cstring(pstr, "\n");
for (i = 0; i < xbps_array_count(res); i++) {
pkgd = xbps_array_get(res, i);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
xbps_string_append_cstring(pstr, pkgver);
xbps_string_append_cstring(pstr, "\n");
}
ATF_REQUIRE_STREQ(prop_string_cstring_nocopy(pstr), expected_output);
ATF_REQUIRE_STREQ(xbps_string_cstring_nocopy(pstr), expected_output);
}
ATF_TC(find_all_orphans_test);
@ -89,9 +89,9 @@ ATF_TC_HEAD(find_all_orphans_test, tc)
ATF_TC_BODY(find_all_orphans_test, tc)
{
struct xbps_handle xh;
prop_array_t res;
prop_dictionary_t pkgd;
prop_string_t pstr;
xbps_array_t res;
xbps_dictionary_t pkgd;
xbps_string_t pstr;
const char *pkgver, *tcsdir;
unsigned int i;
@ -103,17 +103,17 @@ ATF_TC_BODY(find_all_orphans_test, tc)
xh.metadir = tcsdir;
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
pstr = prop_string_create();
pstr = xbps_string_create();
res = xbps_find_pkg_orphans(&xh, NULL);
for (i = 0; i < prop_array_count(res); i++) {
pkgd = prop_array_get(res, i);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
prop_string_append_cstring(pstr, pkgver);
prop_string_append_cstring(pstr, "\n");
for (i = 0; i < xbps_array_count(res); i++) {
pkgd = xbps_array_get(res, i);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
xbps_string_append_cstring(pstr, pkgver);
xbps_string_append_cstring(pstr, "\n");
}
printf("%s", prop_string_cstring_nocopy(pstr));
printf("%s", xbps_string_cstring_nocopy(pstr));
ATF_REQUIRE_STREQ(prop_string_cstring_nocopy(pstr), expected_output_all);
ATF_REQUIRE_STREQ(xbps_string_cstring_nocopy(pstr), expected_output_all);
}
ATF_TP_ADD_TCS(tp)

View File

@ -34,7 +34,7 @@ ATF_TC_HEAD(pkgdb_get_pkg_test, tc)
ATF_TC_BODY(pkgdb_get_pkg_test, tc)
{
prop_dictionary_t pkgd;
xbps_dictionary_t pkgd;
struct xbps_handle xh;
const char *tcsdir, *pkgver;
@ -48,23 +48,23 @@ ATF_TC_BODY(pkgdb_get_pkg_test, tc)
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
pkgd = xbps_pkgdb_get_pkg(&xh, "mixed");
ATF_REQUIRE_EQ(prop_object_type(pkgd), PROP_TYPE_DICTIONARY);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_STREQ(pkgver, "mixed-0.1_1");
pkgd = xbps_pkgdb_get_pkg(&xh, "mixed>0");
ATF_REQUIRE_EQ(prop_object_type(pkgd), PROP_TYPE_DICTIONARY);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_STREQ(pkgver, "mixed-0.1_1");
pkgd = xbps_pkgdb_get_pkg(&xh, "mixed<2");
ATF_REQUIRE_EQ(prop_object_type(pkgd), PROP_TYPE_DICTIONARY);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_STREQ(pkgver, "mixed-0.1_1");
pkgd = xbps_pkgdb_get_pkg(&xh, "mixed-0.1_1");
ATF_REQUIRE_EQ(prop_object_type(pkgd), PROP_TYPE_DICTIONARY);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_STREQ(pkgver, "mixed-0.1_1");
}
@ -76,7 +76,7 @@ ATF_TC_HEAD(pkgdb_get_virtualpkg_test, tc)
ATF_TC_BODY(pkgdb_get_virtualpkg_test, tc)
{
prop_dictionary_t pkgd;
xbps_dictionary_t pkgd;
struct xbps_handle xh;
const char *tcsdir, *pkgver;
@ -90,23 +90,23 @@ ATF_TC_BODY(pkgdb_get_virtualpkg_test, tc)
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
pkgd = xbps_pkgdb_get_virtualpkg(&xh, "mixed");
ATF_REQUIRE_EQ(prop_object_type(pkgd), PROP_TYPE_DICTIONARY);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_STREQ(pkgver, "virtual-mixed-0.1_1");
pkgd = xbps_pkgdb_get_virtualpkg(&xh, "mixed>0");
ATF_REQUIRE_EQ(prop_object_type(pkgd), PROP_TYPE_DICTIONARY);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_STREQ(pkgver, "virtual-mixed-0.1_1");
pkgd = xbps_pkgdb_get_virtualpkg(&xh, "mixed<2");
ATF_REQUIRE_EQ(prop_object_type(pkgd), PROP_TYPE_DICTIONARY);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_STREQ(pkgver, "virtual-mixed-0.1_1");
pkgd = xbps_pkgdb_get_virtualpkg(&xh, "mixed-0.1_1");
ATF_REQUIRE_EQ(prop_object_type(pkgd), PROP_TYPE_DICTIONARY);
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_STREQ(pkgver, "virtual-mixed-0.1_1");
}
@ -119,8 +119,8 @@ ATF_TC_HEAD(pkgdb_get_pkg_revdeps_test, tc)
ATF_TC_BODY(pkgdb_get_pkg_revdeps_test, tc)
{
struct xbps_handle xh;
prop_array_t res;
prop_string_t pstr;
xbps_array_t res;
xbps_string_t pstr;
const char *tcsdir, *str;
const char *eout = "four-0.1_1\ntwo-0.1_1\n";
unsigned int i;
@ -135,15 +135,15 @@ ATF_TC_BODY(pkgdb_get_pkg_revdeps_test, tc)
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
res = xbps_pkgdb_get_pkg_revdeps(&xh, "mixed");
ATF_REQUIRE_EQ(prop_object_type(res), PROP_TYPE_ARRAY);
ATF_REQUIRE_EQ(xbps_object_type(res), XBPS_TYPE_ARRAY);
pstr = prop_string_create();
for (i = 0; i < prop_array_count(res); i++) {
prop_array_get_cstring_nocopy(res, i, &str);
prop_string_append_cstring(pstr, str);
prop_string_append_cstring(pstr, "\n");
pstr = xbps_string_create();
for (i = 0; i < xbps_array_count(res); i++) {
xbps_array_get_cstring_nocopy(res, i, &str);
xbps_string_append_cstring(pstr, str);
xbps_string_append_cstring(pstr, "\n");
}
ATF_REQUIRE_STREQ(prop_string_cstring_nocopy(pstr), eout);
ATF_REQUIRE_STREQ(xbps_string_cstring_nocopy(pstr), eout);
}
ATF_TP_ADD_TCS(tp)

View File

@ -26,15 +26,15 @@
#include <atf-c.h>
#include <xbps_api.h>
static prop_array_t
static xbps_array_t
array_init(void)
{
prop_array_t a;
xbps_array_t a;
a = prop_array_create();
a = xbps_array_create();
ATF_REQUIRE(a != NULL);
prop_array_add_cstring_nocopy(a, "foo-2.0_1");
prop_array_add_cstring_nocopy(a, "blah-2.1_1");
xbps_array_add_cstring_nocopy(a, "foo-2.0_1");
xbps_array_add_cstring_nocopy(a, "blah-2.1_1");
return a;
}
@ -47,7 +47,7 @@ ATF_TC_HEAD(match_string_test, tc)
ATF_TC_BODY(match_string_test, tc)
{
prop_array_t a = array_init();
xbps_array_t a = array_init();
ATF_REQUIRE_EQ(xbps_match_string_in_array(a, "foo-2.0_1"), true);
ATF_REQUIRE_EQ(xbps_match_string_in_array(a, "foo-2.1_1"), false);
}
@ -60,7 +60,7 @@ ATF_TC_HEAD(match_pkgname_test, tc)
ATF_TC_BODY(match_pkgname_test, tc)
{
prop_array_t a = array_init();
xbps_array_t a = array_init();
ATF_REQUIRE_EQ(xbps_match_pkgname_in_array(a, "foo"), true);
ATF_REQUIRE_EQ(xbps_match_pkgname_in_array(a, "baz"), false);
}
@ -73,7 +73,7 @@ ATF_TC_HEAD(match_pkgpattern_test, tc)
ATF_TC_BODY(match_pkgpattern_test, tc)
{
prop_array_t a = array_init();
xbps_array_t a = array_init();
ATF_REQUIRE_EQ(xbps_match_pkgpattern_in_array(a, "foo>=1.0"), true);
ATF_REQUIRE_EQ(xbps_match_pkgpattern_in_array(a, "blah<1.0"), false);
}
@ -86,7 +86,7 @@ ATF_TC_HEAD(match_pkgdep_test, tc)
ATF_TC_BODY(match_pkgdep_test, tc)
{
prop_array_t a = array_init();
xbps_array_t a = array_init();
ATF_REQUIRE_EQ(xbps_match_pkgdep_in_array(a, "foo-2.0_1"), true);
}

View File

@ -26,45 +26,45 @@
#include <atf-c.h>
#include <xbps_api.h>
static prop_array_t
static xbps_array_t
rundeps_init(void)
{
prop_array_t a;
xbps_array_t a;
a = prop_array_create();
a = xbps_array_create();
ATF_REQUIRE(a != NULL);
prop_array_add_cstring_nocopy(a, "cron-daemon>=0");
prop_array_add_cstring_nocopy(a, "xbps>=0.14");
xbps_array_add_cstring_nocopy(a, "cron-daemon>=0");
xbps_array_add_cstring_nocopy(a, "xbps>=0.14");
return a;
}
static prop_array_t
static xbps_array_t
provides_init(void)
{
prop_array_t a;
xbps_array_t a;
a = prop_array_create();
a = xbps_array_create();
ATF_REQUIRE(a != NULL);
prop_array_add_cstring_nocopy(a, "cron-daemon-0");
prop_array_add_cstring_nocopy(a, "xbps-9999");
xbps_array_add_cstring_nocopy(a, "cron-daemon-0");
xbps_array_add_cstring_nocopy(a, "xbps-9999");
return a;
}
static prop_dictionary_t
static xbps_dictionary_t
pkgdict_init(void)
{
prop_array_t a;
prop_dictionary_t d;
xbps_array_t a;
xbps_dictionary_t d;
d = prop_dictionary_create();
d = xbps_dictionary_create();
ATF_REQUIRE(d != NULL);
a = provides_init();
ATF_REQUIRE_EQ(prop_dictionary_set(d, "provides", a), true);
ATF_REQUIRE_EQ(xbps_dictionary_set(d, "provides", a), true);
return d;
}
@ -77,7 +77,7 @@ ATF_TC_HEAD(match_virtual_pkg_dict_test, tc)
ATF_TC_BODY(match_virtual_pkg_dict_test, tc)
{
prop_dictionary_t d;
xbps_dictionary_t d;
d = pkgdict_init();
ATF_REQUIRE_EQ(
@ -96,7 +96,7 @@ ATF_TC_HEAD(match_any_virtualpkg_rundeps_test, tc)
ATF_TC_BODY(match_any_virtualpkg_rundeps_test, tc)
{
prop_array_t provides, rundeps;
xbps_array_t provides, rundeps;
provides = provides_init();
rundeps = rundeps_init();