2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# CDDL HEADER START
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# The contents of this file are subject to the terms of the
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# Common Development and Distribution License (the "License").
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# You may not use this file except in compliance with the License.
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# See the License for the specific language governing permissions
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# and limitations under the License.
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# When distributing Covered Code, include this CDDL HEADER in each
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# If applicable, add the following below this CDDL HEADER, with the
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# fields enclosed by brackets "[]" replaced with your own identifying
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# information: Portions Copyright [yyyy] [name of copyright owner]
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# CDDL HEADER END
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenclass TestPkgCollidingLinks(pkg5unittest.SingleDepotTestCase):
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # Only start/stop the depot once (instead of for every test)
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen open pkg_A@1.0,5.11-0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add file tmp/link_target_0 mode=0555 owner=root group=bin path=link_target_0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add file tmp/link_target_1 mode=0555 owner=root group=bin path=link_target_1
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add file tmp/link_target_2 mode=0555 owner=root group=bin path=link_target_2
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen open pkg_B@1.0,5.11-0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add link path=0 target=./link_target_0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add link path=1 target=./link_target_1
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add link path=2 target=./link_target_2
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen open pkg_C@1.0,5.11-0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add link path=0 target=./link_target_0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add link path=1 target=./link_target_1
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add link path=/2 target=./link_target_2
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen misc_files = [p for p in pkg_A.split() if "tmp/link_target" in p]
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen self.pkgsend_bulk(self.rurl, (self.pkg_A, self.pkg_B,
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen """Verify symlinks are correctly reference counted
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen during installation & removal of packages"""
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # create an image
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # install packages and verify
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # add a pkg w/ duplicate links
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # cause trouble.
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # readd a pkg w/ duplicate links
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenclass TestPkgCollidingHardLinks(pkg5unittest.SingleDepotTestCase):
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # Only start/stop the depot once (instead of for every test)
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen open pkg_A@1.0,5.11-0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add file tmp/link_target_0 mode=0555 owner=root group=bin path=link_target_0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add file tmp/link_target_1 mode=0555 owner=root group=bin path=link_target_1
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add file tmp/link_target_2 mode=0555 owner=root group=bin path=link_target_2
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen open pkg_A@2.0,5.11-0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add file tmp/link_target_3 mode=0555 owner=root group=bin path=link_target_0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add file tmp/link_target_4 mode=0555 owner=root group=bin path=link_target_1
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add file tmp/link_target_5 mode=0555 owner=root group=bin path=link_target_2
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen open pkg_B@1.0,5.11-0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add hardlink path=0 target=./link_target_0
b0be0bead3d6963149f7f2a9504b8ab5aced9af5Timo Sirainen add hardlink path=1 target=./link_target_1
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add hardlink path=2 target=./link_target_2
b0be0bead3d6963149f7f2a9504b8ab5aced9af5Timo Sirainen add depend type=require fmri=pkg_A@1.0,5.11-0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen open pkg_C@1.0,5.11-0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add hardlink path=0 target=./link_target_0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add hardlink path=1 target=./link_target_1
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add hardlink path=2 target=./link_target_2
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add depend type=require fmri=pkg_A@1.0,5.11-0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen misc_files = [p for p in pkg_A.split() if "tmp/link_target" in p]
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen self.pkgsend_bulk(self.rurl, (self.pkg_A, self.pkg_B,
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen """ Make sure link count is what we think it should be"""
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen for f in ("link_target_{0:d}".format(i) for i in range(3)):
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen self.assertEqual(os.stat(os.path.join(self.get_img_path(),
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen """Verify hardlinks are correctly reference counted
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen during installation & removal of packages"""
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # create an image
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # install packages and verify
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # add a pkg w/ duplicate links
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # cause trouble.
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # readd a pkg w/ duplicate links
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # update the files the links all point to