[csw-devel] SF.net SVN: gar:[9154] csw/mgar/gar/v2

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Mar 14 11:14:39 CET 2010


Revision: 9154
          http://gar.svn.sourceforge.net/gar/?rev=9154&view=rev
Author:   wahwah
Date:     2010-03-14 10:14:39 +0000 (Sun, 14 Mar 2010)

Log Message:
-----------
mGAR v2: checkpkg, removed one per-package pkgtrans, reduced the default screen output.

Modified Paths:
--------------
    csw/mgar/gar/v2/bin/analyze_module_results.py
    csw/mgar/gar/v2/bin/checkpkg
    csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py
    csw/mgar/gar/v2/lib/python/checkpkg.py
    csw/mgar/gar/v2/lib/python/package_checks.py
    csw/mgar/gar/v2/lib/python/package_checks_old.py
    csw/mgar/gar/v2/lib/python/package_checks_old_test.py
    csw/mgar/gar/v2/lib/python/package_checks_test.py

Modified: csw/mgar/gar/v2/bin/analyze_module_results.py
===================================================================
--- csw/mgar/gar/v2/bin/analyze_module_results.py	2010-03-14 05:34:29 UTC (rev 9153)
+++ csw/mgar/gar/v2/bin/analyze_module_results.py	2010-03-14 10:14:39 UTC (rev 9154)
@@ -16,13 +16,13 @@
 def main():
   parser = optparse.OptionParser()
   parser.add_option("-e", "--extract-dir", dest="extractdir",
-                    help="Directory with extracted packages")
+                    help="Directory with extracted packages "
+                         "(with error tag files)")
   options, args = parser.parse_args()
-  pkgnames = args
-  packages = [opencsw.DirectoryFormatPackage(
-                  os.path.join(options.extractdir, pkgname))
-              for pkgname in pkgnames]
-  overrides_list = [pkg.GetOverrides() for pkg in packages]
+  filenames = args
+  srv4_pkgs = [opencsw.CswSrv4File(x) for x in filenames]
+  pkgstats = [checkpkg.PackageStats(x) for x in srv4_pkgs]
+  overrides_list = [pkg.GetSavedOverrides() for pkg in pkgstats]
   files = os.listdir(options.extractdir)
   error_tags = []
   for file_name in files:

Modified: csw/mgar/gar/v2/bin/checkpkg
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg	2010-03-14 05:34:29 UTC (rev 9153)
+++ csw/mgar/gar/v2/bin/checkpkg	2010-03-14 10:14:39 UTC (rev 9154)
@@ -152,57 +152,54 @@
 	exit 1
 fi
 
+printf "Examining pkginfo files: "
+
 for f in "$@"
 do
 
-
-
 if [[ ! -f $f ]] ; then
 	print ERROR: $f does not exist
 	exit 1
 fi
 
 
-case $f in
-	*)
-	print Examining $f
+debugmsg "Examining $f"
+debugmsg "Looking for bad strings..."
 
-	print Looking for bad strings...
+# XPG4 grep has some kind of magical "ignore ELF header" power.
+#  but... not on sol8, just sol10?
+# and so does /bin/grep. but NOT /bin/egrep???
+#
+# Need to rewrite this whole thing to also
+# check for badly set RUNPATHs. sigh.
+#
+# Using rot13 so that checkpkg can check itself without reporting
+# an error.
+badpaths="$(echo /rkcbeg/zrqhfn /bcg/ohvyq | gtr a-mn-z n-za-m)"
+for badpath in $badpaths ; do
+  GREP=/bin/grep gzgrep "$badpath" $f
+  if [[ $? -eq 0 ]] ; then
+    print ""
+    print "ERROR: build-machine paths found in file $f"
+    print "($badpath)"
+    exit 1
+  fi
+done
 
-	# XPG4 grep has some kind of magical "ignore ELF header" power.
-	#  but... not on sol8, just sol10?
-	# and so does /bin/grep. but NOT /bin/egrep???
-	#
-	# Need to rewrite this whole thing to also
-	# check for badly set RUNPATHs. sigh.
-	#
-	# Using rot13 so that checkpkg can check itself without reporting
-	# an error.
-	badpaths="$(echo /rkcbeg/zrqhfn /bcg/ohvyq | gtr a-mn-z n-za-m)"
-	for badpath in $badpaths ; do
-		GREP=/bin/grep gzgrep "$badpath" $f
-		if [[ $? -eq 0 ]] ; then
-			print ""
-			print ERROR: build-machine paths found in file $f
-			print '($badpath)'
-			exit 1
-		fi
-	done
-esac
-
-print Extracting all files for more detailed inspection...
-
 set_variables_for_individual_package_check "$f"
 
