From owner-svn-soc-all@FreeBSD.ORG Mon Sep 2 09:14:04 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 66211AC9 for ; Mon, 2 Sep 2013 09:14:04 +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 456532AD2 for ; Mon, 2 Sep 2013 09:14:04 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r829E4CP006978 for ; Mon, 2 Sep 2013 09:14:04 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r829E4ts006961 for svn-soc-all@FreeBSD.org; Mon, 2 Sep 2013 09:14:04 GMT (envelope-from mattbw@FreeBSD.org) Date: Mon, 2 Sep 2013 09:14:04 GMT Message-Id: <201309020914.r829E4ts006961@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: r256828 - soc2013/mattbw/backend 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:14:04 -0000 Author: mattbw Date: Mon Sep 2 09:14:03 2013 New Revision: 256828 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256828 Log: Factor out gen_pkg in tests. This now lies in a new file, "testutils.c", so it can be shared amongst all unit tests. Added: soc2013/mattbw/backend/testutils.c soc2013/mattbw/backend/testutils.h Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/namever.h soc2013/mattbw/backend/namever_test.c soc2013/mattbw/backend/pkgutils_test.c Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Mon Sep 2 08:51:50 2013 (r256827) +++ soc2013/mattbw/backend/Makefile Mon Sep 2 09:14:03 2013 (r256828) @@ -101,28 +101,31 @@ tests: ${TESTPROGS} # TODO: Find a more BSD way of doing this -query/id_test: query/id_test.o query/id.o namever.o +query/id_test: query/id_test.o query/id.o namever.o testutils.o ${CC} ${LDFLAGS} ${TESTLDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBS} ${TESTLIBS} 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 +query/check_test: query/check_test.o query/check.o query/id.o query/packages.o query/find.o namever.o testutils.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 +pkgutils_test: pkgutils_test.o pkgutils.o namever.o testutils.o ${CC} ${LDFLAGS} ${TESTLDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBS} ${TESTLIBS} pkgutils_test.o: pkgutils_test.c ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} -namever_test: namever_test.o namever.o +namever_test: namever_test.o namever.o testutils.o ${CC} ${LDFLAGS} ${TESTLDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LIBS} ${TESTLIBS} namever_test.o: namever_test.c ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} +testutils.o: testutils.c + ${CC} ${CFLAGS} ${TESTCFLAGS} -o ${.TARGET} -c ${.ALLSRC} + .include Modified: soc2013/mattbw/backend/namever.h ============================================================================== --- soc2013/mattbw/backend/namever.h Mon Sep 2 08:51:50 2013 (r256827) +++ soc2013/mattbw/backend/namever.h Mon Sep 2 09:14:03 2013 (r256828) @@ -29,4 +29,5 @@ char *namever_from_package_id(const gchar *package_id); char **namever_array_from_package_ids(gchar **package_ids, guint count); void namever_array_free(char ***namevers_p, guint count); + #endif /* !_PKGNG_BACKEND_NAMEVER_H_ */ Modified: soc2013/mattbw/backend/namever_test.c ============================================================================== --- soc2013/mattbw/backend/namever_test.c Mon Sep 2 08:51:50 2013 (r256827) +++ soc2013/mattbw/backend/namever_test.c Mon Sep 2 09:14:03 2013 (r256828) @@ -22,31 +22,10 @@ #include /* gchar, g_free */ #include "namever.h" /* pkgutils_... */ +#include "testutils.h" /* gen_pkg */ /* ATF/kyua tests for 'pkgutils.c'. */ -static struct pkg *gen_pkg(pkg_t type); - -static struct pkg * -gen_pkg(pkg_t type) -{ - struct pkg *pkg; - int pkg_new_result; - - pkg = NULL; - pkg_new_result = pkg_new(&pkg, type); - - 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(test_namever_from_name_and_version); ATF_TC_HEAD(test_namever_from_name_and_version, tc) { Modified: soc2013/mattbw/backend/pkgutils_test.c ============================================================================== --- soc2013/mattbw/backend/pkgutils_test.c Mon Sep 2 08:51:50 2013 (r256827) +++ soc2013/mattbw/backend/pkgutils_test.c Mon Sep 2 09:14:03 2013 (r256828) @@ -23,31 +23,10 @@ #include "pkg.h" /* pkg... */ #include "pkgutils.h" /* pkgutils_... */ +#include "testutils.h" /* gen_pkg */ /* ATF/kyua tests for 'pkgutils.c'. */ -static struct pkg *gen_pkg(pkg_t type); - -static struct pkg * -gen_pkg(pkg_t type) -{ - struct pkg *pkg; - int pkg_new_result; - - pkg = NULL; - pkg_new_result = pkg_new(&pkg, type); - - 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(pkg_to_id_valid_local); ATF_TC_HEAD(pkg_to_id_valid_local, tc) { Added: soc2013/mattbw/backend/testutils.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/testutils.c Mon Sep 2 09:14:03 2013 (r256828) @@ -0,0 +1,50 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * 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 +#include "pkg.h" /* pkg... */ + +#include "testutils.h" /* Prototypes */ + +/* + * Utility functions for unit tests. These shouldn't be used for anything + * else. + */ + +struct pkg * +gen_pkg(pkg_t type) +{ + struct pkg *pkg; + int pkg_new_result; + + pkg = NULL; + pkg_new_result = pkg_new(&pkg, type); + + 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; +} + Added: soc2013/mattbw/backend/testutils.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/testutils.h Mon Sep 2 09:14:03 2013 (r256828) @@ -0,0 +1,28 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * 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. + */ + +#ifndef _PKGNG_BACKEND_TESTUTILS_H_ +#define _PKGNG_BACKEND_TESTUTILS_H_ + +#include "pkg.h" /* struct pkg */ + +struct pkg *gen_pkg(pkg_t type); + +#endif /* !_PKGNG_BACKEND_TESTUTILS_H_ */