Ejemplo n.º 1
0
    def test_cpu_dependency(self):
        """test origin cpu dependency
                cpu test simulator uses alphabetic comparison"""

        if portable.osname != "sunos":
            raise pkg5unittest.TestSkippedException(
                "cpu check unsupported on this platform.")

        rurl = self.dc.get_repo_url()
        plist = self.pkgsend_bulk(rurl, self.pkg_list)
        self.image_create(rurl)
        os.environ["PKG_INSTALLED_VERSION"] = "hoopsnake"
        # trim some of the versions out; note that pkgs w/ cpu
        # errors/problems are silently ignored.
        self.pkg("install -v [email protected] [email protected]")
        self.pkg("list -v")
        os.environ["PKG_INSTALLED_VERSION"] = "dropbear"
        self.pkg("install [email protected]", 1)
        # exercise general error codes
        self.pkg("install [email protected]", 1)
        # verify that upreving the cpu lets us install more
        self.pkg("list")
        os.environ["PKG_INSTALLED_VERSION"] = "coolabah"
        self.pkg("update *@latest")
        self.pkg("list")
        self.pkg("verify [email protected]", 1)
        del os.environ["PKG_INSTALLED_VERSION"]
        self.pkg("list")
        # this is a trick, there is no v1.6
        self.pkg("verify [email protected]", 1)
        # check that we ignore dependencies w/ missing enumerators
        self.pkg("install [email protected]")
        self.pkg("list")
Ejemplo n.º 2
0
    def setUp(self):
        if portable.osname != "sunos":
            raise pkg5unittest.TestSkippedException(
                "System attributes unsupported on this platform.")

        self.test_path = tempfile.mkdtemp(prefix="test-suite", dir="/var/tmp")
        self.test_fh, self.test_fn = tempfile.mkstemp(dir=self.test_path)
Ejemplo n.º 3
0
    def test_help_character_encoding(self):
        """Verify help command output for ja_JP.eucJP locale.
                Match against the expected output"""

        # This is a test case for CR 7166082.
        # It compares the output of "pkg --help" command against
        # the expected output for ja_JP.eucJP locale.
        # If first 4 lines of "pkg --help" command output modified
        # in the future then this test case will also need to be
        # modified.

        ret, out = self.cmdline_run("/usr/bin/locale -a",
                                    out=True,
                                    coverage=False)
        line = " ".join(out.split())
        m = re.search(r"ja_JP.eucJP", line)
        if not m:
            raise pkg5unittest.TestSkippedException(
                "The "
                "test system must have the ja_JP.eucJP locale "
                "installed to run this test.")

        eucJP_encode_file = os.path.join(self.ro_data_root,
                                         "pkg.help.eucJP.expected.out")
        f = codecs.open(eucJP_encode_file, encoding="eucJP")

        locale_env = {"LC_ALL": "ja_JP.eucJP"}
        ret, out, err = self.pkg("help -v",
                                 env_arg=locale_env,
                                 out=True,
                                 stderr=True)
        cmd_out = unicode(err, encoding="eucJP")
        # Take only 4 lines from "pkg --help" command output.
        u_out = cmd_out.splitlines()[:4]

        n = 0
        # The expected output file contain 4 lines and command output
        # is also 4 lines.
        while n < 4:
            cmd_line = u_out[n]
            # Remove \n from readline()
            file_line = f.readline()[:-1]

            self.assertEqual(cmd_line, file_line)
            n = n + 1

        f.close()
Ejemplo n.º 4
0
    def test_fw_dependency(self):
        """test origin firmware dependency"""
        """firmware test simulator uses alphabetic comparison"""

        if portable.osname != "sunos":
            raise pkg5unittest.TestSkippedException(
                "Firmware check unsupported on this platform.")

        rurl = self.dc.get_repo_url()
        plist = self.pkgsend_bulk(rurl, self.pkg_list)
        self.image_create(rurl)

        os.environ["PKG_INSTALLED_VERSION"] = "elf"
        # trim some of the versions out; note that pkgs w/ firmware
        # errors/problems are silently ignored.
        self.pkg("install A B")
        self.pkg("list")
        self.pkg("verify [email protected]")
        # test verify by changing device version
        os.environ["PKG_INSTALLED_VERSION"] = "dwarf"
        self.pkg("verify [email protected]", 1)
        os.environ["PKG_INSTALLED_VERSION"] = "elf"
        # exercise large number of devices code
        os.environ["PKG_NUM_FAKE_DEVICES"] = "500"
        self.pkg("install [email protected]", 1)
        # exercise general error codes
        self.pkg("install [email protected]", 1)
        self.pkg("install [email protected]", 1)
        # verify that upreving the firmware lets us install more
        os.environ["PKG_INSTALLED_VERSION"] = "hobbit"
        self.pkg("update")
        self.pkg("verify [email protected]")
        # simulate removing device
        del os.environ["PKG_INSTALLED_VERSION"]
        self.pkg("update")
        self.pkg("list")
        self.pkg("verify [email protected]")
        # ok since we never drop core
        # here as device
        # doesn't exist.

        # check that we ignore dependencies w/ missing enumerators for now
        self.pkg("install [email protected]")
Ejemplo n.º 5
0
    def test_sysattrs(self):
        """Test that system attributes are verified correctly."""

        if portable.osname != "sunos":
            raise pkg5unittest.TestSkippedException(
                "System attributes unsupported on this platform.")

        self.pkgsend_bulk(self.rurl, [self.sysattr, self.sysattr2])

        # Need to create an image in /var/tmp since sysattrs don't work
        # in tmpfs.
        old_img_path = self.img_path()
        self.set_img_path(tempfile.mkdtemp(prefix="test-suite",
                                           dir="/var/tmp"))

        self.image_create(self.rurl)
        self.pkg("install sysattr sysattr2")
        self.pkg("verify")
        fpath = os.path.join(self.img_path(), "p1/bobcat")

        # Need to get creative here to remove the system attributes
        # since you need the sys_linkdir privilege which we don't have:
        # see run.py:393
        # So we re-create the file with correct owner and mode and the
        # only thing missing are the sysattrs.
        portable.remove(fpath)
        portable.copyfile(os.path.join(self.test_root, "bobcat"), fpath)
        os.chmod(fpath, 0o555)
        os.chown(fpath, -1, 2)
        self.pkg("verify", exit=1)
        for sattr in ('H', 'S'):
            expected = "System attribute '{0}' not set".format(sattr)
            self.assertTrue(expected in self.output,
                            "Missing in verify output:  {0}".format(expected))

        shutil.rmtree(self.img_path())
        self.set_img_path(old_img_path)