-mkdir $EXTRACTDIR
+[ -d ${EXTRACTDIR} ] || mkdir ${EXTRACTDIR}
 
 # FIXME: This doesn't support multiple packages
 TMPFILE=$EXTRACTDIR/pkginfo
 
 
-dd if=$f skip=1 | (cd $EXTRACTDIR; cpio -ivd $pkgname/pkginfo)
+printf "$pkgname "
+dd if=$f skip=1 | (cd $EXTRACTDIR; cpio -ivd $pkgname/pkginfo >/dev/null 2>&1)
 if [[ $? -ne 0 ]] ; then
-	print ERROR: could not extract $f
+	print "ERROR: could not extract $f"
+	print "with (cd $EXTRACTDIR; cpio -ivd $pkgname/pkginfo)"
+	ls -l $EXTRACTDIR
 	rm -rf $EXTRACTDIR $TMPARCHIVE
 	exit 1
 fi
@@ -223,131 +220,44 @@
 # strip out '' chars, because it interferes with mysql
 desc=`print $desc | sed "s/'//g"`
 
-
-goodarch=yes
-case $f in
-	*${LOCAL_ARCH}*)
-		
-	;;
-	*)
-		print NOTE: pkg must be for arch $LOCAL_ARCH to check dynamic libs
-		goodarch=no		
-	;;
-esac
-
-
-#if [ "$goodarch" = "no" ] ; then
-#	# neutral architechture. cant check libraries for it.
-#	print ""
-#	rm -rf $EXTRACTDIR $TMPARCHIVE
-#	exit 0
-#fi
-
-print ""
-print Extracing pkg for examination of files...
-custom_pkgtrans $f $EXTRACTDIR $pkgname
-
 #############################################################
 # We now have the package expanded, in "directory" form, in
 # $EXTRACTDIR/$pkgname
 # Now do some extended error checking on it.
 # This is similar to Debians "Lintian" phase for packages.
 
-/usr/sbin/pkgchk -d $EXTRACTDIR $pkgname || errmsg "Package failed integrity check"
+# TODO: Run this during the stats collection stage.
+# /usr/sbin/pkgchk -d $EXTRACTDIR $pkgname || errmsg "Package failed integrity check"
+# print "/usr/sbin/pkgchk passed."
 
-print "/usr/sbin/pkgchk passed."
 
-
 ########################################
 # Check for some common errors
 #########################################
-# find all executables and dynamic libs,and list their filenames.
-listbinaries() {
-	if [ ! -d $1 ] ; then
-		print errmsg $1 not a directory
-		rm -rf $EXTRACTDIR
-		exit 1
-	fi
 
-	find $1 -print | xargs file |grep ELF |nawk -F: '{print $1}'
-}
+# TODO: To be ported.
+#
+# # find all executables and dynamic libs,and list their filenames.
+# if [[ "$basedir" != "" ]] ; then
+# 	print
+# 	if [[ -f $EXTRACTDIR/elflist ]] ; then
+# 		print "Checking relocation ability..."
+# 		xargs strings < $EXTRACTDIR/elflist| grep /opt/csw
+# 		if [[ $? -eq 0 ]] ; then
+# 			errmsg package build as relocatable, but binaries have hardcoded /opt/csw paths in them
+# 		else
+# 			print trivial check passed
+# 		fi
+# 	else
+# 		echo No relocation check done for non-binary relocatable package.
+# 	fi
+# fi
 
