From owner-svn-soc-all@FreeBSD.ORG Fri Jul 5 01:11:57 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]) by hub.freebsd.org (Postfix) with ESMTP id 6CD03B20 for ; Fri, 5 Jul 2013 01:11:57 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 4DF8E181A for ; Fri, 5 Jul 2013 01:11:57 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r651Bubx059215 for ; Fri, 5 Jul 2013 01:11:56 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r651Butf059212 for svn-soc-all@FreeBSD.org; Fri, 5 Jul 2013 01:11:56 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 5 Jul 2013 01:11:56 GMT Message-Id: <201307050111.r651Butf059212@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: r254078 - soc2013/mattbw/tests/get-details-output 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: Fri, 05 Jul 2013 01:11:57 -0000 Author: mattbw Date: Fri Jul 5 01:11:56 2013 New Revision: 254078 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254078 Log: clean up test a bit, add multiple package runner Added: soc2013/mattbw/tests/get-details-output/test-pkg.sh - copied unchanged from r254077, soc2013/mattbw/tests/get-details-output/test-output.sh soc2013/mattbw/tests/get-details-output/test.sh (contents, props changed) Deleted: soc2013/mattbw/tests/get-details-output/test-output.sh Copied: soc2013/mattbw/tests/get-details-output/test-pkg.sh (from r254077, soc2013/mattbw/tests/get-details-output/test-output.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/get-details-output/test-pkg.sh Fri Jul 5 01:11:56 2013 (r254078, copy of r254077, soc2013/mattbw/tests/get-details-output/test-output.sh) @@ -0,0 +1,59 @@ +#!/bin/sh + +# Tests pkcon against pkg to make sure the pkg backend works correctly for GetDetails. +# +# More black-box tests should be written later + +if [ $# -eq 1 ] +then + PACKAGE="$1" +else + PACKAGE="pkg" +fi + +echo "using package ${PACKAGE}" + +# Get the expected ABI through some invasive inspection of the pkg config dump +ARCH="`pkg -vv | grep ABI | sed 's/ *ABI: *//'`" + +CMD_GETCAT="./getcat" + +# Get the PackageKit group of the package +ORIGIN="`pkg query \"%o\" ${PACKAGE}`" +GROUP="`${CMD_GETCAT} ${ORIGIN}`" + +# Get the licences by mashing the `pkg query` licence list and or/and/single identifier +# into one "licence or licence or licence" string. +LICENSE=`\ + pkg query "%L %l" "${PACKAGE}" | # "licence or\nlicence or\n" + tr "\n" " " | # "licence or licence or ", note space + sed 's/ *[^ ]* *$//'` # "licence or licence" + +# Build a format string for the query that mocks up a pkcon GetDetails result +FMT="Package description + package: %n-%v.${ARCH} + license: ${LICENSE} + group: ${GROUP} + description: %e + size: %sb bytes + url: %w" + +# Now run both queries and diff them +PKG_FILE="${PACKAGE}-pkg" +PKCON_FILE="${PACKAGE}-pkcon" + +pkg query "${FMT}" "${PACKAGE}" > "${PKG_FILE}" +pkcon get-details "${PACKAGE};;;installed" | awk -f "strip_messages.awk" > "${PKCON_FILE}" + +DIFF="`diff -rupN \"${PACKAGE}-pkg\" \"${PACKAGE}-pkcon\"`" +if [ -n "${DIFF}" ] +then + echo "test failed with diff:" + echo "${DIFF}" + RETURN=1 +else + echo "test succeeded" + RETURN=0 +fi + +return $RETURN Added: soc2013/mattbw/tests/get-details-output/test.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/get-details-output/test.sh Fri Jul 5 01:11:56 2013 (r254078) @@ -0,0 +1,13 @@ +#!/bin/sh + +# Main test runner for the GetDetails output test. + +while read LINE +do + ./test-pkg.sh "${LINE}" + if [ $? -ne 0 ] + then + echo "tests failed" + exit 1 + fi +done < "test-pkgs"