#
# 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
#
from . import testutils
if __name__ == "__main__":
import pkg5unittest
import os
import errno
import shutil
import unittest
pkg_A = """
open pkg_A@1.0,5.11-0
add file tmp/facets_4 mode=0555 owner=root group=bin path=4 facet.locale.fr_CA=True facet.locale.nl_ZA=True
add link path=test target=1
close"""
pkg_B1 = """
open pkg_B@1.0,5.11-0
close"""
pkg_B2 = """
open pkg_B@2.0,5.11-0
close"""
# All 'all's must be true AND any 'true's true.
pkg_top_level = """
open pkg_top_level@1.0,5.11-0
add file tmp/facets_3 mode=0555 owner=root group=bin path=top3 facet.doc=all facet.locale.fr_CA=true
add file tmp/facets_4 mode=0555 owner=root group=bin path=top4 facet.doc=all facet.locale.fr_CA=true facet.locale.nl_ZA=true
add file tmp/facets_5 mode=0555 owner=root group=bin path=top5 facet.devel=all facet.doc=all facet.locale.fr_CA=true facet.locale.nl_ZA=true
add file tmp/facets_6 mode=0555 owner=root group=bin path=top0.debug facet.devel=all facet.debug.top=all
add file tmp/facets_7 mode=0555 owner=root group=bin path=optional.doc facet.optional.doc=all facet.doc=true
add file tmp/facets_8 mode=0555 owner=root group=bin path=optional_fr.doc facet.optional.doc=all facet.doc=all facet.locale.fr_CA=true
close"""
misc_files = [
]
error = ""
try:
except AssertionError as e:
if error:
raise AssertionError(error)
"""Verify that the specified path exists. If negate is true,
then make sure the path doesn't exist"""
try:
except IOError as e:
return
# file is there
if negate:
return
# create an image w/ locales set
ic_args = "";
ic_args += " --facet 'facet.locale*=False' "
ic_args += " --facet 'facet.locale.fr*=True' "
ic_args += " --facet 'facet.locale.fr_CA=False' "
# install a package and verify
# make sure it delivers its files as appropriate
# Verify that effective value is shown for facets that are
# always implicity false such as debug / optional.
"facet.debug.top\tFalse\tsystem\n"
"facet.optional.doc\tFalse\tsystem\n",
)
# notice that a file should not exist according to its facet
# verify that a non-existent facet can be set when other facets
# are in effect
affect_packages=[],
# Again, but this time after removing the publisher cache data
# and as an unprivileged user to verify that cached manifest
# data doesn't affect operation.
"cache", "publisher")
affect_packages=[],
# Again, but this time after removing the cache directory
# entirely.
"cache")
affect_packages=[],
# change to pick up another file w/ two tags and test the
# parsable output
# remove all the facets
"'facet.locale.fr*'=None facet.locale.fr_CA=None")
False],
])
for i in range(8):
# zap all the locales
for i in range(8):
# Verify that effective value is shown for facets that are
# implicity false due to wildcards whether they're known to the
# system through packages or not.
"facet.locale.fr\tFalse\tlocal\n"
"facet.locale.nl_ZA\tFalse\tlocal\n",
)
# Verify that an action with multiple facets will be installed
# if at least one is implicitly true even when the first facet
# evaluated matches an explicit wildcard facet set to false.
# This test relies on Python iterating over the action
# attributes dictionary such that facet.locale.nl_ZA is
# evaluated first. (There's no way to influence that and the
# order seems 100% consistent for now.)
"'facet.locale.*=false' facet.locale.fr_CA=true");
])
# This test is merely here so that if the evaluation order is
# reversed for some reason that expected results are still seen.
"facet.locale.fr_*=false facet.locale.fr_CA=None");
False],
])
# Test that setting an unset, non-existent facet to None works.
# Test that setting a non-existent facet to True then removing
# it works.
# Test that setting a facet at the same time as removing a facet
# sees both as changing.
# First, install faceted package.
for i in range(9):
# Next, set general locale.*=False, but locale.fr=True.
# General 0 file, locale.fr file, and has slashes file should be
# there.
for i in (0, 1, 8):
# No other locale files should be present.
for i in (2, 3, 4, 5, 6, 7):
# Now set wombat=False and unset locale.fr.
"""Verify that non-facet related packaging operation don't
accidentally change facets."""
# create an image w/ two facets set.
ic_args = ""
ic_args += " --facet 'locale.fr=False' "
ic_args += " --facet 'locale.fr_FR=False' "
# install a random package and make sure we don't accidentally
# change facets.
expected = (
"facet.locale.fr\tFalse\tlocal\n"
"facet.locale.fr_FR\tFalse\tlocal\n")
for i in [ 0, 3, 4, 5, 6, 7 ]:
for i in [ 1, 2 ]:
# update an image and make sure we don't accidentally change
# facets.
expected = (
"facet.locale.fr\tFalse\tlocal\n"
"facet.locale.fr_FR\tFalse\tlocal\n")
for i in [ 0, 3, 4, 5, 6, 7 ]:
for i in [ 1, 2 ]:
"""Verify that resetting a Facet explicitly set to false
# create an image with pkg_A and no facets
for i in range(8):
# set a facet on an image with no facets
expected = (
"facet.locale.fr\tFalse\tlocal\n")
for i in [ 0, 2, 3, 4, 5, 6, 7 ]:
for i in [ 1 ]:
# set a facet on an image with existing facets
expected = (
"facet.locale.fr\tFalse\tlocal\n"
"facet.locale.fr_FR\tFalse\tlocal\n")
for i in [ 0, 3, 4, 5, 6, 7 ]:
for i in [ 1, 2 ]:
# clear a facet while setting a facet on an image with other
# facets that aren't being changed
expected = (
"facet.locale.fr_FR\tFalse\tlocal\n"
"facet.locale.nl\tFalse\tlocal\n")
for i in [ 0, 1, 3, 4, 6, 7 ]:
for i in [ 2, 5 ]:
# clear a facet on an image with other facets that aren't
# being changed
expected = (
"facet.locale.fr_FR\tFalse\tlocal\n")
for i in [ 0, 1, 3, 4, 5, 6, 7 ]:
for i in [ 2 ]:
# clear the only facet on an image
for i in range(8):
# verify debug content removed when debug facet reset
expected = (
"facet.debug.foo\tTrue\tlocal\n")
"""Verify that the 'all' value for facets is handled as
expected."""
("top0", True),
("top0.debug", False),
("top1", True),
("top2", True),
("top3", True),
("top4", True),
("top5", True),
("optional.doc", False),
("optional_fr.doc", False),
))
# All faceted files should be installed.
("top0", True),
("top0.debug", True),
("top1", True),
("top2", True),
("top3", True),
("top4", True),
("top5", True),
("optional.doc", True),
("optional_fr.doc", True),
))
# Only top0[.debug] should be installed.
("top0", True),
("top0.debug", True),
("top1", False),
("top2", False),
("top3", False),
("top4", False),
("top5", False),
("optional.doc", False),
("optional_fr.doc", False),
))
# No faceted files should be installed.
("top0", False),
("top0.debug", False),
("top1", False),
("top2", False),
("top3", False),
("top4", False),
("top5", False),
("optional.doc", False),
("optional_fr.doc", False),
))
# Only top1, top3, top4, optional.doc, and optional_fr.doc
# should be installed.
("top0", False),
("top0.debug", False),
("top1", True),
("top2", False),
("top3", True),
("top4", True),
("top5", False),
("optional.doc", True),
("optional_fr.doc", True),
))
# All faceted files should be installed.
("top0", True),
("top0.debug", True),
("top1", True),
("top2", True),
("top3", True),
("top4", True),
("top5", True),
("optional.doc", True),
("optional_fr.doc", True),
))
# Only top0[.debug], top1, top2, top4, top5, and optional.doc
# should be installed.
("top0", True),
("top0.debug", True),
("top1", True),
("top2", True),
("top3", False),
("top4", True),
("top5", True),
("optional.doc", True),
("optional_fr.doc", False),
))
# Only top0[.debug], top1, top2, and optional.doc should be
# installed.
("top0", True),
("top0.debug", True),
("top1", True),
("top2", True),
("top3", False),
("top4", False),
("top5", False),
("optional.doc", True),
("optional_fr.doc", False),
))
# are installed.
"locale.nl_ZA=None optional.doc=None debug.top=None")
("top0", True),
("top0.debug", False),
("top1", True),
("top2", True),
("top3", True),
("top4", True),
("top5", True),
("optional.doc", False),
("optional_fr.doc", False),
))
# Set a false wildcard for the 'devel' and 'doc' facets. No
# files should be installed.
"debug.*=true")
("top0", False),
("top0.debug", False),
("top1", False),
("top2", False),
("top3", False),
("top4", False),
("top5", False),
("optional.doc", False),
("optional_fr.doc", False),
))
# Set the devel facet True and the debug.top facet true and
# verify that explicit sets trump wildcard matching. Only
# top0[.debug] should be installed.
("top0", True),
("top0.debug", True),
("top1", False),
("top2", False),
("top3", False),
("top4", False),
("top5", False),
("optional.doc", False),
("optional_fr.doc", False),
))
"""Test that invalid facet names are handled appropriately"""
if __name__ == "__main__":