-if [[ "$goodarch" = "yes" ]] ; then
-	# man ld.so.1 for more info on this hack
-	export LD_NOAUXFLTR=1
-	listbinaries $EXTRACTDIR/$pkgname >$EXTRACTDIR/elflist
-	# have to do this for ldd to work. arrg.
-	if [ -s "$EXTRACTDIR/elflist" ] ; then
-		chmod 0755 `cat $EXTRACTDIR/elflist`
-		cat $EXTRACTDIR/elflist| xargs /usr/ccs/bin/dump -Lv |nawk '$2=="NEEDED"{print $3}' |
-			sort -u | egrep -v $EXTRACTDIR >$EXTRACTDIR/liblist
-		print libraries used are:
-		cat $EXTRACTDIR/liblist
-		print "cross-referencing with depend file (May take a while)"
-	else
-		print No dynamic libraries in the package
-	fi
-fi
-
-#If these dont exist, it is Bad.
-touch $EXTRACTDIR/liblist $EXTRACTDIR/libpkgs
-
-# store things that look like shared objects from the package map for
-# delayed library validation.
-grep "\.so" $EXTRACTDIR/$pkgname/pkgmap >> $SETLIBS
-
-if [[ -f $EXTRACTDIR/$pkgname/install/depend ]] ; then
-	print 
-	print "Examining 'depend' file"
-else
-	# They may have forgotten to create/add in a depend file
-	# Remind people what the package depends on
-	# print "Analysing dynamic dependancies, if any"
-	touch $EXTRACTDIR/$pkgname/install/depend
-fi
-
-# sanity check against "depends on self"
-nawk '$2=="'$pkgname'" {exit 1}' $EXTRACTDIR/$pkgname/install/depend
-if [[ $? -ne 0 ]] ; then
-	errmsg "$pkgname references self in depend file"
-fi
-
-#to retain a record of all packages currently being examined from $@
-echo $pkgname >> $SETDEPS
-
-nawk '$1=="P" {print $2}'  $EXTRACTDIR/$pkgname/install/depend |
-	sort >$EXTRACTDIR/deppkgs
-for dep in `cat $EXTRACTDIR/deppkgs`
-do
-    pkginfo $dep
-    if [[ $? -ne 0 ]]; then
-	#if we've already looked at the package named $dep,
-	#it'll be in the file.
-	awk "\$1 == \"$dep\" {print}" $SETDEPS | /usr/bin/grep $dep >/dev/null
-	if [[ $? -ne 0 ]]; then #we haven't yet seen this package in our set
-	    echo "Can't validate dependence on $dep.  Storing for delayed validation."
-	    #store for validation at the end.
-	    echo "$dep $pkgname" >> $SETDEPS.missing
-	else
-	    echo "Found $dep as part of the package set being evaluated."
-	fi
-    fi
+tmparchives="$tmparchives $TMPARCHIVE"
 done
 
-if [[ "$basedir" != "" ]] ; then
-	print
-	if [[ -f $EXTRACTDIR/elflist ]] ; then
-		print "Checking relocation ability..."
-		xargs strings < $EXTRACTDIR/elflist| grep /opt/csw
-		if [[ $? -eq 0 ]] ; then
-			errmsg package build as relocatable, but binaries have hardcoded /opt/csw paths in them
-		else
-			print trivial check passed
-		fi
-	else
-		echo No relocation check done for non-binary relocatable package.
-	fi
-fi
+# Terminating the line with pkgnames
+echo
 
 # Plugin section.
 #
@@ -355,11 +265,6 @@
 # checkpkg is.  Each plugin file name should be an executable and begin with
 # "checkpkg-".
 
-tmparchives="$tmparchives $TMPARCHIVE"
-done
-
-# All packages have been extracted.
-
 set_variables_for_individual_package_check "$f"
 
 test_suite_ok=1
@@ -456,9 +361,10 @@
 fi
 
 # Collecting errors and applying the overrides.
+# This has to use the original files.
 ${command_basedir}/analyze_module_results.py \
-	-e "${EXTRACTDIR}" \
-	${pkgnames}
+    -e "${EXTRACTDIR}" \
+    "$@"
 if [[ "$?" -ne 0 ]]; then
 	errmsg "${RED}Modular checks are reporting errors.${COLOR_RESET}"
 else
@@ -470,18 +376,4 @@
 # Cleaning up after all packages
 cleanup
 
-if [ -s $SETDEPS.missing ]; then
-    print "Doing late evaluations of package dependencies."
-    while read mdep; do
-	dep=`echo $mdep | nawk '{print $1}'`
-	pkg=`echo $mdep | nawk '{print $2}'`
-	/usr/bin/grep $dep $SETDEPS >/dev/null
-	if [ $? -ne 0 ]; then
-	    errmsg "Couldn't validate $dep as a dependency in package $pkg"
-	else
-	    print "Validated $dep as a dependency for $pkg."
-	fi
-    done < $SETDEPS.missing
-fi
-
 cleanupset

