From owner-svn-soc-all@FreeBSD.ORG Wed Jul 24 09:35:45 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id F0B934B6 for ; Wed, 24 Jul 2013 09:35:44 +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 E0ECB2566 for ; Wed, 24 Jul 2013 09:35:44 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6O9ZiJ8049612 for ; Wed, 24 Jul 2013 09:35:44 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6O9Zi6R049597 for svn-soc-all@FreeBSD.org; Wed, 24 Jul 2013 09:35:44 GMT (envelope-from mattbw@FreeBSD.org) Date: Wed, 24 Jul 2013 09:35:44 GMT Message-Id: <201307240935.r6O9Zi6R049597@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: r255100 - in soc2013/mattbw/tests: . get-details-output search-files-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: Wed, 24 Jul 2013 09:35:45 -0000 Author: mattbw Date: Wed Jul 24 09:35:44 2013 New Revision: 255100 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255100 Log: add basic test for SearchFile Added: soc2013/mattbw/tests/search-files-output/ soc2013/mattbw/tests/search-files-output/test-file.sh (contents, props changed) soc2013/mattbw/tests/strip_messages.awk - copied unchanged from r254741, soc2013/mattbw/tests/get-details-output/strip_messages.awk soc2013/mattbw/tests/test-diff.sh (contents, props changed) Deleted: soc2013/mattbw/tests/get-details-output/strip_messages.awk Modified: soc2013/mattbw/tests/get-details-output/test-pkg.sh Modified: soc2013/mattbw/tests/get-details-output/test-pkg.sh ============================================================================== --- soc2013/mattbw/tests/get-details-output/test-pkg.sh Wed Jul 24 09:12:46 2013 (r255099) +++ soc2013/mattbw/tests/get-details-output/test-pkg.sh Wed Jul 24 09:35:44 2013 (r255100) @@ -134,20 +134,7 @@ eval ${PKGCMD} \""${FMT}"\" > "${PKG_FILE}" ${CMD_PKCON} get-details "${PK_ID}" | - awk -f "strip_messages.awk" > "${PKCON_FILE}" + awk -f "../strip_messages.awk" > "${PKCON_FILE}" -################################################################################ -# Diff the results. - -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 +../test-diff.sh "${PACKAGE}-pkg" "${PACKAGE}-pkcon" +return $? Added: soc2013/mattbw/tests/search-files-output/test-file.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/search-files-output/test-file.sh Wed Jul 24 09:35:44 2013 (r255100) @@ -0,0 +1,22 @@ +#!/bin/sh + +################################################################################ +# Test the output of `pkcon search file` to see if it agrees with `pkg which.` +# Expects one argument, the file which shall be passed to both. + +# Output files +PKG_OUT=out.pkg +PKCON_OUT=out.pkcon + +# Get the expected ABI through some invasive inspection of the pkg config dump +ARCH="`pkg -vv | grep ABI | sed 's/ *ABI: *//'`" + +echo "Looking for provider of $1..." +pkg which -q "$1" | + sed "s/^/Installed /; s/$/.${ARCH}/" > ${PKG_OUT} + +pkcon search file "$1" | + awk -f "../strip_messages.awk" > ${PKCON_OUT} + +../test-diff.sh ${PKG_OUT} ${PKCON_OUT} +return $? Copied: soc2013/mattbw/tests/strip_messages.awk (from r254741, soc2013/mattbw/tests/get-details-output/strip_messages.awk) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/strip_messages.awk Wed Jul 24 09:35:44 2013 (r255100, copy of r254741, soc2013/mattbw/tests/get-details-output/strip_messages.awk) @@ -0,0 +1,4 @@ +# Strips in-band auxiliary messages from a `pkcon` run, leaving only the results +BEGIN { in_description=0 } +!/Message:.*/ && in_description { print } +/Results:/ { in_description=1 } Added: soc2013/mattbw/tests/test-diff.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/tests/test-diff.sh Wed Jul 24 09:35:44 2013 (r255100) @@ -0,0 +1,21 @@ +#!/bin/sh +# +# Performs a diff between two files that represent the PkgNG and PackageKit +# outputs after performing analogous commands, modified to follow the format +# of one or the other. The two files should be identical for the test to +# succeed; if it fails then usually the PackageKit backend is reporting +# incorrect data. +# +# Usage: test-diff.sh pkg-file pkcon-file + +DIFF="`diff -rupN \"$1\" \"$2\"`" +if [ -n "${DIFF}" ] +then + echo "test failed with diff:" + echo "${DIFF}" + RETURN=1 +else + echo "test succeeded" + RETURN=0 +fi +