socsvn commit: r257008 - in soc2013/mattbw/backend: . query

mattbw at FreeBSD.org mattbw at FreeBSD.org
Fri Sep 6 12:44:14 UTC 2013


Author: mattbw
Date: Fri Sep  6 12:44:13 2013
New Revision: 257008
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257008

Log:
  Add tests for repo_of_package.
  
  This also fixes some broken references to legacy repo functions.
  

Added:
  soc2013/mattbw/backend/repo_test.c
Modified:
  soc2013/mattbw/backend/Atffile
  soc2013/mattbw/backend/Makefile
  soc2013/mattbw/backend/pkgutils.c
  soc2013/mattbw/backend/query/check.c

Modified: soc2013/mattbw/backend/Atffile
==============================================================================
--- soc2013/mattbw/backend/Atffile	Fri Sep  6 12:08:31 2013	(r257007)
+++ soc2013/mattbw/backend/Atffile	Fri Sep  6 12:44:13 2013	(r257008)
@@ -4,3 +4,4 @@
 
 tp: namever_test
 tp: pkgutils_test
+tp: repo_test

Modified: soc2013/mattbw/backend/Makefile
==============================================================================
--- soc2013/mattbw/backend/Makefile	Fri Sep  6 12:08:31 2013	(r257007)
+++ soc2013/mattbw/backend/Makefile	Fri Sep  6 12:44:13 2013	(r257008)
@@ -74,6 +74,7 @@
 TESTPROGS=					\
 		namever_test			\
 		pkgutils_test			\
+		repo_test			\
 		query/id_test			\
 		query/check_test		\
 
@@ -108,16 +109,16 @@
 query/id_test.o: query/id_test.c
 	${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC}
 
-query/check_test: query/check_test.o query/check.o query/id.o query/packages.o query/find.o namever.o testutils.o pkgutils.o
+query/check_test: query/check_test.o query/check.o query/id.o query/packages.o query/find.o namever.o testutils.o pkgutils.o repo.o
 	${CC} ${LDFLAGS} ${TESTLDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBS} ${TESTLIBS}
 
 query/check_test.o: query/check_test.c
 	${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC}
 
-pkgutils_test: pkgutils_test.o pkgutils.o namever.o testutils.o
+pkgutils_test: pkgutils_test.o pkgutils.o namever.o testutils.o repo.o
 	${CC} ${LDFLAGS} ${TESTLDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBS} ${TESTLIBS}
 
-pkgutils_test.o: pkgutils_test.c
+pkgutils_test.o: pkgutils_test.c repo.o
 	${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC}
 
 namever_test: namever_test.o namever.o testutils.o
@@ -126,6 +127,12 @@
 namever_test.o: namever_test.c
 	${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC}
 
+repo_test: repo_test.o repo.o testutils.o
+	${CC} ${LDFLAGS} ${TESTLDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBS} ${TESTLIBS}
+
+repo_test.o: repo_test.c
+	${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC}
+
 testutils.o: testutils.c
 	${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC}
 

Modified: soc2013/mattbw/backend/pkgutils.c
==============================================================================
--- soc2013/mattbw/backend/pkgutils.c	Fri Sep  6 12:08:31 2013	(r257007)
+++ soc2013/mattbw/backend/pkgutils.c	Fri Sep  6 12:44:13 2013	(r257008)
@@ -26,6 +26,7 @@
 
 #include "namever.h"		/* namever_... */
 #include "pkgutils.h"		/* Prototypes */
+#include "repo.h"		/* repo_... */
 #include "utils.h"		/* INTENTIONALLY_IGNORE */
 
 /*
@@ -126,7 +127,7 @@
 
 	pkg_get(pkg, PKG_NAME, &name, PKG_VERSION, &version, PKG_ARCH, &arch);
 
-	repo = pkgutils_pkg_to_pk_repo(pkg);
+	repo = repo_of_package(pkg);
 
 	return pk_package_id_build(name, version, arch, repo);
 }

Modified: soc2013/mattbw/backend/query/check.c
==============================================================================
--- soc2013/mattbw/backend/query/check.c	Fri Sep  6 12:08:31 2013	(r257007)
+++ soc2013/mattbw/backend/query/check.c	Fri Sep  6 12:44:13 2013	(r257008)
@@ -25,6 +25,7 @@
 
 #include "../namever.h"		/* namever_... */
 #include "../pkgutils.h"	/* pkgutils_... */
