From 15b148fb518750cc6096afbc58a194753476a517 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 30 Nov 2012 07:47:22 +0100 Subject: [PATCH] tests: remove obsolete tests for 0.19 API. --- tests/libxbps/Makefile | 5 - tests/libxbps/find_pkg/Kyuafile | 5 - tests/libxbps/find_pkg/Makefile | 8 - tests/libxbps/find_pkg/main.c | 95 -------- tests/libxbps/find_pkg/pkgdb.plist | 38 --- tests/libxbps/find_pkg/xbps.conf | 1 - tests/libxbps/plist_array_replace/Makefile | 7 - tests/libxbps/plist_array_replace/main.c | 139 ----------- tests/libxbps/plist_find_array/Makefile | 7 - tests/libxbps/plist_find_array/main.c | 176 -------------- tests/libxbps/plist_find_dictionary/Makefile | 7 - tests/libxbps/plist_find_dictionary/main.c | 181 --------------- tests/libxbps/plist_remove/Makefile | 7 - tests/libxbps/plist_remove/main.c | 230 ------------------- 14 files changed, 906 deletions(-) delete mode 100644 tests/libxbps/find_pkg/Kyuafile delete mode 100644 tests/libxbps/find_pkg/Makefile delete mode 100644 tests/libxbps/find_pkg/main.c delete mode 100644 tests/libxbps/find_pkg/pkgdb.plist delete mode 100644 tests/libxbps/find_pkg/xbps.conf delete mode 100644 tests/libxbps/plist_array_replace/Makefile delete mode 100644 tests/libxbps/plist_array_replace/main.c delete mode 100644 tests/libxbps/plist_find_array/Makefile delete mode 100644 tests/libxbps/plist_find_array/main.c delete mode 100644 tests/libxbps/plist_find_dictionary/Makefile delete mode 100644 tests/libxbps/plist_find_dictionary/main.c delete mode 100644 tests/libxbps/plist_remove/Makefile delete mode 100644 tests/libxbps/plist_remove/main.c diff --git a/tests/libxbps/Makefile b/tests/libxbps/Makefile index 85406c10..1ae6fcac 100644 --- a/tests/libxbps/Makefile +++ b/tests/libxbps/Makefile @@ -4,13 +4,8 @@ SUBDIRS = common SUBDIRS += cmpver SUBDIRS += pkgpattern_match -SUBDIRS += plist_array_replace -SUBDIRS += plist_find_array -SUBDIRS += plist_find_dictionary SUBDIRS += plist_match SUBDIRS += plist_match_virtual -SUBDIRS += plist_remove SUBDIRS += util -SUBDIRS += find_pkg include ../../mk/subdir.mk diff --git a/tests/libxbps/find_pkg/Kyuafile b/tests/libxbps/find_pkg/Kyuafile deleted file mode 100644 index ba7212fd..00000000 --- a/tests/libxbps/find_pkg/Kyuafile +++ /dev/null @@ -1,5 +0,0 @@ -syntax("kyuafile", 1) - -test_suite("libxbps") - -atf_test_program{name="pkg_installed_in_pkgdb_test"} diff --git a/tests/libxbps/find_pkg/Makefile b/tests/libxbps/find_pkg/Makefile deleted file mode 100644 index 2350dedc..00000000 --- a/tests/libxbps/find_pkg/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -TOPDIR = ../../.. --include $(TOPDIR)/config.mk - -TESTSSUBDIR = libxbps/find_pkg -TEST = pkg_installed_in_pkgdb_test -EXTRA_FILES = Kyuafile xbps.conf pkgdb.plist - -include $(TOPDIR)/mk/test.mk diff --git a/tests/libxbps/find_pkg/main.c b/tests/libxbps/find_pkg/main.c deleted file mode 100644 index 2f2adb6d..00000000 --- a/tests/libxbps/find_pkg/main.c +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * Copyright (c) 2012 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 -#include -#include - -ATF_TC(find_pkg_dict_installed_test); -ATF_TC_HEAD(find_pkg_dict_installed_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_find_pkg_dict_installed"); -} -ATF_TC_BODY(find_pkg_dict_installed_test, tc) -{ - struct xbps_handle xh; - prop_dictionary_t dr; - const char *pkgver, *tcsdir; - - /* get test source dir */ - tcsdir = atf_tc_get_config_var(tc, "srcdir"); - - /* initialize xbps */ - memset(&xh, 0, sizeof(xh)); - xh.rootdir = "/tmp"; - xh.metadir = tcsdir; - ATF_REQUIRE_EQ(xbps_init(&xh), 0); - - dr = xbps_find_pkg_dict_installed(&xh, "xbps", false); - ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY); - prop_dictionary_get_cstring_nocopy(dr, "pkgver", &pkgver); - ATF_REQUIRE_STREQ(pkgver, "xbps-0.14"); - - xbps_end(&xh); -} - -ATF_TC(find_virtualpkg_dict_installed_test); -ATF_TC_HEAD(find_virtualpkg_dict_installed_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_find_virtualpkg_dict_installed"); -} -ATF_TC_BODY(find_virtualpkg_dict_installed_test, tc) -{ - struct xbps_handle xh; - prop_dictionary_t dr; - const char *pkgver, *tcsdir; - char *cffile; - - /* get test source dir */ - tcsdir = atf_tc_get_config_var(tc, "srcdir"); - cffile = xbps_xasprintf("%s/xbps.conf", tcsdir); - - /* initialize xbps */ - memset(&xh, 0, sizeof(xh)); - xh.rootdir = "/tmp"; - xh.conffile = cffile; - xh.metadir = tcsdir; - ATF_REQUIRE_EQ(xbps_init(&xh), 0); - - dr = xbps_find_virtualpkg_dict_installed(&xh, "xbps-src>=24", true); - ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY); - prop_dictionary_get_cstring_nocopy(dr, "pkgver", &pkgver); - ATF_REQUIRE_STREQ(pkgver, "xbps-src-git-20120312"); - - xbps_end(&xh); -} - -ATF_TP_ADD_TCS(tp) -{ - ATF_TP_ADD_TC(tp, find_pkg_dict_installed_test); - ATF_TP_ADD_TC(tp, find_virtualpkg_dict_installed_test); - - return atf_no_error(); -} diff --git a/tests/libxbps/find_pkg/pkgdb.plist b/tests/libxbps/find_pkg/pkgdb.plist deleted file mode 100644 index 8ccd9836..00000000 --- a/tests/libxbps/find_pkg/pkgdb.plist +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - automatic-install - - pkgname - xbps - pkgver - xbps-0.14 - short_desc - The XBPS package system - state - installed - version - 0.14 - - - automatic-install - - pkgname - xbps-src-git - pkgver - xbps-src-git-20120312 - provides - - xbps-src-9999 - - short_desc - The XBPS package system - binary package builder (git snaphost) - state - installed - version - 20120312 - - - diff --git a/tests/libxbps/find_pkg/xbps.conf b/tests/libxbps/find_pkg/xbps.conf deleted file mode 100644 index 6e8b158a..00000000 --- a/tests/libxbps/find_pkg/xbps.conf +++ /dev/null @@ -1 +0,0 @@ -virtual-package xbps-src-git { targets = "xbps-src-9999" } diff --git a/tests/libxbps/plist_array_replace/Makefile b/tests/libxbps/plist_array_replace/Makefile deleted file mode 100644 index adbc9781..00000000 --- a/tests/libxbps/plist_array_replace/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -TOPDIR = ../../.. --include $(TOPDIR)/config.mk - -TEST = plist_array_replace_test - -include ../Makefile.inc -include $(TOPDIR)/mk/test.mk diff --git a/tests/libxbps/plist_array_replace/main.c b/tests/libxbps/plist_array_replace/main.c deleted file mode 100644 index a79afa67..00000000 --- a/tests/libxbps/plist_array_replace/main.c +++ /dev/null @@ -1,139 +0,0 @@ -/*- - * Copyright (c) 2012 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 -#include - -static const char axml[] = -"\n" -"\n" -"\n" -"\n" -" \n" -" pkgname\n" -" afoo\n" -" version\n" -" 1.1\n" -" pkgver\n" -" afoo-1.1\n" -" \n" -" \n" -" pkgname\n" -" foo\n" -" version\n" -" 2.0\n" -" pkgver\n" -" foo-2.0\n" -" \n" -"\n" -"\n"; - -static const char axml2[] = -"\n" -"\n" -"\n" -"\n" -" \n" -" pkgname\n" -" bfoo\n" -" version\n" -" 1.2\n" -" pkgver\n" -" bfoo-1.2\n" -" \n" -" \n" -" pkgname\n" -" foo\n" -" version\n" -" 2.0\n" -" pkgver\n" -" foo-2.0\n" -" \n" -"\n" -"\n"; - -ATF_TC(array_replace_dict_by_name_test); - -ATF_TC_HEAD(array_replace_dict_by_name_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_array_replace_dict_by_name"); -} - -ATF_TC_BODY(array_replace_dict_by_name_test, tc) -{ - prop_array_t orig, new; - prop_dictionary_t d; - - orig = prop_array_internalize(axml); - ATF_REQUIRE_EQ(prop_object_type(orig), PROP_TYPE_ARRAY); - - new = prop_array_internalize(axml2); - ATF_REQUIRE_EQ(prop_object_type(new), PROP_TYPE_ARRAY); - - d = prop_dictionary_create(); - ATF_REQUIRE_EQ(prop_object_type(d), PROP_TYPE_DICTIONARY); - ATF_REQUIRE_EQ(prop_dictionary_set_cstring_nocopy(d, "pkgname", "bfoo"), true); - ATF_REQUIRE_EQ(prop_dictionary_set_cstring_nocopy(d, "pkgver", "bfoo-1.2"), true); - ATF_REQUIRE_EQ(prop_dictionary_set_cstring_nocopy(d, "version", "1.2"), true); - - ATF_REQUIRE_EQ(xbps_array_replace_dict_by_name(orig, d, "afoo"), 0); - ATF_REQUIRE_EQ(prop_array_equals(orig, new), true); -} - -ATF_TC(array_replace_dict_by_pattern_test); - -ATF_TC_HEAD(array_replace_dict_by_pattern_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_array_replace_dict_by_pattern"); -} - -ATF_TC_BODY(array_replace_dict_by_pattern_test, tc) -{ - prop_array_t orig, new; - prop_dictionary_t d; - - orig = prop_array_internalize(axml); - ATF_REQUIRE_EQ(prop_object_type(orig), PROP_TYPE_ARRAY); - - new = prop_array_internalize(axml2); - ATF_REQUIRE_EQ(prop_object_type(new), PROP_TYPE_ARRAY); - - d = prop_dictionary_create(); - ATF_REQUIRE_EQ(prop_object_type(d), PROP_TYPE_DICTIONARY); - ATF_REQUIRE_EQ(prop_dictionary_set_cstring_nocopy(d, "pkgname", "bfoo"), true); - ATF_REQUIRE_EQ(prop_dictionary_set_cstring_nocopy(d, "pkgver", "bfoo-1.2"), true); - ATF_REQUIRE_EQ(prop_dictionary_set_cstring_nocopy(d, "version", "1.2"), true); - - ATF_REQUIRE_EQ(xbps_array_replace_dict_by_pattern(orig, d, "afoo>=1.0"), 0); - ATF_REQUIRE_EQ(prop_array_equals(orig, new), true); -} - -ATF_TP_ADD_TCS(tp) -{ - ATF_TP_ADD_TC(tp, array_replace_dict_by_name_test); - ATF_TP_ADD_TC(tp, array_replace_dict_by_pattern_test); - - return atf_no_error(); -} diff --git a/tests/libxbps/plist_find_array/Makefile b/tests/libxbps/plist_find_array/Makefile deleted file mode 100644 index ab0c59f1..00000000 --- a/tests/libxbps/plist_find_array/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -TOPDIR = ../../.. --include $(TOPDIR)/config.mk - -TEST = plist_find_array_test - -include ../Makefile.inc -include $(TOPDIR)/mk/test.mk diff --git a/tests/libxbps/plist_find_array/main.c b/tests/libxbps/plist_find_array/main.c deleted file mode 100644 index 4e9132e9..00000000 --- a/tests/libxbps/plist_find_array/main.c +++ /dev/null @@ -1,176 +0,0 @@ -/*- - * Copyright (c) 2012 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 -#include -#include - -static const char arrayxml[] = -"\n" -"\n" -"\n" -"\n" -" \n" -" pkgname\n" -" afoo\n" -" version\n" -" 1.1\n" -" pkgver\n" -" afoo-1.1\n" -" provides\n" -" \n" -" virtualpkg-9999\n" -" \n" -" \n" -" \n" -" pkgname\n" -" foo\n" -" version\n" -" 2.0\n" -" pkgver\n" -" foo-2.0\n" -" \n" -"\n" -"\n"; - -ATF_TC(find_pkg_in_array_by_name_test); -ATF_TC_HEAD(find_pkg_in_array_by_name_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_find_pkg_in_array_by_name"); -} -ATF_TC_BODY(find_pkg_in_array_by_name_test, tc) -{ - struct xbps_handle xh; - prop_array_t a; - prop_dictionary_t dr; - - a = prop_array_internalize(arrayxml); - ATF_REQUIRE_EQ(prop_object_type(a), PROP_TYPE_ARRAY); - - memset(&xh, 0, sizeof(xh)); - xbps_init(&xh); - /* match by pkgname */ - dr = xbps_find_pkg_in_array_by_name(&xh, a, "foo", NULL); - ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY); -} - -ATF_TC(find_pkg_in_array_by_pattern_test); -ATF_TC_HEAD(find_pkg_in_array_by_pattern_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_find_pkg_in_array_by_pattern"); -} -ATF_TC_BODY(find_pkg_in_array_by_pattern_test, tc) -{ - struct xbps_handle xh; - prop_array_t a; - prop_dictionary_t dr; - - a = prop_array_internalize(arrayxml); - ATF_REQUIRE_EQ(prop_object_type(a), PROP_TYPE_ARRAY); - - memset(&xh, 0, sizeof(xh)); - xbps_init(&xh); - /* match by pkgpattern */ - dr = xbps_find_pkg_in_array_by_pattern(&xh, a, "foo>=2.0", NULL); - ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY); -} - -ATF_TC(find_pkg_in_array_by_pkgver_test); -ATF_TC_HEAD(find_pkg_in_array_by_pkgver_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_find_pkg_in_array_by_pkgver"); -} -ATF_TC_BODY(find_pkg_in_array_by_pkgver_test, tc) -{ - struct xbps_handle xh; - prop_array_t a; - prop_dictionary_t dr; - - a = prop_array_internalize(arrayxml); - ATF_REQUIRE_EQ(prop_object_type(a), PROP_TYPE_ARRAY); - - memset(&xh, 0, sizeof(xh)); - xbps_init(&xh); - /* exact match by pkgver */ - dr = xbps_find_pkg_in_array_by_pkgver(&xh, a, "foo-2.0", NULL); - ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY); -} - -ATF_TC(find_virtualpkg_in_array_by_name_test); -ATF_TC_HEAD(find_virtualpkg_in_array_by_name_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_find_virtualpkg_in_array_by_name"); -} -ATF_TC_BODY(find_virtualpkg_in_array_by_name_test, tc) -{ - struct xbps_handle xh; - prop_array_t a; - prop_dictionary_t dr; - const char *pkgname; - - a = prop_array_internalize(arrayxml); - ATF_REQUIRE_EQ(prop_object_type(a), PROP_TYPE_ARRAY); - - memset(&xh, 0, sizeof(xh)); - xbps_init(&xh); - dr = xbps_find_virtualpkg_in_array_by_name(&xh, a, "virtualpkg"); - ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY); - prop_dictionary_get_cstring_nocopy(dr, "pkgname", &pkgname); - ATF_REQUIRE_STREQ(pkgname, "afoo"); -} - -ATF_TC(find_virtualpkg_in_array_by_pattern_test); -ATF_TC_HEAD(find_virtualpkg_in_array_by_pattern_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_find_virtualpkg_in_array_by_pattern"); -} -ATF_TC_BODY(find_virtualpkg_in_array_by_pattern_test, tc) -{ - struct xbps_handle xh; - prop_array_t a; - prop_dictionary_t dr; - const char *pkgname; - - a = prop_array_internalize(arrayxml); - ATF_REQUIRE_EQ(prop_object_type(a), PROP_TYPE_ARRAY); - - memset(&xh, 0, sizeof(xh)); - xbps_init(&xh); - dr = xbps_find_virtualpkg_in_array_by_pattern(&xh, a, "virtualpkg>=9999"); - ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY); - prop_dictionary_get_cstring_nocopy(dr, "pkgname", &pkgname); - ATF_REQUIRE_STREQ(pkgname, "afoo"); -} - -ATF_TP_ADD_TCS(tp) -{ - ATF_TP_ADD_TC(tp, find_pkg_in_array_by_name_test); - ATF_TP_ADD_TC(tp, find_pkg_in_array_by_pattern_test); - ATF_TP_ADD_TC(tp, find_pkg_in_array_by_pkgver_test); - ATF_TP_ADD_TC(tp, find_virtualpkg_in_array_by_name_test); - ATF_TP_ADD_TC(tp, find_virtualpkg_in_array_by_pattern_test); - - return atf_no_error(); -} diff --git a/tests/libxbps/plist_find_dictionary/Makefile b/tests/libxbps/plist_find_dictionary/Makefile deleted file mode 100644 index 21948836..00000000 --- a/tests/libxbps/plist_find_dictionary/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -TOPDIR = ../../.. --include $(TOPDIR)/config.mk - -TEST = plist_find_dictionary_test - -include ../Makefile.inc -include $(TOPDIR)/mk/test.mk diff --git a/tests/libxbps/plist_find_dictionary/main.c b/tests/libxbps/plist_find_dictionary/main.c deleted file mode 100644 index a70ead89..00000000 --- a/tests/libxbps/plist_find_dictionary/main.c +++ /dev/null @@ -1,181 +0,0 @@ -/*- - * Copyright (c) 2012 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 -#include -#include - -static const char dictxml[] = -"\n" -"\n" -"\n" -"\n" -" packages\n" -" \n" -" \n" -" pkgname\n" -" afoo\n" -" version\n" -" 1.1_1\n" -" pkgver\n" -" afoo-1.1_1\n" -" provides\n" -" \n" -" virtualpkg-9999_1\n" -" \n" -" \n" -" \n" -" pkgname\n" -" foo\n" -" version\n" -" 2.0_1\n" -" pkgver\n" -" foo-2.0_1\n" -" \n" -" \n" -"\n" -"\n"; - -ATF_TC(find_pkg_in_dict_by_name_test); -ATF_TC_HEAD(find_pkg_in_dict_by_name_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_find_pkg_in_dict_by_name"); -} -ATF_TC_BODY(find_pkg_in_dict_by_name_test, tc) -{ - struct xbps_handle xh; - prop_dictionary_t d, dr; - - d = prop_dictionary_internalize(dictxml); - ATF_REQUIRE_EQ(prop_object_type(d), PROP_TYPE_DICTIONARY); - - memset(&xh, 0, sizeof(xh)); - xbps_init(&xh); - /* match by pkgname */ - dr = xbps_find_pkg_in_dict_by_name(&xh, d, "packages", "foo"); - ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY); -} - -ATF_TC(find_pkg_in_dict_by_pattern_test); -ATF_TC_HEAD(find_pkg_in_dict_by_pattern_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_find_pkg_in_dict_by_pattern"); -} -ATF_TC_BODY(find_pkg_in_dict_by_pattern_test, tc) -{ - struct xbps_handle xh; - prop_dictionary_t d, dr; - - d = prop_dictionary_internalize(dictxml); - ATF_REQUIRE_EQ(prop_object_type(d), PROP_TYPE_DICTIONARY); - - memset(&xh, 0, sizeof(xh)); - xbps_init(&xh); - /* match by pkgpattern */ - dr = xbps_find_pkg_in_dict_by_pattern(&xh, d, "packages", "foo>=2.0"); - ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY); -} - -ATF_TC(find_pkg_in_dict_by_pkgver_test); -ATF_TC_HEAD(find_pkg_in_dict_by_pkgver_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_find_pkg_in_dict_by_pkgver"); -} -ATF_TC_BODY(find_pkg_in_dict_by_pkgver_test, tc) -{ - struct xbps_handle xh; - prop_dictionary_t d, dr; - - d = prop_dictionary_internalize(dictxml); - ATF_REQUIRE_EQ(prop_object_type(d), PROP_TYPE_DICTIONARY); - - memset(&xh, 0, sizeof(xh)); - xbps_init(&xh); - /* exact match by pkgver */ - dr = xbps_find_pkg_in_dict_by_pkgver(&xh, d, "packages", "foo-2.0_1"); - ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY); -} - -ATF_TC(find_virtualpkg_in_dict_by_pattern_test); -ATF_TC_HEAD(find_virtualpkg_in_dict_by_pattern_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_find_virtualpkg_in_dict_by_pattern"); -} -ATF_TC_BODY(find_virtualpkg_in_dict_by_pattern_test, tc) -{ - struct xbps_handle xh; - prop_dictionary_t d, dr; - const char *pkgver; - - d = prop_dictionary_internalize(dictxml); - ATF_REQUIRE_EQ(prop_object_type(d), PROP_TYPE_DICTIONARY); - - /* match virtualpkg by pattern */ - memset(&xh, 0, sizeof(xh)); - xbps_init(&xh); - dr = xbps_find_virtualpkg_in_dict_by_pattern(&xh, d, "packages", "virtualpkg>=9999"); - ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY); - prop_dictionary_get_cstring_nocopy(dr, "pkgver", &pkgver); - ATF_REQUIRE_STREQ(pkgver, "afoo-1.1_1"); - - dr = xbps_find_virtualpkg_in_dict_by_pattern(&xh, d, "packages", "virtualpkg<=9999_1"); - ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY); - prop_dictionary_get_cstring_nocopy(dr, "pkgver", &pkgver); - ATF_REQUIRE_STREQ(pkgver, "afoo-1.1_1"); -} - -ATF_TC(find_virtualpkg_in_dict_by_name_test); -ATF_TC_HEAD(find_virtualpkg_in_dict_by_name_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_find_virtualpkg_in_dict_by_name"); -} -ATF_TC_BODY(find_virtualpkg_in_dict_by_name_test, tc) -{ - struct xbps_handle xh; - prop_dictionary_t d, dr; - const char *pkgver; - - d = prop_dictionary_internalize(dictxml); - ATF_REQUIRE_EQ(prop_object_type(d), PROP_TYPE_DICTIONARY); - - memset(&xh, 0, sizeof(xh)); - xbps_init(&xh); - /* match virtualpkg by name */ - dr = xbps_find_virtualpkg_in_dict_by_name(&xh, d, "packages", "virtualpkg"); - ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY); - prop_dictionary_get_cstring_nocopy(dr, "pkgver", &pkgver); - ATF_REQUIRE_STREQ(pkgver, "afoo-1.1_1"); -} - -ATF_TP_ADD_TCS(tp) -{ - ATF_TP_ADD_TC(tp, find_pkg_in_dict_by_name_test); - ATF_TP_ADD_TC(tp, find_pkg_in_dict_by_pattern_test); - ATF_TP_ADD_TC(tp, find_pkg_in_dict_by_pkgver_test); - ATF_TP_ADD_TC(tp, find_virtualpkg_in_dict_by_name_test); - ATF_TP_ADD_TC(tp, find_virtualpkg_in_dict_by_pattern_test); - - return atf_no_error(); -} diff --git a/tests/libxbps/plist_remove/Makefile b/tests/libxbps/plist_remove/Makefile deleted file mode 100644 index 6d4b63cc..00000000 --- a/tests/libxbps/plist_remove/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -TOPDIR = ../../.. --include $(TOPDIR)/config.mk - -TEST = plist_remove_test - -include ../Makefile.inc -include $(TOPDIR)/mk/test.mk diff --git a/tests/libxbps/plist_remove/main.c b/tests/libxbps/plist_remove/main.c deleted file mode 100644 index 218dbaee..00000000 --- a/tests/libxbps/plist_remove/main.c +++ /dev/null @@ -1,230 +0,0 @@ -/*- - * Copyright (c) 2012 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 -#include -#include - -static const char dictxml[] = -"\n" -"\n" -"\n" -"\n" -" packages\n" -" \n" -" \n" -" pkgname\n" -" afoo\n" -" version\n" -" 1.1_1\n" -" pkgver\n" -" afoo-1.1_1\n" -" \n" -" \n" -" pkgname\n" -" foo\n" -" version\n" -" 2.0_1\n" -" pkgver\n" -" foo-2.0_1\n" -" \n" -" \n" -"\n" -"\n"; - -static const char dictxml2[] = -"\n" -"\n" -"\n" -"\n" -" packages\n" -" \n" -" \n" -" pkgname\n" -" foo\n" -" version\n" -" 2.0_1\n" -" pkgver\n" -" foo-2.0_1\n" -" \n" -" \n" -"\n" -"\n"; - -static const char axml[] = -"\n" -"\n" -"\n" -"\n" -" foo-1.0_1\n" -" blah-2.0_1\n" -"\n" -"\n"; - -static const char axml2[] = -"\n" -"\n" -"\n" -"\n" -" blah-2.0_1\n" -"\n" -"\n"; - -ATF_TC(remove_pkg_from_array_by_name_test); - -ATF_TC_HEAD(remove_pkg_from_array_by_name_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_remove_pkg_from_array_by_name"); -} - -ATF_TC_BODY(remove_pkg_from_array_by_name_test, tc) -{ - struct xbps_handle xh; - prop_array_t a; - prop_dictionary_t d, d2; - - d = prop_dictionary_internalize(dictxml); - ATF_REQUIRE_EQ(prop_object_type(d), PROP_TYPE_DICTIONARY); - - d2 = prop_dictionary_internalize(dictxml2); - ATF_REQUIRE_EQ(prop_object_type(d2), PROP_TYPE_DICTIONARY); - - memset(&xh, 0, sizeof(xh)); - xbps_init(&xh); - a = prop_dictionary_get(d, "packages"); - ATF_REQUIRE_EQ(xbps_remove_pkg_from_array_by_name(&xh, a, "afoo", NULL), true); - ATF_REQUIRE_EQ(prop_dictionary_equals(d, d2), true); -} - -ATF_TC(remove_pkg_from_array_by_pattern_test); - -ATF_TC_HEAD(remove_pkg_from_array_by_pattern_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_remove_pkg_from_array_by_pattern"); -} - -ATF_TC_BODY(remove_pkg_from_array_by_pattern_test, tc) -{ - struct xbps_handle xh; - prop_array_t a; - prop_dictionary_t d, d2; - - d = prop_dictionary_internalize(dictxml); - ATF_REQUIRE_EQ(prop_object_type(d), PROP_TYPE_DICTIONARY); - - d2 = prop_dictionary_internalize(dictxml2); - ATF_REQUIRE_EQ(prop_object_type(d2), PROP_TYPE_DICTIONARY); - - memset(&xh, 0, sizeof(xh)); - xbps_init(&xh); - a = prop_dictionary_get(d, "packages"); - ATF_REQUIRE_EQ(xbps_remove_pkg_from_array_by_pattern(&xh, a, "afoo>=1.0", NULL), true); - ATF_REQUIRE_EQ(prop_dictionary_equals(d, d2), true); -} - -ATF_TC(remove_pkg_from_array_by_pkgver_test); - -ATF_TC_HEAD(remove_pkg_from_array_by_pkgver_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_remove_pkg_from_array_by_pkgver"); -} - -ATF_TC_BODY(remove_pkg_from_array_by_pkgver_test, tc) -{ - struct xbps_handle xh; - prop_array_t a; - prop_dictionary_t d, d2; - - d = prop_dictionary_internalize(dictxml); - ATF_REQUIRE_EQ(prop_object_type(d), PROP_TYPE_DICTIONARY); - - d2 = prop_dictionary_internalize(dictxml2); - ATF_REQUIRE_EQ(prop_object_type(d2), PROP_TYPE_DICTIONARY); - - memset(&xh, 0, sizeof(xh)); - xbps_init(&xh); - a = prop_dictionary_get(d, "packages"); - ATF_REQUIRE_EQ(xbps_remove_pkg_from_array_by_pkgver(&xh, a, "afoo-1.1_1", NULL), true); - ATF_REQUIRE_EQ(prop_dictionary_equals(d, d2), true); -} - -ATF_TC(remove_string_from_array_test); - -ATF_TC_HEAD(remove_string_from_array_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_remove_string_from_array"); -} - -ATF_TC_BODY(remove_string_from_array_test, tc) -{ - struct xbps_handle xh; - prop_array_t a, a2; - - a = prop_array_internalize(axml); - ATF_REQUIRE_EQ(prop_object_type(a), PROP_TYPE_ARRAY); - - a2 = prop_array_internalize(axml2); - ATF_REQUIRE_EQ(prop_object_type(a2), PROP_TYPE_ARRAY); - - memset(&xh, 0, sizeof(xh)); - xbps_init(&xh); - ATF_REQUIRE_EQ(xbps_remove_string_from_array(&xh, a, "foo-1.0_1"), true); - ATF_REQUIRE_EQ(prop_array_equals(a, a2), true); -} - -ATF_TC(remove_pkgname_from_array_test); - -ATF_TC_HEAD(remove_pkgname_from_array_test, tc) -{ - atf_tc_set_md_var(tc, "descr", "Test xbps_remove_pkgname_from_array"); -} - -ATF_TC_BODY(remove_pkgname_from_array_test, tc) -{ - struct xbps_handle xh; - prop_array_t a, a2; - - a = prop_array_internalize(axml); - ATF_REQUIRE_EQ(prop_object_type(a), PROP_TYPE_ARRAY); - - a2 = prop_array_internalize(axml2); - ATF_REQUIRE_EQ(prop_object_type(a2), PROP_TYPE_ARRAY); - - memset(&xh, 0, sizeof(xh)); - xbps_init(&xh); - ATF_REQUIRE_EQ(xbps_remove_pkgname_from_array(&xh, a, "foo"), true); - ATF_REQUIRE_EQ(prop_array_equals(a, a2), true); -} - -ATF_TP_ADD_TCS(tp) -{ - ATF_TP_ADD_TC(tp, remove_pkg_from_array_by_name_test); - ATF_TP_ADD_TC(tp, remove_pkg_from_array_by_pattern_test); - ATF_TP_ADD_TC(tp, remove_pkg_from_array_by_pkgver_test); - ATF_TP_ADD_TC(tp, remove_string_from_array_test); - ATF_TP_ADD_TC(tp, remove_pkgname_from_array_test); - - return atf_no_error(); -}