From owner-svn-soc-all@FreeBSD.ORG Mon Sep 2 09:17:58 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 75AFDC1E for ; Mon, 2 Sep 2013 09:17:58 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 62F912B00 for ; Mon, 2 Sep 2013 09:17:58 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r829HwIW050909 for ; Mon, 2 Sep 2013 09:17:58 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r829HwHq050907 for svn-soc-all@FreeBSD.org; Mon, 2 Sep 2013 09:17:58 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 2 Sep 2013 09:17:58 GMT Message-Id: <201309020917.r829HwHq050907@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r256829 - soc2013/mattbw/backend/query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Sep 2013 09:17:58 -0000 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();