+#include "../repo.h"		/* repo_... */
 #include "../utils.h"		/* type_of_repo_name, enum repo_type */
 #include "check.h"		/* query_check... */
 #include "find.h"		/* query_find_... */
@@ -50,7 +51,7 @@
 	assert(query_id->namever != NULL);
 
 	namever = namever_from_package(package);
-	repo = pkgutils_pkg_to_pk_repo(package);
+	repo = repo_of_package(package);
 	(void)pkg_get(package, PKG_ARCH, &arch, PKG_NAME, &name);
 
 	/* Be cautious and reject matches if the package fields aren't here. */

Added: soc2013/mattbw/backend/repo_test.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2013/mattbw/backend/repo_test.c	Fri Sep  6 12:44:13 2013	(r257008)
@@ -0,0 +1,98 @@
+/*-
+ * Copyright (C) 2013 Matt Windsor <mattbw at FreeBSD.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#include <atf-c.h>
+#include <string.h>		/* ATF_CHECK_STREQ */
+#include <glib.h>		/* gchar, g_free */
+#include "pkg.h"		/* pkg... */
+
+#include "repo.h"		/* repo_... */
+#include "testutils.h"		/* gen_pkg */
+
+/* ATF/kyua tests for 'repo.c'. */
+
+ATF_TC(repo_of_package_valid_local);
+ATF_TC_HEAD(repo_of_package_valid_local, tc)
+{
+
+	atf_tc_set_md_var(tc, "descr",
+	    "Test 'repo_of_package' on a local (file) package.");
+}
+ATF_TC_BODY(repo_of_package_valid_local, tc)
+{
+	struct pkg     *pkg;
+
+	pkg = gen_pkg(PKG_FILE);
+	ATF_REQUIRE(pkg != NULL);
+
+	ATF_CHECK_STREQ(repo_of_package(pkg), "local");
+
+	pkg_free(pkg);
+}
+
+ATF_TC(repo_of_package_valid_installed);
+ATF_TC_HEAD(repo_of_package_valid_installed, tc)
+{
+
+	atf_tc_set_md_var(tc, "descr",
+	    "Test 'repo_of_package' on an installed package.");
+}
+ATF_TC_BODY(repo_of_package_valid_installed, tc)
+{
+	struct pkg     *pkg;
+
+	pkg = gen_pkg(PKG_INSTALLED);
+	ATF_REQUIRE(pkg != NULL);
+
+	ATF_CHECK_STREQ(repo_of_package(pkg), "installed");
+
+	pkg_free(pkg);
+}
+
+ATF_TC(repo_of_package_valid_remote);
+ATF_TC_HEAD(repo_of_package_valid_remote, tc)
+{
+
+	atf_tc_set_md_var(tc, "descr",
+	    "Test 'repo_of_package' on a remote package.");
+}
+ATF_TC_BODY(repo_of_package_valid_remote, tc)
+{
+	struct pkg     *pkg;
+
+	pkg = gen_pkg(PKG_REMOTE);
+	ATF_REQUIRE(pkg != NULL);
+
+	ATF_CHECK_STREQ(repo_of_package(pkg), "packagesite");
+
+	pkg_free(pkg);
+}
+
+/*
+ * TEST PACK
+ */
+
+ATF_TP_ADD_TCS(tp)
+{
+	ATF_TP_ADD_TC(tp, repo_of_package_valid_local);
+	ATF_TP_ADD_TC(tp, repo_of_package_valid_installed);
+	ATF_TP_ADD_TC(tp, repo_of_package_valid_remote);
+
+	return atf_no_error();
+}


More information about the svn-soc-all mailing list