#
# 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 unittest
import os
bronze10 = """
open bronze@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=/usr
add license tmp/copyright1 license=copyright
close
"""
nopathA10 = """
open nopathA@1.0,5.11-0
add license tmp/copyright1 license=copyright
close
"""
nopathB10 = """
open nopathB@1.0,5.11-0
add license tmp/copyright1 license=copyright
close
"""
# wire file contents to well known values so we're sure we
# know their hashes.
misc_files = {
"tmp/copyright1": "magic5",
}
"""Verify that contents handles bad options as expected."""
"""Verify that when -t is specified without -o, the default
attributes vary to match."""
"""local pkg contents should fail in an empty image; remote
should succeed on a match """
"""get contents"""
"""test that local and remote contents are the same"""
x = "".join(x)
x = self.reduceSpaces(x)
y = "".join(y)
y = self.reduceSpaces(y)
self.assertEqualDiff(x, y)
""" test matching """
""" attempt to get contents of non-existent packages """
"""Test the -a option of contents"""
# Basic -a
"422bdb3eb2d613367933194e3f11220aebe56226")
# -a with a pattern
"02cdf31d12ccfb6d35e4b8eeff10535e22da3f7e",
"b14e4cdfee720f1eab645bcbfb76eca153301715"])
# Multiple -a
"-a mode=0555")
"02cdf31d12ccfb6d35e4b8eeff10535e22da3f7e",
"422bdb3eb2d613367933194e3f11220aebe56226"])
# Non-matching pattern should exit 1
"""Test the -o option of contents. When pkg contents doesn't
find any actions that match the specified output columns, we
produce appropriate error messages."""
# Test that the build_release is dropped from version string of
# pkg FMRIS for the special case '-o pkg.fmri'.(Bug 17659776)"""
# part of the messages that result in running pkg contents
# when no output would result. Note that pkg still returns 0
# at present in these cases.
# XXX Checking for a substring of an error message in a test case
# isn't ideal.
nopath = "This package delivers no filesystem content"
nopath_plural = "These packages deliver no filesystem content"
nofield = "This package contains no actions with the fields specified " \
"using the -o"
nofield_plural = "These packages contain no actions with the fields " \
"specified using the -o"
"""Test that when multiple manifests are given and -m is used,
their contents aren't comingled."""
expected_res = reduce(lambda x, y: x + y,
[
], "")
"""Verify that pkg contents -r returns expected results
when multiple publishers provide the same package based
on publisher search order."""
# Create an isolated repository for this test
# Create a test image.
# Test should be higher ranked than test2 since the default
# for auto-configuration is to use lexical order when
# multiple publishers are found. As such, info -r should
# return results for 'test' by default.
# Verify that if the publisher is specified, that is preferred
# over rank.
# Verify that if stem is specified with and without publisher,
# both matches are listed if the higher-ranked publisher differs
# from the publisher specified.
"bronze")
"bronze")
"""A separate test class is needed because these tests modify packages
after they've been published and need to avoid corrupting packages for
other tests."""
# Tests in this suite use the read only data directory.
nopathA10 = """
open nopathA@1.0,5.11-0
add license tmp/copyright1 license=copyright
close
"""
"""Test that if an installed manifest has changed in the
repository the original manifest is used for pkg contents and
contents -r."""
# Specify location as filesystem path.
"""Test that if an uninstalled manifest has changed in the
repository but is cached locally, that the changed manifest is
reflected in contents -r."""
# Specify location as filesystem path.
if __name__ == "__main__":