Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Jul 2013 01:06:44 GMT
From:      mattbw@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r254392 - in soc2013/mattbw/tests: all-ports-dirs-mapped get-details-output
Message-ID:  <201307080106.r6816iZM016650@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mattbw
Date: Mon Jul  8 01:06:44 2013
New Revision: 254392
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254392

Log:
  add new test, remove getcat and slightly mod getdetails test

Added:
  soc2013/mattbw/tests/all-ports-dirs-mapped/
  soc2013/mattbw/tests/all-ports-dirs-mapped/test.sh   (contents, props changed)
  soc2013/mattbw/tests/get-details-output/test-pkgs
Deleted:
  soc2013/mattbw/tests/get-details-output/Makefile
  soc2013/mattbw/tests/get-details-output/getcat.1
  soc2013/mattbw/tests/get-details-output/getcat.c
Modified:
  soc2013/mattbw/tests/get-details-output/test-pkg.sh

Added: soc2013/mattbw/tests/all-ports-dirs-mapped/test.sh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2013/mattbw/tests/all-ports-dirs-mapped/test.sh	Mon Jul  8 01:06:44 2013	(r254392)
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+################################################################################
+# Tests to make sure all ports directories have a corresponding PackageKit
+# category mapped, using getcat.
+#
+# Usage: ./test
+#     (You may need to make/install any programs listed below)
+
+################################################################################
+# Programs used in this test (relative paths will require make-ing, names
+# imply external program installation).
+
+CMD_GETCAT_DIR=../../backend/bin/getcat/
+CMD_GETCAT="${CMD_GETCAT_DIR}pkgpk-getcat"
+
+( cd "${CMD_GETCAT_DIR}"; make )
+if [ $? -ne 0 ]
+then
+	echo "couldn't make getcat"
+	exit 2
+fi
+
+# Quick and dirty way of getting all ports directories with the / required for
+# getcat to work; assume all required ports directories are lowercase and all
+# other directories have at least one uppercase character.
+PORTS_DIRS=`ls -1F /usr/ports | grep '/$' | grep -v ".*[A-Z].*"`
+
+# Test to make sure getcat retrieves "unknown" for silly ports dirs
+GROUP=`${CMD_GETCAT} wombatwombatwombat`
+if [ "${GROUP}" != "unknown" ]
+then
+	echo "test failed, did not return unknown for bad ports dir"
+	exit 1
+fi
+
+for DIR in ${PORTS_DIRS}
+do
+	GROUP=`${CMD_GETCAT} ${DIR}`
+	if [ -n "${GROUP}" ] && [ "${GROUP}" != "unknown" ]
+	then
+		echo "${DIR} -> ${GROUP}"
+	else
+		echo "test failed on ${DIR}"
+		exit 1
+	fi
+done

Modified: soc2013/mattbw/tests/get-details-output/test-pkg.sh
==============================================================================
--- soc2013/mattbw/tests/get-details-output/test-pkg.sh	Mon Jul  8 01:05:22 2013	(r254391)
+++ soc2013/mattbw/tests/get-details-output/test-pkg.sh	Mon Jul  8 01:06:44 2013	(r254392)
@@ -8,10 +8,28 @@
 #
 # Usage: ./test-pkg [PACKAGE] [PK_REPO]
 #     or ./test.sh (runs this over a set of packages)
+#     (You may need to make/install any programs listed below)
 #
 # TODO: Specific version/arch requirements in the PackageID
 
 ################################################################################
+# Programs used in this test (relative paths will require make-ing, names
+# imply external program installation).
+CMD_PKG=pkg
+CMD_PKCON=pkcon
+
+CMD_GETCAT_DIR=../../backend/bin/getcat/
+CMD_GETCAT="${CMD_GETCAT_DIR}pkgpk-getcat"
+
+( cd "${CMD_GETCAT_DIR}"; make )
+if [ $? -ne 0 ]
+then
+	echo "couldn't make getcat"
+	exit 2
+fi
+
+
+################################################################################
 # Retrieve the arguments.
 
 if [ $# -gt 0 ]
@@ -53,12 +71,12 @@
 if [ ${TRY_LOCAL} -gt 0 ]
 then
 	# Does the package exist locally?
-	TEST=`eval pkg query ${ECOND} \"%n\"`
+	TEST=`eval ${CMD_PKG} query ${ECOND} \"%n\"`
 	if [ -n "${TEST}" ]
 	then
 		FOUND=1
 		TRY_REMOTE=0
-		QTYPE="pkg query"
+		QTYPE="${CMD_PKG} query"
 	fi
 fi
 if [ ${TRY_REMOTE} -gt 0 ]
@@ -68,7 +86,7 @@
 	if [ -n "${TEST}" ]
 	then
 		FOUND=1
-		QTYPE="pkg rquery ${REPO}"
+		QTYPE="${CMD_PKG} rquery ${REPO}"
 	fi
 fi
 PKGCMD="${QTYPE} ${ECOND}"
@@ -78,7 +96,7 @@
 PK_ID="${PACKAGE};;;${PK_REPO}"
 echo "testing with package ${PACKAGE}"
 echo "  pkg invocation:   ${PKGCMD} ..."
-echo "  pkcon invocation: pkcon get-details ${PK_ID}"
+echo "  pkcon invocation: ${CMD_PKCON} get-details ${PK_ID}"
 
 ################################################################################
 # Infer data not available from a query string but used in PackageKit.
@@ -86,8 +104,6 @@
 # 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="`eval ${PKGCMD} \"%o\"`"
 GROUP="`${CMD_GETCAT} ${ORIGIN}`"
@@ -117,7 +133,8 @@
 PKCON_FILE="${PACKAGE}-pkcon"
 
 eval ${PKGCMD} \""${FMT}"\" > "${PKG_FILE}"
-pkcon get-details "${PK_ID}" | awk -f "strip_messages.awk" > "${PKCON_FILE}"
+${CMD_PKCON} get-details "${PK_ID}" |
+	awk -f "strip_messages.awk" > "${PKCON_FILE}"
 
 ################################################################################
 # Diff the results.

Added: soc2013/mattbw/tests/get-details-output/test-pkgs
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2013/mattbw/tests/get-details-output/test-pkgs	Mon Jul  8 01:06:44 2013	(r254392)
@@ -0,0 +1,11 @@
+pkg
+pkg installed
+pkg packagesite
+wine
+wine installed
+wine packagesite
+asciidoc
+asciidoc installed
+asciidoc packagesite
+gnu-unifont
+gnu-unifont packagesite



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307080106.r6816iZM016650>