29static const char expected_output[] =
30 "xbps-git-20130310_2\n"
31 "libxbps-git-20130310_2\n"
33 "libarchive-3.1.2_1\n"
43 "xbps-triggers-1.0_1\n";
45static const char expected_output_all[] =
47 "unexistent-pkg-0_1\n"
51ATF_TC(find_pkg_orphans_test);
52ATF_TC_HEAD(find_pkg_orphans_test, tc)
54 atf_tc_set_md_var(tc,
"descr",
"Test xbps_find_pkg_orphans() for target pkg");
57ATF_TC_BODY(find_pkg_orphans_test, tc)
61 xbps_dictionary_t pkgd;
63 const char *pkgver, *tcsdir;
67 tcsdir = atf_tc_get_config_var(tc,
"srcdir");
69 memset(&xh, 0,
sizeof(xh));
74 a = xbps_array_create();
75 xbps_array_add_cstring_nocopy(a,
"xbps-git");
77 pstr = xbps_string_create();
79 for (i = 0; i < xbps_array_count(res); i++) {
80 pkgd = xbps_array_get(res, i);
81 xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver);
82 xbps_string_append_cstring(pstr, pkgver);
83 xbps_string_append_cstring(pstr,
"\n");
85 ATF_REQUIRE_STREQ(xbps_string_cstring_nocopy(pstr), expected_output);
88ATF_TC(find_all_orphans_test);
89ATF_TC_HEAD(find_all_orphans_test, tc)
91 atf_tc_set_md_var(tc,
"descr",
"Test xbps_find_pkg_orphans() for all pkgs");
94ATF_TC_BODY(find_all_orphans_test, tc)
98 xbps_dictionary_t pkgd;
100 const char *pkgver, *tcsdir;
104 tcsdir = atf_tc_get_config_var(tc,
"srcdir");
106 memset(&xh, 0,
sizeof(xh));
111 pstr = xbps_string_create();
113 for (i = 0; i < xbps_array_count(res); i++) {
114 pkgd = xbps_array_get(res, i);
115 xbps_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver);
116 xbps_string_append_cstring(pstr, pkgver);
117 xbps_string_append_cstring(pstr,
"\n");
119 printf(
"%s", xbps_string_cstring_nocopy(pstr));
121 ATF_REQUIRE_STREQ(xbps_string_cstring_nocopy(pstr), expected_output_all);
127 ATF_TP_ADD_TC(tp, find_pkg_orphans_test);
129 ATF_TP_ADD_TC(tp, find_all_orphans_test);
131 return atf_no_error();
Generic XBPS structure handler for initialization.
void void void void void int xbps_init(struct xbps_handle *xhp)
xbps_array_t xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans)
size_t xbps_strlcpy(char *dst, const char *src, size_t dstsize)