Modified: csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py
===================================================================
--- csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py	2010-03-14 05:34:29 UTC (rev 9153)
+++ csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py	2010-03-14 10:14:39 UTC (rev 9154)
@@ -29,7 +29,6 @@
                                            md5sums,
                                            options.debug)
   # Registering functions defined above.
-  check_manager.RegisterIndividualCheck(package_checks_old.CatalognameLowercase)
   check_manager.RegisterIndividualCheck(package_checks_old.FileNameSanity)
   check_manager.RegisterIndividualCheck(package_checks_old.PkginfoSanity)
   check_manager.RegisterIndividualCheck(package_checks_old.ArchitectureSanity)

Modified: csw/mgar/gar/v2/lib/python/checkpkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg.py	2010-03-14 05:34:29 UTC (rev 9153)
+++ csw/mgar/gar/v2/lib/python/checkpkg.py	2010-03-14 10:14:39 UTC (rev 9154)
@@ -433,6 +433,15 @@
         except sqlite3.OperationalError, e:
           logging.warn("sqlite3.OperationalError: %s", e)
 
+  def GetInstalledPackages(self):
+    """Returns a dictioary of all installed packages."""
+    self._LazyInitializeDatabase()
+    c = self.conn.cursor()
+    sql = "SELECT pkgname, pkg_desc FROM packages;"
+    c.execute(sql)
+    return dict(x[0:2] for x in c)
+
+
 def SharedObjectDependencies(pkgname,
                              binaries_by_pkgname,
                              needed_sonames_by_binary,
@@ -820,7 +829,10 @@
     """Proxies calls to self.system_pkgmap."""
     return self.system_pkgmap.GetPkgmapLineByBasename(basename)
 
+  def GetInstalledPackages(self):
+    return self.system_pkgmap.GetInstalledPackages()
 
+
 class IndividualCheckInterface(CheckInterfaceBase):
   """To be passed to the checking functions.
 
@@ -1250,6 +1262,13 @@
       self.CollectStats()
     return self.all_stats
 
+  def GetSavedOverrides(self):
+    if not self.StatsExist():
+      raise PackageError("Package stats not ready.")
+    override_stats = self.ReadObject("overrides")
+    overrides = [Override(**x) for x in override_stats]
+    return overrides
+
   def DumpObject(self, obj, name):
     """Saves an object.
 

Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py	2010-03-14 05:34:29 UTC (rev 9153)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2010-03-14 10:14:39 UTC (rev 9154)
@@ -28,6 +28,14 @@
 MAX_DESCRIPTION_LENGTH = 100
 
 
+def CatalognameLowercase(pkg_data, error_mgr, logger):
+  catalogname = pkg_data["basic_stats"]["catalogname"]
+  if catalogname != catalogname.lower():
+    error_mgr.ReportError("catalogname-not-lowercase")
+  if not re.match(r"^[\w_]+$", catalogname):
+    error_mgr.ReportError("catalogname-is-not-a-simple-word")
+
+
 def CheckForbiddenPaths(pkg_data, error_mgr, logger):
   for pkgname in PATHS_ALLOWED_ONLY_IN:
     if pkgname != pkg_data["basic_stats"]["pkgname"]:
@@ -223,4 +231,18 @@
 
 def SetCheckDependencies(pkgs_data, error_mgr, logger):
   """Dependencies must be either installed in the system, or in the set."""
-  pass
+  known_pkgs = set(error_mgr.GetInstalledPackages())
+  pkgs_under_check = [x["basic_stats"]["pkgname"] for x in pkgs_data]
+  for pkgname in pkgs_under_check:
+    known_pkgs.add(pkgname)
+  for pkg_data in pkgs_data:
+    pkgname = pkg_data["basic_stats"]["pkgname"]
+    for depname, dep_desc in pkg_data["depends"]:
+      if depname not in known_pkgs:
+        error_mgr.ReportError(pkgname, "unidentified-dependency", depname)
+
+def CheckDependsOnSelf(pkg_data, error_mgr, logger):
+  pkgname = pkg_data["basic_stats"]["pkgname"]
+  for depname, dep_desc in pkg_data["depends"]:
+    if depname == pkgname:
+      error_mgr.ReportError("depends-on-self")

Modified: csw/mgar/gar/v2/lib/python/package_checks_old.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_old.py	2010-03-14 05:34:29 UTC (rev 9153)
+++ csw/mgar/gar/v2/lib/python/package_checks_old.py	2010-03-14 10:14:39 UTC (rev 9154)
@@ -17,21 +17,6 @@
     "CSWcommon": ("/opt", "",)
 }
 
