Date: Mon, 2 Sep 2013 09:17:58 GMT From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r256829 - soc2013/mattbw/backend/query Message-ID: <201309020917.r829HwHq050907@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mattbw Date: Mon Sep 2 09:17:58 2013 New Revision: 256829 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256829 Log: Missed out check_test previously. This unit test batch now has a failing test added that might explain why resolve is no longer picking up installed packages. Modified: soc2013/mattbw/backend/query/check_test.c Modified: soc2013/mattbw/backend/query/check_test.c ============================================================================== --- soc2013/mattbw/backend/query/check_test.c Mon Sep 2 09:14:03 2013 (r256828) +++ soc2013/mattbw/backend/query/check_test.c Mon Sep 2 09:17:58 2013 (r256829) @@ -24,31 +24,10 @@ #include "pkg.h" /* pkg... */ #include "check.h" /* query_check... */ +#include "../testutils.h" /* gen_pkg */ /* ATF/kyua tests for 'check.c'. */ -static struct pkg *gen_pkg(void); - -static struct pkg * -gen_pkg(void) -{ - struct pkg *pkg; - int pkg_new_result; - - pkg = NULL; - pkg_new_result = pkg_new(&pkg, PKG_FILE); - - ATF_REQUIRE_EQ(pkg_new_result, EPKG_OK); - - pkg_set(pkg, - PKG_NAME, "pkg", - PKG_VERSION, "1.1.4", - PKG_ARCH, "freebsd:10:x86:32", - PKG_REPONAME, "packagesite"); - - return pkg; -} - ATF_TC(package_match_name_only); ATF_TC_HEAD(package_match_name_only, tc) { @@ -61,7 +40,7 @@ struct pkg *pkg; struct query_id id; - pkg = gen_pkg(); + pkg = gen_pkg(PKG_REMOTE); ATF_REQUIRE(pkg != NULL); id.namever = strdup("pkg"); @@ -86,7 +65,7 @@ struct pkg *pkg; struct query_id id; - pkg = gen_pkg(); + pkg = gen_pkg(PKG_REMOTE); ATF_REQUIRE(pkg != NULL); id.namever = strdup("pkg-1.1.4"); @@ -111,7 +90,7 @@ struct pkg *pkg; struct query_id id; - pkg = gen_pkg(); + pkg = gen_pkg(PKG_REMOTE); ATF_REQUIRE(pkg != NULL); id.namever = strdup("pkg-1.1.4"); @@ -120,6 +99,14 @@ ATF_CHECK(query_check_package(pkg, &id)); + /* + * This is a remote package, so setting the ID repo to 'installed' + * should cause the match to fail. + */ + free(id.repo); + id.repo = strdup("installed"); + ATF_CHECK(!query_check_package(pkg, &id)); + pkg_free(pkg); free(id.namever); free(id.arch); @@ -138,7 +125,7 @@ struct pkg *pkg; struct query_id id; - pkg = gen_pkg(); + pkg = gen_pkg(PKG_REMOTE); ATF_REQUIRE(pkg != NULL); id.namever = strdup("wrong-1.1.4"); @@ -165,7 +152,7 @@ struct pkg *pkg; struct query_id id; - pkg = gen_pkg(); + pkg = gen_pkg(PKG_REMOTE); ATF_REQUIRE(pkg != NULL); id.namever = strdup("pkg-1.1.4"); @@ -192,7 +179,7 @@ struct pkg *pkg; struct query_id id; - pkg = gen_pkg(); + pkg = gen_pkg(PKG_REMOTE); ATF_REQUIRE(pkg != NULL); id.namever = strdup("pkg-1.1.4"); @@ -207,6 +194,37 @@ free(id.repo); } +ATF_TC(package_match_full_installed); +ATF_TC_HEAD(package_match_full_installed, tc) +{ + + atf_tc_set_md_var(tc, "descr", + "Ensure installed packages only match installed query IDs."); +} +ATF_TC_BODY(package_match_full_installed, tc) +{ + struct pkg *pkg; + struct query_id id; + + pkg = gen_pkg(PKG_INSTALLED); + ATF_REQUIRE(pkg != NULL); + + id.namever = strdup("pkg-1.1.4"); + id.arch = strdup("freebsd:10:x86:32"); + id.repo = strdup("packagesite"); + + ATF_CHECK(!query_check_package(pkg, &id)); + + free(id.repo); + id.repo = strdup("installed"); + ATF_CHECK(query_check_package(pkg, &id)); + + pkg_free(pkg); + free(id.namever); + free(id.arch); + free(id.repo); +} + /* * This test condition is commented out because it triggers an assertion * failure instead of failing normally. @@ -223,7 +241,7 @@ struct pkg *pkg; struct query_id id; - pkg = gen_pkg(); + pkg = gen_pkg(PKG_REMOTE); ATF_REQUIRE(pkg != NULL); id.namever = NULL; @@ -250,6 +268,7 @@ ATF_TP_ADD_TC(tp, package_match_bad_namever); ATF_TP_ADD_TC(tp, package_match_bad_arch); ATF_TP_ADD_TC(tp, package_match_bad_repo); + ATF_TP_ADD_TC(tp, package_match_full_installed); /*ATF_TP_ADD_TC(tp, package_match_no_namever);*/ return atf_no_error();
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309020917.r829HwHq050907>