t_plat.py revision 402
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch# CDDL HEADER START
4219de12b28f1936219e27501b9c4b27a4f8d53cStephan Bosch# The contents of this file are subject to the terms of the
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch# Common Development and Distribution License (the "License").
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch# You may not use this file except in compliance with the License.
5a37824675033747fcae3fe3fc3c0dd7ef0ca1cdStephan Bosch# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
5a37824675033747fcae3fe3fc3c0dd7ef0ca1cdStephan Bosch# See the License for the specific language governing permissions
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch# and limitations under the License.
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch# When distributing Covered Code, include this CDDL HEADER in each
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
5257840e8d31a6cb7051703b4cb0931c82aba638Stephan Bosch# If applicable, add the following below this CDDL HEADER, with the
5257840e8d31a6cb7051703b4cb0931c82aba638Stephan Bosch# fields enclosed by brackets "[]" replaced with your own identifying
fe2b0e3de834dd40b698bb579adc5357d5789ec9Stephan Bosch# information: Portions Copyright [yyyy] [name of copyright owner]
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch# CDDL HEADER END
5a37824675033747fcae3fe3fc3c0dd7ef0ca1cdStephan Bosch# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5a37824675033747fcae3fe3fc3c0dd7ef0ca1cdStephan Bosch# Use is subject to license terms.
ede750711f27ca9d9037a7ab9f016411b57f1ad9Stephan Bosch self.assertRaises(KeyError, portable.get_group_by_name,
a62fe4b300e2f591e939993aec4cac1e7ae30ad1Stephan Bosch self.assertRaises(KeyError, portable.get_name_by_gid,
ede750711f27ca9d9037a7ab9f016411b57f1ad9Stephan Bosch self.assertRaises(KeyError, portable.get_user_by_name,
ede750711f27ca9d9037a7ab9f016411b57f1ad9Stephan Bosch self.assertRaises(KeyError, portable.get_name_by_uid,
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch self.assertNotEqual("unknown", util.get_canonical_os_type())
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch self.assertNotEqual("unknown", util.get_canonical_os_name())
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch # make sure it can be used in an fmri
a991cfe2157e58ee43bc580f517ce9ef0dfb7acfStephan Bosch test_fmri = fmri.PkgFmri("testpkg", build_release = rel)
4219de12b28f1936219e27501b9c4b27a4f8d53cStephan Bosch # rename a file on top of another file which already exists
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch exefilesrc = 'C:\\Windows\\system32\\more.com'
31fa529029f35f65451fb1d119ed1d5435b62e46Timo Sirainen # create an image, copy an executable into it,
31fa529029f35f65451fb1d119ed1d5435b62e46Timo Sirainen # run the executable, replace the executable
93cc87bb22386e020cee1093b6bd59295e0b33f0Stephan Bosch img1.set_attrs(image.IMG_USER, tdir1, False, "test",
6bc9fb43cc1ac24693d030a6cbfa43bc7cbc82cbTimo Sirainen proc = subprocess.Popen([exefile], stdin = subprocess.PIPE)
6bc9fb43cc1ac24693d030a6cbfa43bc7cbc82cbTimo Sirainen self.assertRaises(OSError, os.unlink, exefile)
30f35cf5d1e1374d7fab4231e86144fc106a8e79Stephan Bosch # Make sure that the moved executable gets deleted
87c121a4c05b9cee46f1f757ec6999d441519abfStephan Bosch # First do a rename in another image
8aa91c0f70ea2893d82a16a8b8d0171caccce74cStephan Bosch img2.set_attrs(image.IMG_USER, tdir2, False, "test",
e1d8d185fa74752ba6807e415a9c82ebfdb2082cStephan Bosch portable.rename(path2, os.path.join(tdir2, "bar"))
65c0e43da8cfc730eeb4634f8aa384081bbfa4e7Timo Sirainen # Now do another rename in the original image
eb325a5a90c1d2655e74972bde0de6a699d2c864Stephan Bosch # This should cause the executable to deleted from the trash
7384b4e78eaab44693c985192276e31322155e32Stephan Bosch portable.rename(exefile, os.path.join(tdir1, "foo"))