socsvn commit: r257117 - soc2013/mattbw/backend

mattbw at FreeBSD.org mattbw at FreeBSD.org
Sun Sep 8 11:30:15 UTC 2013


Author: mattbw
Date: Sun Sep  8 11:30:14 2013
New Revision: 257117
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257117

Log:
  Add new unit tests for pkgutils_pkg_matches_filters.
  
  These currently fail; will investigate now.
  

Modified:
  soc2013/mattbw/backend/pkgutils_test.c

Modified: soc2013/mattbw/backend/pkgutils_test.c
==============================================================================
--- soc2013/mattbw/backend/pkgutils_test.c	Sun Sep  8 11:20:44 2013	(r257116)
+++ soc2013/mattbw/backend/pkgutils_test.c	Sun Sep  8 11:30:14 2013	(r257117)
@@ -178,6 +178,84 @@
 	pkg_free(package);
 }
 
+ATF_TC(pkg_matches_filters_installed);
+ATF_TC_HEAD(pkg_matches_filters_installed, tc)
+{
+
+	atf_tc_set_md_var(tc, "descr",
+	    "Test 'pkgutils_pkg_matches_filters' for the installed filter.");
+}
+ATF_TC_BODY(pkg_matches_filters_installed, tc)
+{
+	struct pkg     *local;
+	struct pkg     *remote;
+	PkBitfield	filter;
+
+	filter = pk_bitfield_from_enums(PK_FILTER_ENUM_INSTALLED);
+
+	/* Locally installed -> accept */
+	local = gen_pkg(PKG_INSTALLED);
+	ATF_REQUIRE(local != NULL);
+	ATF_CHECK(pkgutils_pkg_matches_filters(local, filter));
+	pkg_free(local);
+
+	remote = gen_pkg(PKG_REMOTE);
+	ATF_REQUIRE(remote != NULL);
+
+	/* Old version newer -> reject */
+	pkg_set(remote, PKG_OLD_VERSION, "1.2.3");
+	ATF_CHECK(!pkgutils_pkg_matches_filters(remote, filter));
+
+	/* Old version the same -> accept */
+	pkg_set(remote, PKG_OLD_VERSION, "1.1.4");
+	ATF_CHECK(pkgutils_pkg_matches_filters(remote, filter));
+
+	/* Old version older -> reject */
+	pkg_set(remote, PKG_OLD_VERSION, "1.0.0");
+	ATF_CHECK(!pkgutils_pkg_matches_filters(remote, filter));
+
+	pkg_free(remote);
+}
+
+ATF_TC(pkg_matches_filters_not_installed);
+ATF_TC_HEAD(pkg_matches_filters_not_installed, tc)
+{
+
+	atf_tc_set_md_var(tc, "descr",
+	    "Test 'pkgutils_pkg_matches_filters' for the ~installed filter.");
+}
+ATF_TC_BODY(pkg_matches_filters_not_installed, tc)
+{
+	struct pkg     *local;
+	struct pkg     *remote;
+	PkBitfield	filter;
+
+	filter = pk_bitfield_from_enums(PK_FILTER_ENUM_NOT_INSTALLED);
+
+	/* Locally installed -> reject */
+	local = gen_pkg(PKG_INSTALLED);
+	ATF_REQUIRE(local != NULL);
+	ATF_CHECK(!pkgutils_pkg_matches_filters(local, filter));
+	pkg_free(local);
+
+	remote = gen_pkg(PKG_REMOTE);
+	ATF_REQUIRE(remote != NULL);
+
+	/* Old version newer -> reject */
+	pkg_set(remote, PKG_OLD_VERSION, "1.2.3");
+	ATF_CHECK(pkgutils_pkg_matches_filters(remote, filter));
+
+	/* Old version the same -> accept */
+	pkg_set(remote, PKG_OLD_VERSION, "1.1.4");
+	ATF_CHECK(!pkgutils_pkg_matches_filters(remote, filter));
+
+	/* Old version older -> reject */
+	pkg_set(remote, PKG_OLD_VERSION, "1.0.0");
+	ATF_CHECK(pkgutils_pkg_matches_filters(remote, filter));
+
+	pkg_free(remote);
+}
+
 /*
  * TEST PACK
  */
@@ -190,6 +268,8 @@
 	ATF_TP_ADD_TC(tp, pkg_install_state);
 	ATF_TP_ADD_TC(tp, pkg_current_state_local);
 	ATF_TP_ADD_TC(tp, pkg_current_state_remote);
+	ATF_TP_ADD_TC(tp, pkg_matches_filters_installed);
+	ATF_TP_ADD_TC(tp, pkg_matches_filters_not_installed);
 
 	return atf_no_error();
 }


More information about the svn-soc-all mailing list