-def CatalognameLowercase(pkg_data, debug):
-  errors = []
-  # Here's how to report an error:
-  catalogname = pkg_data["basic_stats"]["catalogname"]
-  if catalogname != catalogname.lower():
-    errors.append(checkpkg.CheckpkgTag(
-      pkg_data["basic_stats"]["pkgname"],
-      "catalogname-not-lowercase"))
-  if not re.match(r"^[\w_]+$", catalogname):
-    errors.append(checkpkg.CheckpkgTag(
-      pkg_data["basic_stats"]["pkgname"],
-      "catalogname-is-not-a-simple-word"))
-  return errors
-
-
 def FileNameSanity(pkg_data, debug):
   errors = []
   basic_stats = pkg_data["basic_stats"]

Modified: csw/mgar/gar/v2/lib/python/package_checks_old_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_old_test.py	2010-03-14 05:34:29 UTC (rev 9153)
+++ csw/mgar/gar/v2/lib/python/package_checks_old_test.py	2010-03-14 10:14:39 UTC (rev 9154)
@@ -46,21 +46,6 @@
     f.close()
     return data
 
-  def testCatalogName_1(self):
-    self.pkg_data_1["basic_stats"]["catalogname"] = "Foo"
-    errors = pc.CatalognameLowercase(self.pkg_data_1, False)
-    self.failUnless(errors)
-
-  def testCatalogName_2(self):
-    self.pkg_data_1["basic_stats"]["catalogname"] = "foo"
-    errors = pc.CatalognameLowercase(self.pkg_data_1, False)
-    self.failIf(errors)
-
-  def testCatalogNameSpecialCharacters(self):
-    self.pkg_data_1["basic_stats"]["catalogname"] = "foo+abc&123"
-    errors = pc.CatalognameLowercase(self.pkg_data_1, False)
-    self.failUnless(errors)
-
   def testFileNameSanity(self):
     del(self.pkg_data_2["basic_stats"]["parsed_basename"]["revision_info"]["REV"])
     errors = pc.FileNameSanity(self.pkg_data_2, False)

Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-03-14 05:34:29 UTC (rev 9153)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-03-14 10:14:39 UTC (rev 9154)
@@ -2,6 +2,7 @@
 # coding=utf-8
 # $Id$
 
+import copy
 import unittest
 import package_checks as pc
 import checkpkg
@@ -13,22 +14,26 @@
 BASE_DIR = os.path.dirname(__file__)
 TESTDATA_DIR = os.path.join(BASE_DIR, "testdata")
 CHECKPKG_STATS_DIR = os.path.join(TESTDATA_DIR, "stats")
+DEFAULT_DATA_MD5 = "461a24f02dd5020b4aa014b76f3ec2cc"
+DEFAULT_PKG_STATS = checkpkg.PackageStats(None, CHECKPKG_STATS_DIR, DEFAULT_DATA_MD5)
+DEFAULT_PKG_DATA = DEFAULT_PKG_STATS.GetAllStats()
 
 class CheckpkgUnitTestHelper(object):
   """Wraps common components of checkpkg tests."""
-  MD5 = "461a24f02dd5020b4aa014b76f3ec2cc"
 
   def setUp(self):
     # This is slow. Let's speed it up somehow.  Move away from yaml and create
     # a Python module with the data.
-    self.pkg_stats = checkpkg.PackageStats(None, CHECKPKG_STATS_DIR, self.MD5)
+    self.pkg_stats = DEFAULT_PKG_STATS
     self.pkg_data = self.pkg_stats.GetAllStats()
+    # This makes one of the test break. To be investigated.
+    # self.pkg_data = DEFAULT_PKG_DATA
     self.mocker = mox.Mox()
 
   def testDefault(self):
     self.logger_mock = self.mocker.CreateMock(logging.Logger)
     self.error_mgr_mock = self.mocker.CreateMock(
-        checkpkg.CheckpkgManager2.IndividualCheckInterface)
+        checkpkg.IndividualCheckInterface)
     self.CheckpkgTest()
     self.mocker.ReplayAll()
     getattr(pc, self.FUNCTION_NAME)(self.pkg_data, self.error_mgr_mock, self.logger_mock)
@@ -99,5 +104,75 @@
     })
 
 
