socsvn commit: r254078 - soc2013/mattbw/tests/get-details-output

mattbw at FreeBSD.org mattbw at FreeBSD.org
Fri Jul 5 01:11:57 UTC 2013


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"


More information about the svn-soc-all mailing list