Add new kyua tests for xbps_find_pkg_orphans().
This commit is contained in:
parent
a92863cb62
commit
430b224f58
@ -8,6 +8,7 @@ SUBDIRS += plist_match
|
||||
SUBDIRS += plist_match_virtual
|
||||
SUBDIRS += util
|
||||
SUBDIRS += find_pkg_obsoletes
|
||||
SUBDIRS += find_pkg_orphans
|
||||
SUBDIRS += pkgdb
|
||||
|
||||
include ../../mk/subdir.mk
|
||||
|
@ -8,4 +8,5 @@ atf_test_program{name="pkgpattern_match_test"}
|
||||
atf_test_program{name="plist_match_test"}
|
||||
atf_test_program{name="plist_match_virtual_test"}
|
||||
atf_test_program{name="find_pkg_obsoletes_test"}
|
||||
include('find_pkg_orphans/Kyuafile')
|
||||
include('pkgdb/Kyuafile')
|
||||
|
5
tests/libxbps/find_pkg_orphans/Kyuafile
Normal file
5
tests/libxbps/find_pkg_orphans/Kyuafile
Normal file
@ -0,0 +1,5 @@
|
||||
syntax("kyuafile", 1)
|
||||
|
||||
test_suite("libxbps")
|
||||
|
||||
atf_test_program{name="find_pkg_orphans_test"}
|
8
tests/libxbps/find_pkg_orphans/Makefile
Normal file
8
tests/libxbps/find_pkg_orphans/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
TOPDIR = ../../..
|
||||
-include $(TOPDIR)/config.mk
|
||||
|
||||
TESTSSUBDIR = libxbps/find_pkg_orphans
|
||||
TEST = find_pkg_orphans_test
|
||||
EXTRA_FILES = Kyuafile pkgdb-0.21.plist
|
||||
|
||||
include $(TOPDIR)/mk/test.mk
|
127
tests/libxbps/find_pkg_orphans/main.c
Normal file
127
tests/libxbps/find_pkg_orphans/main.c
Normal file
@ -0,0 +1,127 @@
|
||||
/*-
|
||||
* 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>
|
||||
|
||||
static const char expected_output[] =
|
||||
"xbps-git-20130310_2\n"
|
||||
"libxbps-git-20130310_2\n"
|
||||
"proplib-0.6.3_1\n"
|
||||
"libarchive-3.1.2_1\n"
|
||||
"libfetch-2.34_1\n"
|
||||
"confuse-2.7_2\n"
|
||||
"libssl-1.0.1e_3\n"
|
||||
"zlib-1.2.7_1\n"
|
||||
"attr-2.4.46_5\n"
|
||||
"expat-2.1.0_3\n"
|
||||
"liblzma-5.0.4_3\n";
|
||||
|
||||
static const char expected_output_all[] =
|
||||
"orphan0-0_1\n"
|
||||
"unexistent-pkg-0_1\n";
|
||||
|
||||
ATF_TC(find_pkg_orphans_test);
|
||||
ATF_TC_HEAD(find_pkg_orphans_test, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Test xbps_find_pkg_orphans() for target pkg");
|
||||
}
|
||||
|
||||
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;
|
||||
const char *pkgver, *tcsdir;
|
||||
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;
|
||||
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
|
||||
|
||||
a = prop_array_create();
|
||||
prop_array_add_cstring_nocopy(a, "xbps-git");
|
||||
|
||||
pstr = prop_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");
|
||||
}
|
||||
ATF_REQUIRE_STREQ(prop_string_cstring_nocopy(pstr), expected_output);
|
||||
}
|
||||
|
||||
ATF_TC(find_all_orphans_test);
|
||||
ATF_TC_HEAD(find_all_orphans_test, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Test xbps_find_pkg_orphans() for all pkgs");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(find_all_orphans_test, tc)
|
||||
{
|
||||
struct xbps_handle xh;
|
||||
prop_array_t res;
|
||||
prop_dictionary_t pkgd;
|
||||
prop_string_t pstr;
|
||||
const char *pkgver, *tcsdir;
|
||||
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;
|
||||
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
|
||||
|
||||
pstr = prop_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");
|
||||
}
|
||||
printf("%s", prop_string_cstring_nocopy(pstr));
|
||||
|
||||
ATF_REQUIRE_STREQ(prop_string_cstring_nocopy(pstr), expected_output_all);
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
/* First test: find orphans for xbps-git pkg */
|
||||
ATF_TP_ADD_TC(tp, find_pkg_orphans_test);
|
||||
/* Second test: find all orphans */
|
||||
ATF_TP_ADD_TC(tp, find_all_orphans_test);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
198
tests/libxbps/find_pkg_orphans/pkgdb-0.21.plist
Normal file
198
tests/libxbps/find_pkg_orphans/pkgdb-0.21.plist
Normal file
@ -0,0 +1,198 @@
|
||||
<?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>attr</key>
|
||||
<dict>
|
||||
<key>automatic-install</key>
|
||||
<true/>
|
||||
<key>pkgver</key>
|
||||
<string>attr-2.4.46_5</string>
|
||||
<key>run_depends</key>
|
||||
<array>
|
||||
<string>glibc>=2.8_1</string>
|
||||
</array>
|
||||
<key>state</key>
|
||||
<string>installed</string>
|
||||
</dict>
|
||||
<key>confuse</key>
|
||||
<dict>
|
||||
<key>automatic-install</key>
|
||||
<true/>
|
||||
<key>pkgver</key>
|
||||
<string>confuse-2.7_2</string>
|
||||
<key>run_depends</key>
|
||||
<array>
|
||||
<string>glibc>=2.8</string>
|
||||
</array>
|
||||
<key>state</key>
|
||||
<string>installed</string>
|
||||
</dict>
|
||||
<key>expat</key>
|
||||
<dict>
|
||||
<key>automatic-install</key>
|
||||
<true/>
|
||||
<key>pkgver</key>
|
||||
<string>expat-2.1.0_3</string>
|
||||
<key>run_depends</key>
|
||||
<array>
|
||||
<string>glibc>=2.8_1</string>
|
||||
</array>
|
||||
<key>state</key>
|
||||
<string>installed</string>
|
||||
</dict>
|
||||
<key>libarchive</key>
|
||||
<dict>
|
||||
<key>automatic-install</key>
|
||||
<true/>
|
||||
<key>pkgver</key>
|
||||
<string>libarchive-3.1.2_1</string>
|
||||
<key>run_depends</key>
|
||||
<array>
|
||||
<string>libssl>=1.0.0_1</string>
|
||||
<string>attr>=2.4.43_1</string>
|
||||
<string>expat>=2.0.0_1</string>
|
||||
<string>liblzma>=5.0.0_1</string>
|
||||
<string>bzip2>=1.0.5_1</string>
|
||||
<string>zlib>=1.2.3_1</string>
|
||||
<string>glibc>=2.8_1</string>
|
||||
</array>
|
||||
<key>state</key>
|
||||
<string>installed</string>
|
||||
</dict>
|
||||
<key>libfetch</key>
|
||||
<dict>
|
||||
<key>automatic-install</key>
|
||||
<true/>
|
||||
<key>pkgver</key>
|
||||
<string>libfetch-2.34_1</string>
|
||||
<key>run_depends</key>
|
||||
<array>
|
||||
<string>libssl>=1.0.0_1</string>
|
||||
<string>glibc>=2.8_1</string>
|
||||
</array>
|
||||
<key>state</key>
|
||||
<string>installed</string>
|
||||
</dict>
|
||||
<key>liblzma</key>
|
||||
<dict>
|
||||
<key>automatic-install</key>
|
||||
<true/>
|
||||
<key>pkgver</key>
|
||||
<string>liblzma-5.0.4_3</string>
|
||||
<key>run_depends</key>
|
||||
<array>
|
||||
<string>glibc>=2.8_1</string>
|
||||
</array>
|
||||
<key>state</key>
|
||||
<string>installed</string>
|
||||
</dict>
|
||||
<key>libssl</key>
|
||||
<dict>
|
||||
<key>automatic-install</key>
|
||||
<true/>
|
||||
<key>pkgver</key>
|
||||
<string>libssl-1.0.1e_3</string>
|
||||
<key>run_depends</key>
|
||||
<array>
|
||||
<string>glibc>=2.8_1</string>
|
||||
<string>zlib>=1.2.3_1</string>
|
||||
</array>
|
||||
<key>state</key>
|
||||
<string>installed</string>
|
||||
</dict>
|
||||
<key>libxbps-git</key>
|
||||
<dict>
|
||||
<key>automatic-install</key>
|
||||
<true/>
|
||||
<key>pkgver</key>
|
||||
<string>libxbps-git-20130310_2</string>
|
||||
<key>provides</key>
|
||||
<array>
|
||||
<string>libxbps-20130310</string>
|
||||
</array>
|
||||
<key>run_depends</key>
|
||||
<array>
|
||||
<string>libfetch>=2.33_1</string>
|
||||
<string>zlib>=1.2.3_1</string>
|
||||
<string>glibc>=2.8_1</string>
|
||||
<string>proplib>=0.1_1</string>
|
||||
<string>libarchive>=3.1.2_1</string>
|
||||
<string>confuse>=2.7_1</string>
|
||||
<string>libssl>=1.0.0_1</string>
|
||||
</array>
|
||||
<key>state</key>
|
||||
<string>installed</string>
|
||||
</dict>
|
||||
<key>proplib</key>
|
||||
<dict>
|
||||
<key>automatic-install</key>
|
||||
<true/>
|
||||
<key>pkgver</key>
|
||||
<string>proplib-0.6.3_1</string>
|
||||
<key>run_depends</key>
|
||||
<array>
|
||||
<string>zlib>=1.2.3_1</string>
|
||||
<string>glibc>=2.8_1</string>
|
||||
</array>
|
||||
<key>state</key>
|
||||
<string>installed</string>
|
||||
</dict>
|
||||
<key>unexistent-pkg</key>
|
||||
<dict>
|
||||
<key>automatic-install</key>
|
||||
<true/>
|
||||
<key>pkgver</key>
|
||||
<string>unexistent-pkg-0_1</string>
|
||||
<key>state</key>
|
||||
<string>installed</string>
|
||||
</dict>
|
||||
<key>orphan0</key>
|
||||
<dict>
|
||||
<key>automatic-install</key>
|
||||
<true/>
|
||||
<key>pkgver</key>
|
||||
<string>orphan0-0_1</string>
|
||||
<key>run_depends</key>
|
||||
<array>
|
||||
<string>unexistent-pkg>=0</string>
|
||||
</array>
|
||||
<key>state</key>
|
||||
<string>installed</string>
|
||||
</dict>
|
||||
<key>xbps-git</key>
|
||||
<dict>
|
||||
<key>automatic-install</key>
|
||||
<false/>
|
||||
<key>pkgver</key>
|
||||
<string>xbps-git-20130310_2</string>
|
||||
<key>provides</key>
|
||||
<array>
|
||||
<string>xbps-20130310</string>
|
||||
</array>
|
||||
<key>run_depends</key>
|
||||
<array>
|
||||
<string>xbps-triggers>=0</string>
|
||||
<string>libxbps-git-20130310_2</string>
|
||||
<string>glibc>=2.8_1</string>
|
||||
<string>proplib>=0.1_1</string>
|
||||
<string>libarchive>=3.1.2_1</string>
|
||||
</array>
|
||||
<key>state</key>
|
||||
<string>installed</string>
|
||||
</dict>
|
||||
<key>zlib</key>
|
||||
<dict>
|
||||
<key>automatic-install</key>
|
||||
<true/>
|
||||
<key>pkgver</key>
|
||||
<string>zlib-1.2.7_1</string>
|
||||
<key>run_depends</key>
|
||||
<array>
|
||||
<string>glibc>=2.8</string>
|
||||
</array>
|
||||
<key>state</key>
|
||||
<string>installed</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
Loading…
Reference in New Issue
Block a user