Add some tests for pkgdb.
This commit is contained in:
parent
b9888fd7be
commit
bc6aa52f33
@ -8,5 +8,6 @@ SUBDIRS += plist_match
|
|||||||
SUBDIRS += plist_match_virtual
|
SUBDIRS += plist_match_virtual
|
||||||
SUBDIRS += util
|
SUBDIRS += util
|
||||||
SUBDIRS += find_pkg_obsoletes
|
SUBDIRS += find_pkg_obsoletes
|
||||||
|
SUBDIRS += pkgdb
|
||||||
|
|
||||||
include ../../mk/subdir.mk
|
include ../../mk/subdir.mk
|
||||||
|
@ -8,3 +8,4 @@ atf_test_program{name="pkgpattern_match_test"}
|
|||||||
atf_test_program{name="plist_match_test"}
|
atf_test_program{name="plist_match_test"}
|
||||||
atf_test_program{name="plist_match_virtual_test"}
|
atf_test_program{name="plist_match_virtual_test"}
|
||||||
atf_test_program{name="find_pkg_obsoletes_test"}
|
atf_test_program{name="find_pkg_obsoletes_test"}
|
||||||
|
include('pkgdb/Kyuafile')
|
||||||
|
5
tests/libxbps/pkgdb/Kyuafile
Normal file
5
tests/libxbps/pkgdb/Kyuafile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
syntax("kyuafile", 1)
|
||||||
|
|
||||||
|
test_suite("libxbps")
|
||||||
|
|
||||||
|
atf_test_program{name="pkgdb_test"}
|
8
tests/libxbps/pkgdb/Makefile
Normal file
8
tests/libxbps/pkgdb/Makefile
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
TOPDIR = ../../..
|
||||||
|
-include $(TOPDIR)/config.mk
|
||||||
|
|
||||||
|
TESTSSUBDIR = libxbps/pkgdb
|
||||||
|
TEST = pkgdb_test
|
||||||
|
EXTRA_FILES = Kyuafile pkgdb-0.21.plist
|
||||||
|
|
||||||
|
include $(TOPDIR)/mk/test.mk
|
156
tests/libxbps/pkgdb/main.c
Normal file
156
tests/libxbps/pkgdb/main.c
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2013 Juan Romero Pardines.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*-
|
||||||
|
*/
|
||||||
|
#include <atf-c.h>
|
||||||
|
#include <xbps_api.h>
|
||||||
|
|
||||||
|
ATF_TC(pkgdb_get_pkg_test);
|
||||||
|
ATF_TC_HEAD(pkgdb_get_pkg_test, tc)
|
||||||
|
{
|
||||||
|
atf_tc_set_md_var(tc, "descr", "Test xbps_pkgdb_get_pkg()");
|
||||||
|
}
|
||||||
|
|
||||||
|
ATF_TC_BODY(pkgdb_get_pkg_test, tc)
|
||||||
|
{
|
||||||
|
prop_dictionary_t pkgd;
|
||||||
|
struct xbps_handle xh;
|
||||||
|
const char *tcsdir, *pkgver;
|
||||||
|
|
||||||
|
/* get test source dir */
|
||||||
|
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||||
|
|
||||||
|
memset(&xh, 0, sizeof(xh));
|
||||||
|
xh.rootdir = tcsdir;
|
||||||
|
xh.metadir = tcsdir;
|
||||||
|
xh.flags = XBPS_FLAG_DEBUG;
|
||||||
|
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_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_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_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_STREQ(pkgver, "mixed-0.1_1");
|
||||||
|
}
|
||||||
|
|
||||||
|
ATF_TC(pkgdb_get_virtualpkg_test);
|
||||||
|
ATF_TC_HEAD(pkgdb_get_virtualpkg_test, tc)
|
||||||
|
{
|
||||||
|
atf_tc_set_md_var(tc, "descr", "Test xbps_pkgdb_get_virtualpkg()");
|
||||||
|
}
|
||||||
|
|
||||||
|
ATF_TC_BODY(pkgdb_get_virtualpkg_test, tc)
|
||||||
|
{
|
||||||
|
prop_dictionary_t pkgd;
|
||||||
|
struct xbps_handle xh;
|
||||||
|
const char *tcsdir, *pkgver;
|
||||||
|
|
||||||
|
/* get test source dir */
|
||||||
|
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||||
|
|
||||||
|
memset(&xh, 0, sizeof(xh));
|
||||||
|
xh.rootdir = tcsdir;
|
||||||
|
xh.metadir = tcsdir;
|
||||||
|
xh.flags = XBPS_FLAG_DEBUG;
|
||||||
|
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_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_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_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_STREQ(pkgver, "virtual-mixed-0.1_1");
|
||||||
|
}
|
||||||
|
|
||||||
|
ATF_TC(pkgdb_get_pkg_revdeps_test);
|
||||||
|
ATF_TC_HEAD(pkgdb_get_pkg_revdeps_test, tc)
|
||||||
|
{
|
||||||
|
atf_tc_set_md_var(tc, "descr", "Test xbps_pkgdb_get_pkg_revdeps()");
|
||||||
|
}
|
||||||
|
|
||||||
|
ATF_TC_BODY(pkgdb_get_pkg_revdeps_test, tc)
|
||||||
|
{
|
||||||
|
struct xbps_handle xh;
|
||||||
|
prop_array_t res;
|
||||||
|
prop_string_t pstr;
|
||||||
|
const char *tcsdir, *str;
|
||||||
|
const char *eout = "four-0.1_1\ntwo-0.1_1\n";
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
/* get test source dir */
|
||||||
|
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||||
|
|
||||||
|
memset(&xh, 0, sizeof(xh));
|
||||||
|
xh.rootdir = tcsdir;
|
||||||
|
xh.metadir = tcsdir;
|
||||||
|
xh.flags = XBPS_FLAG_DEBUG;
|
||||||
|
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);
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
ATF_REQUIRE_STREQ(prop_string_cstring_nocopy(pstr), eout);
|
||||||
|
}
|
||||||
|
|
||||||
|
ATF_TP_ADD_TCS(tp)
|
||||||
|
{
|
||||||
|
ATF_TP_ADD_TC(tp, pkgdb_get_pkg_test);
|
||||||
|
ATF_TP_ADD_TC(tp, pkgdb_get_virtualpkg_test);
|
||||||
|
ATF_TP_ADD_TC(tp, pkgdb_get_pkg_revdeps_test);
|
||||||
|
|
||||||
|
return atf_no_error();
|
||||||
|
}
|
98
tests/libxbps/pkgdb/pkgdb-0.21.plist
Normal file
98
tests/libxbps/pkgdb/pkgdb-0.21.plist
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>four</key>
|
||||||
|
<dict>
|
||||||
|
<key>automatic-install</key>
|
||||||
|
<true/>
|
||||||
|
<key>pkgver</key>
|
||||||
|
<string>four-0.1_1</string>
|
||||||
|
<key>run_depends</key>
|
||||||
|
<array>
|
||||||
|
<string>mixed-0.1_1</string>
|
||||||
|
</array>
|
||||||
|
<key>short_desc</key>
|
||||||
|
<string>four descriptionm</string>
|
||||||
|
<key>state</key>
|
||||||
|
<string>installed</string>
|
||||||
|
</dict>
|
||||||
|
<key>mixed</key>
|
||||||
|
<dict>
|
||||||
|
<key>automatic-install</key>
|
||||||
|
<true/>
|
||||||
|
<key>pkgver</key>
|
||||||
|
<string>mixed-0.1_1</string>
|
||||||
|
<key>short_desc</key>
|
||||||
|
<string>mixed description</string>
|
||||||
|
<key>state</key>
|
||||||
|
<string>installed</string>
|
||||||
|
</dict>
|
||||||
|
<key>one</key>
|
||||||
|
<dict>
|
||||||
|
<key>automatic-install</key>
|
||||||
|
<true/>
|
||||||
|
<key>pkgver</key>
|
||||||
|
<string>one-0.1_1</string>
|
||||||
|
<key>run_depends</key>
|
||||||
|
<array>
|
||||||
|
<string>two>=0.2</string>
|
||||||
|
</array>
|
||||||
|
<key>short_desc</key>
|
||||||
|
<string>one descriptionm</string>
|
||||||
|
<key>state</key>
|
||||||
|
<string>installed</string>
|
||||||
|
</dict>
|
||||||
|
<key>three</key>
|
||||||
|
<dict>
|
||||||
|
<key>automatic-install</key>
|
||||||
|
<true/>
|
||||||
|
<key>pkgver</key>
|
||||||
|
<string>three-0.1_1</string>
|
||||||
|
<key>run_depends</key>
|
||||||
|
<array>
|
||||||
|
<string>four-0.1_1</string>
|
||||||
|
</array>
|
||||||
|
<key>short_desc</key>
|
||||||
|
<string>three descriptionm</string>
|
||||||
|
<key>state</key>
|
||||||
|
<string>installed</string>
|
||||||
|
</dict>
|
||||||
|
<key>two</key>
|
||||||
|
<dict>
|
||||||
|
<key>automatic-install</key>
|
||||||
|
<true/>
|
||||||
|
<key>pkgver</key>
|
||||||
|
<string>two-0.1_1</string>
|
||||||
|
<key>run_depends</key>
|
||||||
|
<array>
|
||||||
|
<string>three>=0.1</string>
|
||||||
|
<string>mixed>=0</string>
|
||||||
|
</array>
|
||||||
|
<key>short_desc</key>
|
||||||
|
<string>two descriptionm</string>
|
||||||
|
<key>state</key>
|
||||||
|
<string>installed</string>
|
||||||
|
</dict>
|
||||||
|
<key>virtual-mixed</key>
|
||||||
|
<dict>
|
||||||
|
<key>automatic-install</key>
|
||||||
|
<true/>
|
||||||
|
<key>pkgver</key>
|
||||||
|
<string>virtual-mixed-0.1_1</string>
|
||||||
|
<key>provides</key>
|
||||||
|
<array>
|
||||||
|
<string>mixed-0.1_1</string>
|
||||||
|
</array>
|
||||||
|
<key>run_depends</key>
|
||||||
|
<array>
|
||||||
|
<string>four-0.1_1</string>
|
||||||
|
<string>three-0.1_1</string>
|
||||||
|
</array>
|
||||||
|
<key>short_desc</key>
|
||||||
|
<string>virtual-mixed description</string>
|
||||||
|
<key>state</key>
|
||||||
|
<string>installed</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
Loading…
Reference in New Issue
Block a user