Date: Wed, 24 Jul 2013 09:35:44 GMT From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255100 - in soc2013/mattbw/tests: . get-details-output search-files-output Message-ID: <201307240935.r6O9Zi6R049597@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 +
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307240935.r6O9Zi6R049597>