+class TestCatalognameLowercase_1(CheckpkgUnitTestHelper, unittest.TestCase):
+  FUNCTION_NAME = 'CatalognameLowercase'
+  def CheckpkgTest(self):
+    self.pkg_data["basic_stats"]["catalogname"] = "Foo"
+    self.error_mgr_mock.ReportError('catalogname-not-lowercase')
+
+class TestCatalognameLowercase_2(CheckpkgUnitTestHelper, unittest.TestCase):
+  FUNCTION_NAME = 'CatalognameLowercase'
+  def CheckpkgTest(self):
+    self.pkg_data["basic_stats"]["catalogname"] = "foo"
+
+class TestCatalognameLowercase_3(CheckpkgUnitTestHelper, unittest.TestCase):
+  FUNCTION_NAME = 'CatalognameLowercase'
+  def CheckpkgTest(self):
+    self.pkg_data["basic_stats"]["catalogname"] = "foo+abc&123"
+    self.error_mgr_mock.ReportError('catalogname-is-not-a-simple-word')
+
+
+class TestSetCheckDependencies(CheckpkgUnitTestHelper, unittest.TestCase):
+  FUNCTION_NAME = 'SetCheckDependencies'
+  def CheckpkgTest(self):
+    self.pkg_data_single = self.pkg_data
+    self.pkg_data = [self.pkg_data_single]
+    self.pkg_data[0]["depends"].append(["CSWmarsian", "A package from Mars."])
+    installed = ["CSWcommon", "CSWisaexec", "CSWiconv", "CSWlibpopt"]
+    self.error_mgr_mock.GetInstalledPackages().AndReturn(installed)
+    self.error_mgr_mock.ReportError('CSWrsync', 'unidentified-dependency', 'CSWmarsian')
+
+
+class TestSetCheckDependenciesGood(CheckpkgUnitTestHelper, unittest.TestCase):
+  FUNCTION_NAME = 'SetCheckDependencies'
+  def CheckpkgTest(self):
+    self.pkg_data_single = self.pkg_data
+    self.pkg_data = [self.pkg_data_single]
+    installed = ["CSWcommon", "CSWisaexec", "CSWiconv", "CSWlibpopt"]
+    self.error_mgr_mock.GetInstalledPackages().AndReturn(installed)
+
+
+class TestSetCheckDependenciesTwoPkgsBad(CheckpkgUnitTestHelper, unittest.TestCase):
+  FUNCTION_NAME = 'SetCheckDependencies'
+  def CheckpkgTest(self):
+    self.pkg_data_single = self.pkg_data
+    self.pkg_data = [self.pkg_data_single, copy.deepcopy(self.pkg_data_single)]
+    self.pkg_data[1]["basic_stats"]["pkgname"] = "CSWsecondpackage"
+    self.pkg_data[1]["depends"].append(["CSWmartian", ""])
+    installed = ["CSWcommon", "CSWisaexec", "CSWiconv", "CSWlibpopt"]
+    self.error_mgr_mock.GetInstalledPackages().AndReturn(installed)
+    self.error_mgr_mock.ReportError(
+        'CSWsecondpackage', 'unidentified-dependency', 'CSWmartian')
+
+
+class TestSetCheckDependenciesTwoPkgsGood(CheckpkgUnitTestHelper, unittest.TestCase):
+  FUNCTION_NAME = 'SetCheckDependencies'
+  def CheckpkgTest(self):
+    self.pkg_data_single = self.pkg_data
+    self.pkg_data = [self.pkg_data_single, copy.deepcopy(self.pkg_data_single)]
+    self.pkg_data[1]["basic_stats"]["pkgname"] = "CSWsecondpackage"
+    self.pkg_data[1]["depends"].append(["CSWrsync", ""])
+    installed = ["CSWcommon", "CSWisaexec", "CSWiconv", "CSWlibpopt"]
+    self.error_mgr_mock.GetInstalledPackages().AndReturn(installed)
+
+
+class TestCheckCheckDependsOnSelf(CheckpkgUnitTestHelper, unittest.TestCase):
+  FUNCTION_NAME = 'CheckDependsOnSelf'
+  def CheckpkgTest(self):
+    self.pkg_data["depends"].append(["CSWrsync", ""])
+    installed = ["CSWcommon", "CSWisaexec", "CSWiconv", "CSWlibpopt"]
+    self.error_mgr_mock.ReportError('depends-on-self')
+
+
 if __name__ == '__main__':
   unittest.main()


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the devel mailing list