t_pkglint.py revision 2290
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
import testutils
if __name__ == "__main__":
import pkg5unittest
import ConfigParser
import shutil
import unittest
import tempfile
import logging
log_fmt_string = "%(asctime)s - %(levelname)s - %(message)s"
broken_manifests = {}
expected_failures = {}
"pkglint.action002.1", "pkglint.action002.4", "pkglint.action002.4",
"pkglint.action002.3"]
broken_manifests["unusual_perms.mf"] = \
"""
#
#
# We deliver prtdiag as a link on one platform, as a file on another, which is
# allowed, testing variant combinations, the unusual permissions are not.
# they being, broken mode 991, a mode where we have more access as the group and
# world than we have as the user, and an underspecified mode
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141:20100603T215050Z
set name=org.opensolaris.consolidation value=osnet
set name=pkg.description value="core kernel software for a specific instruction-set architecture"
set name=pkg.summary value="Core Solaris Kernel"
set name=variant.arch value=i386 value=sparc
file 1d5eac1aab628317f9c088d21e4afda9c754bb76 chash=43dbb3e0bc142f399b61d171f926e8f91adcffe2 elfarch=i386 elfbits=32 elfhash=64c67b16be970380cd5840dd9753828e0c5ada8c group=sys mode=2755 owner=root path=usr/sbin/prtdiag pkg.csize=5490 pkg.size=13572 variant.arch=i386
# invalid modes
dir path=usr mode=991
"""
# The errors for this check are pretty unpleasant
# across pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141
# pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141
# declaring overlapping variants variant.arch
"pkglint.dupaction007", "pkglint.dupaction001.2"]
broken_manifests["combo_variants_broken.mf"] = \
"""
#
#
# We deliver prtdiag as a link on one platform, as a file on another
# but have forgotten to set the variant properly on the file action
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141:20100603T215050Z
set name=org.opensolaris.consolidation value=osnet
set name=pkg.description value="core kernel software for a specific instruction-set architecture"
set name=pkg.summary value="Core Solaris Kernel"
set name=variant.arch value=i386 value=sparc
file 1d5eac1aab628317f9c088d21e4afda9c754bb76 chash=43dbb3e0bc142f399b61d171f926e8f91adcffe2 elfarch=i386 elfbits=32 elfhash=64c67b16be970380cd5840dd9753828e0c5ada8c group=sys mode=2755 owner=root path=usr/sbin/prtdiag pkg.csize=5490 pkg.size=13572 variant.arch=sparc
"""
broken_manifests["dup-clashing-vars.mf"] = \
"""
#
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.141:20100604T143737Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=variant.other value=carrots
set name=variant.arch value=i386 value=sparc
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
file nohash group=bin mode=0755 owner=root path=usr/sbin/fsadmin pkg.csize=953 pkg.size=1572 variant.other=carrots
file nohash group=bin mode=0755 owner=root path=usr/sbin/fsadmin pkg.csize=1234 pkg.size=1234 variant.other=carrots
file nohash group=sys mode=0444 owner=root path=var/svc/manifest/application/x11/xfs.xml pkg.csize=1649 pkg.size=3534 restart_fmri=svc:/system/manifest-import:default
file nohash elfarch=i386 elfbits=32 elfhash=2d5abc9b99e65c52c1afde443e9c5da7a6fcdb1e group=bin mode=0755 owner=root path=usr/bin/xfs pkg.csize=68397 pkg.size=177700 variant.arch=i386
"""
"pkglint.action005.1", "pkglint.action005.1",
"pkglint.action005.1"]
broken_manifests["dup-depend-vars.mf"] = \
"""
#
# we declare dependencies on the same package name twice, with variants
#
set name=pkg.fmri value=pkg://opensolaris.org/SUNWzsh@4.3.9,5.11-0.133:20100216T103302Z
set name=org.opensolaris.consolidation value=sfw
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
set name=variant.opensolaris.zone value=global value=nonglobal
set name=variant.arch value=sparc value=i386
set name=variant.foo value=bar value=baz
depend fmri=consolidation/sfw/sfw-incorporation type=require
depend fmri=shell/zsh/redherring@4.3.9-0.133 type=require variant.foo=bar
"""
broken_manifests["dup-depend-incorp.mf"] = \
"""
#
# There are 2 dependencies on sfw-incorporation, but only one is a require
# incorporation, so this should not generate errors, other than us not being
# able to find the dependency warning.
#
set name=pkg.fmri value=pkg://opensolaris.org/entire@0.5.11,5.11-0.145:20100730T013044Z
set name=pkg.depend.install-hold value=core-os
set name=pkg.description value="This package constrains system package versions to the same build. WARNING: Proper system update and correct package selection depend on the presence of this incorporation. Removing this package will result in an unsupported system."
set name=description value="incorporation to lock all system packages to same build"
set name=pkg.summary value="incorporation to lock all system packages to same build"
set name=variant.arch value=sparc value=i386
set name=org.opensolaris.consolidation value=None
depend fmri=consolidation/sfw/sfw-incorporation type=require
depend fmri=consolidation/sfw/sfw-incorporation@0.5.11-0.145 type=incorporate
"""
"pkglint.action005.1", "pkglint.action005.1"]
broken_manifests["dup-depend-versions.mf"] = \
"""
#
# as we're declaring complimentary variants, we shouldn't report errors,
# other than the 3 lint warnings for the missing dependencies
#
set name=pkg.fmri value=pkg://opensolaris.org/SUNWzsh@4.3.9,5.11-0.133:20100216T103302Z
set name=org.opensolaris.consolidation value=sfw
set name=variant.opensolaris.zone value=global value=nonglobal
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
set name=variant.arch value=sparc value=i386
set name=variant.other value=other value=thing
set name=variant.foo value=bar value=baz
depend fmri=consolidation/sfw/sfw-incorporation type=require
"""
broken_manifests["dup-no-vars.mf"] = \
"""
#
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.141:20100604T143737Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=variant.arch value=i386 value=sparc
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
file nohash group=sys mode=0444 owner=root path=var/svc/manifest/application/x11/xfs.xml pkg.csize=1649 pkg.size=3534 restart_fmri=svc:/system/manifest-import:default
file nohash elfarch=i386 elfbits=32 elfhash=2d5abc9b99e65c52c1afde443e9c5da7a6fcdb1e group=bin mode=0755 owner=root path=usr/bin/xfs pkg.csize=68397 pkg.size=177700 variant.arch=i386
"""
broken_manifests["dup-refcount-diff-attrs.mf"] = \
"""
#
# we deliver some duplicate ref-counted actions (dir, link, hardlink) with differing
# attributes
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.141:20100604T143737Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=variant.other value=carrots
set name=variant.arch value=i386 value=sparc
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
"""
# 3 errors get reported for this manifest:
# usr/sbin/fsadmin is delivered by multiple action types across ['pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.141:20100604T143737Z']
# usr/sbin/fsadmin is ref-counted but has different attributes across duplicates in [<pkg.fmri.PkgFmri 'pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.141:20100604T143737Z' at 0x8733e2c>]
# usr/sbin/fsadmin delivered by [<pkg.fmri.PkgFmri 'pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.141:20100604T143737Z' at 0x8733e2c>] is a duplicate, declaring overlapping variants ['variant.other']
"pkglint.dupaction007", "pkglint.dupaction001.1"]
broken_manifests["dup-types-clashing-vars.mf"] = \
"""
#
# variant on both.
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.141:20100604T143737Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=variant.arch value=i386 value=sparc
set name=variant.other value=carrots
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
file nohash group=bin mode=0755 owner=root path=usr/sbin/fsadmin pkg.csize=1234 pkg.size=1234 variant.other=carrots
file nohash group=sys mode=0444 owner=root path=var/svc/manifest/application/x11/xfs.xml pkg.csize=1649 pkg.size=3534 restart_fmri=svc:/system/manifest-import:default
file nohash elfarch=i386 elfbits=32 elfhash=2d5abc9b99e65c52c1afde443e9c5da7a6fcdb1e group=bin mode=0755 owner=root path=usr/bin/xfs pkg.csize=68397 pkg.size=177700 variant.arch=i386
"""
# 2 errors here
# usr/lib/X11/fs is delivered by multiple action types across ['pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.141:20100604T143737Z']
# path usr/lib/X11/fs is ref-counted but has different attributes across duplicates in [<pkg.fmri.PkgFmri 'pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.141:20100604T143737Z' at 0x87369ec>]
"pkglint.dupaction007"]
broken_manifests["dup-types.mf"] = \
"""
#
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.141:20100604T143737Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=variant.arch value=i386 value=sparc
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
file nohash group=sys mode=0444 owner=root path=var/svc/manifest/application/x11/xfs.xml pkg.csize=1649 pkg.size=3534 restart_fmri=svc:/system/manifest-import:default
file nohash elfarch=i386 elfbits=32 elfhash=2d5abc9b99e65c52c1afde443e9c5da7a6fcdb1e group=bin mode=0755 owner=root path=usr/bin/xfs pkg.csize=68397 pkg.size=177700 variant.arch=i386
"""
broken_manifests["duplicate_sets.mf"] = \
"""
#
# We try to deliver the same set action twice
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141:20100603T215050Z
set name=org.opensolaris.consolidation value=osnet
set name=pkg.description value="core kernel software for a specific instruction-set architecture"
set name=pkg.summary value="Core Solaris Kernel"
set name=variant.arch value=i386 value=sparc
set name=test value=i386
set name=test value=i386
"""
expected_failures["duplicate_sets_allowed_vars.mf"] = []
broken_manifests["duplicate_sets_allowed_vars.mf"] = \
"""
#
# We try to deliver the same set action twice, with different variants
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141:20100603T215050Z
set name=pkg.description value="core kernel software for a specific instruction-set architecture"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
set name=test value=i386 variant.arch=sparc
set name=test value=i386 variant.arch=i386
"""
broken_manifests["duplicate_sets_variants.mf"] = \
"""
#
# We try to deliver the same set action twice, with variants
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141:20100603T215050Z
set name=org.opensolaris.consolidation value=osnet
set name=pkg.description value="core kernel software for a specific instruction-set architecture"
set name=pkg.summary value="Core Solaris Kernel"
set name=variant.arch value=i386 value=sparc
set name=test value=i386 variant.arch=sparc
set name=test value=i386 variant.arch=sparc
"""
expected_failures["info_class_valid.mf"] = []
broken_manifests["info_class_valid.mf"] = \
"""
#
# A perfectly valid manifest with a correct info.classification key
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.149:20100917T003411Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
set name=variant.arch value=i386 value=sparc
"""
broken_manifests["info_class_missing.mf"] = \
"""
#
# we deliver package with no info.classification key
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.149:20100917T003411Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
set name=variant.arch value=i386 value=sparc
"""
broken_manifests["silly_description.mf"] = \
"""
#
# we deliver package where the description is the same as the summary
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.149:20100917T003411Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=pkg.description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
set name=variant.arch value=i386 value=sparc
"""
broken_manifests["info_class_many_values.mf"] = \
"""
#
# we deliver a directory with multiple info.classification keys, one of which
# is wrong
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.149:20100917T003411Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=info.classification value=org.opensolaris.category.2008:System/Noodles value=org.opensolaris.category.2008:System/Core
set name=pkg.summary value="Pkglint test package"
set name=variant.arch value=i386 value=sparc
"""
broken_manifests["info_class_wrong_prefix.mf"] = \
"""
#
# we deliver a directory with an incorrect info.classification key
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.149:20100917T003411Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
set name=variant.arch value=i386 value=sparc
"""
broken_manifests["info_class_no_category.mf"] = \
"""
#
# we deliver a directory with an incorrect info.classification key,
# with no category value
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.149:20100917T003411Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=info.classification value=org.opensolaris.category.2008:
set name=pkg.summary value="Pkglint test package"
set name=variant.arch value=i386 value=sparc
"""
broken_manifests["info_class_wrong_category.mf"] = \
"""
#
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.149:20100917T003411Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
set name=variant.arch value=i386 value=sparc
"""
"opensolaris.action001.3", "opensolaris.action001.2",
"opensolaris.action001.3", "opensolaris.action001.1",
"opensolaris.action001.3"]
broken_manifests["invalid_usernames.mf"] = \
"""
#
# We try to deliver a series of invalid usernames, some result in multiple
# lint messages
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141:20100603T215050Z
set name=org.opensolaris.consolidation value=osnet
set name=pkg.description value="core kernel software for a specific instruction-set architecture"
set name=pkg.summary value="Core Solaris Kernel"
set name=variant.arch value=i386 value=sparc
user gcos-field="pkg(5) server UID" group=pkg5srv uid=97 username=""
user gcos-field="pkg(5) server UID" group=pkg5srv uid=98 username=1pkg5srv
user gcos-field="pkg(5) server UID" group=pkg5srv uid=99 username=pkg5srvZZ
user gcos-field="pkg(5) server UID" group=pkg5srv uid=100 username=pkg5s:v
user gcos-field="pkg(5) server UID" group=pkg5srv uid=101 username=pkg5-_.
"""
broken_manifests["license-has-path.mf"] = \
"""
#
# We deliver a license action that also specifies a path
#
set name=variant.arch value=i386 value=sparc
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141:20100603T215050Z
set name=pkg.description value="core kernel software for a specific instruction-set architecture"
set name=org.opensolaris.consolidation value=osnet
set name=pkg.summary value="Core Solaris Kernel"
license license="Foo" path=usr/share/lib/legalese.txt
"""
# We actually emit 3 messages here in testing, 1 for the legitmate error,
# 2 for the "linted"-handling code, saying that we're not linting these actions
#
"pkglint.dupaction003.1"]
broken_manifests["linted-action.mf"] = \
"""
#
# we deliver some duplicate ref-counted actions (dir, link, hardlink) with differing
# attributes, but since they're marked as linted, we should get no output, we should
# still get the duplicate user though.
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/TIMFtest@1.1.0,5.11-0.141:20100604T143737Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=variant.other value=carrots
set name=variant.arch value=i386 value=sparc
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
user ftpuser=false gcos-field="Network Configuration Admin" group=netadm uid=17 username=netcfg
user ftpuser=false gcos-field="Network Configuration Admin" group=netadm uid=19 username=netcfg
"""
# We'll actually report one lint message here, that we're not
# doing any linting for this manifest because of pkg.linted
# - the default log handler used by the pkglint CLI only marks
# a failure if it's > level.INFO, but for testing, we record all
# messages
broken_manifests["linted-manifest.mf"] = \
"""
#
# This manifest is marked as pkg.linted, and should not have manifest
# checks run on it. In particular, we should not complain about the lack
# of variant.arch nor the unusual permission, 0751
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/TIMFtest@1.1.0,5.11-0.141:20100604T143737Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=variant.other value=carrots
# set name=variant.arch value=i386 value=sparc
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
set name=pkg.linted value=True
user ftpuser=false gcos-field="Network Configuration Admin" group=netadm uid=17 username=netcfg
user ftpuser=false gcos-field="Network Configuration Admin" group=netadm uid=19 username=netcfg
"""
broken_manifests["no_desc-legacy.mf"] = \
"""
#
# We deliver a legacy actions without a required attribute, "desc". Since we
# can't find the package pointed to by the legacy 'pkg' attribute, we should
# not complain about those.
# This package also has no variant.arch attribute, which should be fine since
# we're not delivering any content with an elfarch attribute, and we're
# omitting the variant.arch from the legacy actions.
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141:20100603T215050Z
set name=pkg.description value="core kernel software for a specific instruction-set architecture"
set name=pkg.summary value="Core Solaris Kernel"
# set name=variant.arch value=i386 value=sparc
set name=org.opensolaris.consolidation value=osnet
legacy arch=i386 category=system hotline="Please contact your local service provider" name="Core Solaris Kernel (Root)" pkg=SUNWckr vendor="Sun Microsystems, Inc." version=11.11,REV=2009.11.11
legacy arch=sparc category=system desc="core kernel software for a specific instruction-set architecture" hotline="Please contact your local service provider" name="Core Solaris Kernel (Root)" pkg=SUNWckr vendor="Sun Microsystems, Inc." version=11.11,REV=2009.11.11
"""
expected_failures["no_dup-allowed-vars.mf"] = []
broken_manifests["no_dup-allowed-vars.mf"] = \
"""
#
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.141:20100604T143737Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
set name=variant.arch value=i386 value=sparc
set name=variant.other value="carrots" value="turnips"
file nohash group=bin mode=0755 owner=root path=usr/sbin/fsadmin pkg.csize=953 pkg.size=1572 variant.other=carrots
file nohash group=bin mode=0755 owner=root path=usr/sbin/fsadmin pkg.csize=1234 pkg.size=1234 variant.other=turnips
file nohash group=sys mode=0444 owner=root path=var/svc/manifest/application/x11/xfs.xml pkg.csize=1649 pkg.size=3534 restart_fmri=svc:/system/manifest-import:default
file nohash elfarch=i386 elfbits=32 elfhash=2d5abc9b99e65c52c1afde443e9c5da7a6fcdb1e group=bin mode=0755 owner=root path=usr/bin/xfs pkg.csize=68397 pkg.size=177700 variant.arch=i386
"""
expected_failures["no_dup-types-different-vars.mf"] = []
broken_manifests["no_dup-types-different-vars.mf"] = \
"""
#
# delivering to the same path name. Ref-counted actions, but
# different variants, this should not be reported as an error
# doesn't result in lint errors.
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.141:20100604T143737Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
set name=variant.arch value=i386 value=sparc
set name=variant.bar value=other value=foo
file nohash group=sys mode=0444 owner=root path=var/svc/manifest/application/x11/xfs.xml pkg.csize=1649 pkg.size=3534 restart_fmri=svc:/system/manifest-import:default
file nohash elfarch=i386 elfbits=32 elfhash=2d5abc9b99e65c52c1afde443e9c5da7a6fcdb1e group=bin mode=0755 owner=root path=usr/bin/xfs pkg.csize=68397 pkg.size=177700 variant.arch=i386
"""
# our obsolete depend lint check should complain about not being able to find
# manifests, but we shouldn't trigger the duplicate dependency error
"pkglint.action005.1", "pkglint.action005.1"]
broken_manifests["nodup-depend-okvars.mf"] = \
"""
#
# as we're declaring complimentary variants, we shouldn't report errors
#
set name=pkg.fmri value=pkg://opensolaris.org/SUNWzsh@4.3.9,5.11-0.133:20100216T103302Z
set name=org.opensolaris.consolidation value=sfw
set name=variant.opensolaris.zone value=global value=nonglobal
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
set name=variant.arch value=sparc value=i386
set name=variant.other value=other value=thing
set name=variant.foo value=bar value=baz
depend fmri=consolidation/sfw/sfw-incorporation type=require
"""
"pkglint.action005.1", "pkglint.action005.1"]
broken_manifests["novariant_arch.mf"] = \
"""
#
# we don't have a variant.arch attribute set, and are delivering a file with
# an elfarch attribute
#
set name=pkg.fmri value=pkg://opensolaris.org/SUNWzsh@4.3.9,5.11-0.133:20100216T103302Z
set name=org.opensolaris.consolidation value=sfw
set name=variant.opensolaris.zone value=global value=nonglobal
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
set name=variant.other value=other value=thing
set name=variant.foo value=bar value=baz
depend fmri=consolidation/sfw/sfw-incorporation type=require
file nohash elfarch=i386 elfbits=32 elfhash=2d5abc9b99e65c52c1afde443e9c5da7a6fcdb1e group=bin mode=0755 owner=root path=usr/bin/xfs pkg.csize=68397 pkg.size=177700
"""
broken_manifests["obsolete-has-description.mf"] = \
"""
#
# We deliver an obsolete package that has a pkg.description
#
set name=pkg.fmri value=pkg://opensolaris.org/SUNWaspell@0.5.11,5.11-0.130:20091218T222625Z
set name=pkg.obsolete value=true variant.arch=i386
set name=pkg.description value="This is a package description"
set name=variant.opensolaris.zone value=global value=nonglobal variant.arch=i386
set name=variant.arch value=i386
"""
broken_manifests["obsolete-more-actions.mf"] = \
"""
#
# We deliver an obsolete package that has actions other than 'set'.
# (bogus signature on this manifest, just for testing)
#
set name=pkg.fmri value=pkg://opensolaris.org/SUNWaspell@0.5.11,5.11-0.130:20091218T222625Z
set name=pkg.obsolete value=true variant.arch=i386
set name=variant.opensolaris.zone value=global value=nonglobal variant.arch=i386
set name=variant.arch value=i386
signature algorithm=sha256 value=75b662e14a4ea8f0fa0507d40133b0347a36bc1f63112487f4738073edf4455d version=0
"""
expected_failures["obsolete.mf"] = []
broken_manifests["obsolete.mf"] = \
"""
#
# This is a perfectly valid example of an obsolete package
#
set name=pkg.fmri value=pkg://opensolaris.org/SUNWaspell@0.5.11,5.11-0.130:20091218T222625Z
set name=pkg.obsolete value=true variant.arch=i386
set name=variant.opensolaris.zone value=global value=nonglobal variant.arch=i386
set name=variant.arch value=i386
"""
"pkglint.manifest002.3"]
broken_manifests["renamed-more-actions.mf"] = \
"""
#
# We've reported a package as having been renamed, yet try to deliver
# actions other than 'set' and 'depend'
# (bogus signature on this manifest, just for testing)
#
set name=pkg.fmri value=pkg://opensolaris.org/SUNWzsh@4.3.9,5.11-0.133:20100216T103302Z
set name=org.opensolaris.consolidation value=sfw
set name=pkg.renamed value=true
set name=variant.opensolaris.zone value=global value=nonglobal
set name=variant.arch value=sparc value=i386
depend fmri=consolidation/sfw/sfw-incorporation type=require
signature algorithm=sha256 value=75b662e14a4ea8f0fa0507d40133b0347a36bc1f63112487f4738073edf4455d version=0
"""
broken_manifests["renamed.mf"] = \
"""
#
# This is a perfectly valid example of a renamed package
# (bogus signature on this manifest, just for testing)
#
set name=pkg.fmri value=pkg://opensolaris.org/SUNWzsh@4.3.9,5.11-0.133:20100216T103302Z
set name=org.opensolaris.consolidation value=sfw
set name=pkg.renamed value=true
set name=variant.opensolaris.zone value=global value=nonglobal
set name=variant.arch value=sparc value=i386
depend fmri=consolidation/sfw/sfw-incorporation type=require
signature algorithm=sha256 value=75b662e14a4ea8f0fa0507d40133b0347a36bc1f63112487f4738073edf4455d version=0
"""
"pkglint.action001.2"]
broken_manifests["underscores.mf"] = \
"""
#
# We try to deliver attributes with underscores.
#
set name=pkg.fmri value=pkg://opensolaris.org/system/underscores@0.5.11,5.11-0.141:20100603T215050Z
set name=pkg.description value="core kernel software for a specific instruction-set architecture"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
set name=test value=i386 variant.arch=sparc
set name=this_underscore_check value=i386 another_attribute=False
set name=info.source_url value=http://www.sun.com
"""
broken_manifests["undescribed-variant.mf"] = \
"""
#
# we try to set a variant we've never described in the manifest
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.141:20100604T143737Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=variant.arch value=i386 value=sparc
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
file nohash group=sys mode=0444 owner=root path=var/svc/manifest/application/x11/xfs.xml pkg.csize=1649 pkg.size=3534 restart_fmri=svc:/system/manifest-import:default variant.noodles=singapore
file nohash elfarch=i386 elfbits=32 elfhash=2d5abc9b99e65c52c1afde443e9c5da7a6fcdb1e group=bin mode=0755 owner=root path=usr/bin/xfs pkg.csize=68397 pkg.size=177700 variant.arch=i386
"""
broken_manifests["unknown-variant.mf"] = \
"""
#
# we try to deliver an action with a variant value we haven't described
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.141:20100604T143737Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=variant.arch value=i386 value=sparc
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
file nohash group=sys mode=0444 owner=root path=var/svc/manifest/application/x11/xfs.xml pkg.csize=1649 pkg.size=3534 restart_fmri=svc:/system/manifest-import:default variant.opensolaris.zone=foo
file nohash elfarch=i386 elfbits=32 elfhash=2d5abc9b99e65c52c1afde443e9c5da7a6fcdb1e group=bin mode=0755 owner=root path=usr/bin/xfs pkg.csize=68397 pkg.size=177700 variant.arch=i386
"""
broken_manifests["unknown.mf"] = \
"""
#
# We try to deliver an 'unknown' action
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141:20100603T215050Z
set name=pkg.description value="core kernel software for a specific instruction-set architecture"
set name=pkg.summary value="Core Solaris Kernel"
set name=variant.arch value=i386 value=sparc
set name=org.opensolaris.consolidation value=osnet
unknown name="no idea"
"""
"pkglint.action002.4"]
broken_manifests["unusual_mode_noexecdir.mf"] = \
"""
#
# we deliver a directory with an unexecutable mode 0422
#
set name=pkg.fmri value=pkg://opensolaris.org/pkglint/test@1.1.0,5.11-0.141:20100604T143737Z
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=pkg.description value="Description of pkglint test package"
set name=description value="Pkglint test package"
set name=pkg.summary value="Pkglint test package"
set name=variant.arch value=i386 value=sparc
file nohash group=sys mode=0444 owner=root path=var/svc/manifest/application/x11/xfs.xml pkg.csize=1649 pkg.size=3534 restart_fmri=svc:/system/manifest-import:default
file nohash elfarch=i386 elfbits=32 elfhash=2d5abc9b99e65c52c1afde443e9c5da7a6fcdb1e group=bin mode=0755 owner=root path=usr/bin/xfs pkg.csize=68397 pkg.size=177700 variant.arch=i386
"""
"""Records log messages to a buffer"""
def test_lint_checks(self):
"""Ensure that lint checks are functioning."""
"Expected %s failures for %s, got %s: %s" %
else:
"Differences in reported vs. "
"expected lint ids for %s: "
"%s vs. %s" %
"""info.classification check can deal with bad data files."""
{"info_class_valid.mf":
broken_manifests["info_class_valid.mf"]})
f.write("nothing here")
f.close()
bad_file]:
{"info_classification_path": classification_path},
"Unexpected errors encountered: %s" %
"""Tests that exercise reference vs. lint repository checks
and test linting of multiple packages at once."""
ref_mf = {}
#
# A sample package which delivers several actions, to an earlier release than
# 0.140. This manifest has an intentional error, which we should detect when
# linting against build 139.
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.139
set name=pkg.description value="core kernel software for a specific instruction-set architecture"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
dir group=sys mode=0755 owner=root path=etc
"""
#
# A sample package which delivers several actions, to an earlier release than
# 0.141
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.140
set name=pkg.description value="core kernel software for a specific instruction-set architecture"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
dir group=sys mode=0755 owner=root path=etc
"""
#
# A sample package which delivers several actions, to 0.141
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141
set name=pkg.description value="core kernel software for a specific instruction-set architecture"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
dir group=sys mode=0755 owner=root path=etc
"""
#
# A sample package which delivers several actions
#
set name=pkg.fmri value=pkg://opensolaris.org/system/additional@0.5.11,5.11-0.141
set name=pkg.description value="additional reference actions for pkglint"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
dir group=sys mode=0755 owner=root path=etc
dir group=sys mode=0755 owner=root path=etc
"""
#
# A sample package which delivers several actions
#
set name=pkg.fmri value=pkg://opensolaris.org/system/more@0.5.11,5.11-0.141
set name=pkg.description value="additional reference actions for pkglint"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
dir group=sys mode=0755 owner=root path=etc
"""
#
# This is not an obsolete package - used to check versioning
#
set name=pkg.fmri value=pkg://opensolaris.org/system/obsolete@0.5.11,5.11-0.140
set name=variant.opensolaris.zone value=global value=nonglobal variant.arch=i386
set name=variant.arch value=i386
"""
#
# This is a perfectly valid example of an obsolete package
#
set name=pkg.fmri value=pkg://opensolaris.org/system/obsolete@0.5.11,5.11-0.141
set name=pkg.obsolete value=true variant.arch=i386
set name=variant.opensolaris.zone value=global value=nonglobal variant.arch=i386
set name=variant.arch value=i386
"""
#
# This is a dummy package designed trip a lint of no-ancestor-legacy.mf
# we don't declare a dependency on the package delivering the legacy action.
#
set name=pkg.fmri value=pkg://opensolaris.org/SUNWckr@0.5.11,5.11-0.141
set name=pkg.description value="additional reference actions for pkglint"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=pkg.renamed value=true
set name=variant.arch value=i386 value=sparc
"""
#
# set of variants for both the action and the package. This should not cause
# an assertion to be raised.
#
set name=variant.arch value=sparc value=i386
set name=pkg.summary value="A packge with two variant values"
set name=pkg.description value="A package with two values for variant.arch."
set name=org.opensolaris.consolidation value=osnet
set name=variant.opensolaris.zone value=global value=nonglobal
set name=pkg.fmri value=pkg://opensolaris.org/variant/twovar@0.5.11,5.11-0.148:20100910T211706Z
"""
#
# This is a dummy package designed trip a lint of no-ancestor-legacy.mf
# we don't declare a dependency on the FMRI delivered by it.
#
set name=pkg.fmri value=pkg://opensolaris.org/SUNWckr-norename@0.5.11,5.11-0.141
set name=pkg.description value="additional reference actions for pkglint"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
"""
#
# A package with a legacy action that points to a renamed ancestor
#
set name=pkg.fmri value=pkg://opensolaris.org/legacy-uses-renamed-ancestor@0.5.11,5.11-0.141
set name=pkg.description value="additional reference actions for pkglint"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
legacy pkg="renamed-ancestor-old" desc="core kernel software for a specific instruction-set architecture" arch=i386 category=system hotline="Please contact your local service provider" name="Core Solaris Kernel (Root)" vendor="Sun Microsystems, Inc." version=11.11,REV=2009.11.11
"""
#
# The ancestor referred to above, but we've renamed it
#
set name=pkg.fmri value=pkg://opensolaris.org/renamed-ancestor-old@0.5.11,5.11-0.141
set name=pkg.description value="additional reference actions for pkglint"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
set name=pkg.renamed value=true
depend fmri=renamed-ancestor-new type=require
"""
#
# The renamed legacy ancestor - this correctly depends on the latest
# named version
#
set name=pkg.fmri value=pkg://opensolaris.org/renamed-ancestor-new@0.5.11,5.11-0.141
set name=pkg.description value="additional reference actions for pkglint"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
set name=pkg.renamed value=true
depend fmri=legacy-uses-renamed-ancestor type=require
"""
# A set of manifests to be linted. Note that these are all self
# consistent, passing all lint checks on their own.
# Errors are designed to show up when linted against the ref_*
# manifests, as imported to our reference repository.
lint_mf = {}
expected_failures = {}
"pkglint.manifest004"]
#
# We deliver something a package older version than our ref_repo has,
# 0.140 instead of 0.141, this should cause errors unless we're
# linting against the 0.140 build in the repository.
# duplicate of the 0.141 package)
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.140
set name=pkg.description value="core kernel"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
dir group=sys mode=0755 owner=root path=etc
"""
expected_failures["deliver-new-sample1.mf"] = []
#
# We deliver a newer version than our reference repo has
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141
set name=pkg.description value="core kernel"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
dir group=sys mode=0755 owner=root path=etc
"""
expected_failures["deliver-new-sample1-duplicate.mf"] = \
["pkglint.dupaction001.1"]
#
# We deliver a newer version than our reference repo has, intentionally
# duplicating a file our reference repository has in sample3
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.142
set name=pkg.description value="core kernel"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
dir group=sys mode=0755 owner=root path=etc
"""
lint_mf["no-ancestor-legacy.mf"] = \
"""
#
# We deliver a legacy action, but declare a package in the legacy action pkg=
# field from the ref repo which doesn't depend on us. Only one failure,
# because the 2nd legacy action below points to a non-existent package.
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141
set name=pkg.description value="core kernel"
set name=pkg.summary value="Core Solaris Kernel"
set name=variant.arch value=i386 value=sparc
set name=org.opensolaris.consolidation value=osnet
legacy arch=i386 category=system desc="core kernel software for a specific instruction-set architecture" hotline="Please contact your local service provider" name="Core Solaris Kernel (Root)" pkg=SUNWckr variant.arch=i386 vendor="Sun Microsystems, Inc." version=11.11,REV=2009.11.11
legacy arch=sparc category=system desc="core kernel software for a specific instruction-set architecture" hotline="Please contact your local service provider" name="Core Solaris Kernel (Root)" pkg=SUNWthisdoesnotexist variant.arch=sparc vendor="Sun Microsystems, Inc." version=11.11,REV=2009.11.11
"""
#
# We declare a dependency without a version number, on an obsolete package
# this should result in a lint error
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141
set name=pkg.description value="core kernel"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
"""
#
# We declare a dependency on a version known to be obsolete
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141
set name=pkg.description value="core kernel"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
depend fmri=pkg://opensolaris.org/system/obsolete@0.5.11,5.11-0.141 type=require
"""
#
# We have dependency on an older version of the packages which was recently
# made obsolete. Even though we declared the dependency on the non-obsolete
# version, because we published a later, obsoleted version of that package,
# we should get the lint warning.
#
set name=pkg.fmri value=pkg://opensolaris.org/system/kernel@0.5.11,5.11-0.141
set name=pkg.description value="core kernel"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
"""
expected_failures["onevar.mf"] = []
#
# Test that a package which is only published against one variant value doesn't
# cause an assertion failure when it shares an action with another package.
# package twovar.
#
set name=pkg.summary value="A package with one variant" variant.arch=i386
set name=org.opensolaris.consolidation value=osnet variant.arch=i386
set name=info.classification value="org.opensolaris.category.2008:Drivers/Other Peripherals" variant.arch=i386
set name=variant.arch value=i386
set name=variant.opensolaris.zone value=global value=nonglobal variant.arch=i386
set name=pkg.fmri value=pkg://opensolaris.org/variants/onevar@0.5.11,5.11-0.148:20100910T195826Z
set name=pkg.description value="A package published against only one variant value" variant.arch=i386
dir group=sys mode=0755 owner=root path=kernel/strmod variant.arch=i386 variant.opensolaris.zone=global
"""
expected_failures["broken-renamed-ancestor-new.mf"] = \
["pkglint.manifest002.3"]
#
# A new version of one of the packages in the rename chain for
# legacy-has-renamed-ancestor, which should result in an error.
# When tested on its own, this package results in just the 'missing rename'
# error, pkglint.manifest002.3 When tested as part of a checking a legacy
# action which has a pkg attribute pointing to an old package that gets renamed,
# we should get pkglint.action003.4
#
set name=pkg.fmri value=pkg://opensolaris.org/renamed-ancestor-new@0.5.11,5.11-0.141
set name=pkg.description value="additional reference actions for pkglint"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
set name=pkg.renamed value=true
depend fmri=renamed-ancestor-missing type=require
"""
#
# A new version of one of the packages in the rename chain for
# legacy-has-renamed-ancestor, which should result in an error.
# When tested on its own, this package results in the 'looping rename'
# error, pkglint.manifest002.4 When tested as part of a checking a legacy action
# which has a pkg attribute point to an old package that gets renamed,
# we should get pkglint.action003.5, since we're trying to depend on ourselves
#
set name=pkg.fmri value=pkg://opensolaris.org/renamed-ancestor-new@0.5.11,5.11-0.141
set name=pkg.description value="additional reference actions for pkglint"
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
set name=pkg.renamed value=true
depend fmri=renamed-ancestor-new type=require
"""
lint_move_mf = {}
#
# A sample package which delivers several actions, to 0.161. We no longer
#
set name=pkg.summary value="Core Solaris Kernel"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
dir group=sys mode=0755 owner=root path=etc
"""
#
# also.
#
set name=pkg.fmri value=pkg://foo.org/system/additional@0.5.11,5.11-0.161
set name=pkg.summary value="additional content"
set name=org.opensolaris.consolidation value=osnet
set name=variant.arch value=i386 value=sparc
dir group=sys mode=0755 owner=root path=etc
dir group=sys mode=0755 owner=root path=etc
"""
["opensolaris.org", "opensolaris.org", "opensolaris.org"],
command="refresh-index")
command="refresh-index")
def test_lint_repo_basics(self):
"""Test basic handling of repo URIs with the lint engine,
reference repo is error free, cache dir torn down appropriately.
"""
"Unexpected lint errors messages reported against "
"reference repo: %s" %
"Cache dir does not exist after teardown!")
"lint image dir still existed after teardown!")
# This shouldn't appear when we're not using a reference repo
"ref image dir existed!")
"Cache dir was not torn down as expected")
def test_empty_lint_repo(self):
"""Ensure we can lint an empty repository"""
lint_msgs = []
# prune out the missing dependency warnings
if "pkglint.action005.1" not in msg:
"Lint messages reported from a clean reference repository.")
# this should be an empty test: we have no packages in the
# lint repository, so we end up doing nothing
"Lint messages reported from a empty lint repository.")
def test_versioning(self):
"""Package version handling during lint runs.
In particular, it verifies that packages for linting are merged
correctly into pkglint's view of what the ref repository would
look like, were the lint package to be published to the
reference repository."""
"pkglintrc"))
"Expected %s failures for %s, got %s: %s" %
else:
"Differences in reported vs. expected"
" lint ids for %s: %s vs. %s" %
# this manifest should report duplicates when
# linted against a 0.141 repository, but none
# when linted against a 0.140 repository. The duplicates
# were tested when 'deliver-old-sample1.mf' was linted
# above - this time, we lint against 0.140 and expect
# no errors.
"Unexpected lint messages when linting against old "
"version of reference repo: %s" %
# ensure we detect the error when linting against the reference
# 0.139 repository
if not lint_logger.ids:
"No lint messages produced when linting the "
"contents of an old repository")
"Expected exactly 1 lint message when linting the "
"contents of an old repository, got %s" %
"Expected pkglint.dupaction001.1 message when "
"linting the contents of an old repository, got "
def test_lint_mf_baseline(self):
"""The lint manifests in this test class should be lint-clean
themselves - they should only report errors when linting against
our reference repository."""
"pkglintrc"))
# prune missing dependency and missing rename warnings
lint_msgs = []
if "pkglint.manifest002.3" in msg or \
"pkglint.manifest002.4" in msg or \
"pkglint.action005.1" in msg:
pass
else:
"Unexpected lint messages when linting individual "
"manifests that should contain no errors: %s %s" %
"""Tests that linting a package where we break the renaming
of a legacy package, we'll get an error."""
"legacy-uses-renamed-ancestor.mf")
"broken-renamed-ancestor-new.mf")
"self-depend-renamed-ancestor-new.mf")
# look for a rename that didn't ultimately resolve to the
# package that contained the legacy action
lint_msgs = []
if "pkglint.action005.1" not in msg:
"%s produced when linting broken renaming with legacy "
"pkgs" % lint_msgs)
for i in lint_logger.ids:
if i == "pkglint.manifest002.3":
if i == "pkglint.action003.4":
"Missing expected broken renaming legacy errors, "
"got %s" % lint_msgs)
# make sure we spot renames that depend upon themselves
lint_msgs = []
# if "pkglint.action005.1" not in msg:
"produced when linting broken self-dependent renaming with "
"legacy pkgs")
for i in lint_logger.ids:
if i == "pkglint.manifest002.4":
if i == "pkglint.action003.5":
"Missing expected broken renaming self-dependent errors "
"with legacy pkgs. Got %s" % lint_msgs)
def test_relative_path(self):
"""The engine can start with a relative path to its cache."""
"pkglintrc"))
def test_ref_file_move(self):
"""The dupaction checks can cope with a file that moves between
packages, where the old package was delivered in our reference
repository and we're linting both new packages: the package
from which the file was moved, as well as the package to which
the file is moving.
It should report an error when we only lint the new version
of the package to which the file is moving, but not the new
version of package from which the file was moved."""
# first check that file moves work properly, that is,
# we should report no errors here.
lint_msgs = []
# next check that when delivering only the moved-to package,
# we report a duplicate error.
lint_msgs = []
"error not seen when moving file between packages, but "
"Expected pkglint.dupaction001.1, got %s" %
def test_lint_fmri_successor(self):
"""lint_fmri_successor reports lint successors correctly.
The lint fmri_successor check has a biase for new FMRIs and
acts differently to the pkg.fmri.PkgFmri is_successor check,
favouring the new fmri if it is missing information not present
in the old fmri.
We also include some tests for the standard is_successor
check, which is used in the implementation of
lint_fmri_successor."""
class FmriPair():
def is_successor(pair):
"""baseline the standard fmri.is_successor check"""
"""test that new succeeds old and old succeeds new."""
ignore_pubs=ignore_pubs) and \
"""test that new succeeds old, but old does not succeed new"""
# messages used in assertions
fail_msg = "%s do not pass %s check"
fail_msg_pubs = "%s do not pass %s check, ignoring publishers"
fail_msg_ts = "%s do not pass %s check, ignoring timestamps"
# 1 identical everything
# 2 identical versions
# 3 identical names
# 4 differing timestamps, same version (identical, in pkglint's view)
# 5 missing timestamps, same version
# 6 missing timestamps, different version
# 7 different versions
# 8 different versions (where string comparisons won't work since
# with string comparisons, '0.133' < '0.99' which is not desired
"pkg://opensolaris.org/SUNWfcsm@0.5.11,5.11-0.99:20100216T065435Z")
# Now the same set of tests, this time with different publishers
# 1.1 identical everything
# 2.1 identical versions
# 3.1 identical names
# 4.1 differing timestamps, same version (identical, in pkglint's
# view unless we specifically look at the timestamp)
# 5.1 missing timestamps, same version
# 6.1 missing timestamps, different version
# 7.1 different versions
# 8.1 different versions (where string comparisons won't work
# with string comparisons, '0.133' < '0.99' which is not desired
# missing publishers
# different publishers
# different publishers, missing timestmap, same version
fail_newer_pubs % (pair))
# different publishers, missing timestmap
"Read a list of filenames, return a list of Manifest objects"
manifests = []
data = None
# borrowed code from publish.py
lines = [] # giant string of all input lines
linecnts = [] # tuples of starting line no., ending line no
try:
except IOError, e:
continue
try:
break;
else:
lineno = "???"
"Problem reading manifest %s line: %s: %s " %
continue
if "pkg.fmri" in manifest:
manifest["pkg.fmri"])
else:
"Manifest %s does not declare fmri." % filename,
"lint.manifest003")
return manifests
if __name__ == "__main__":