Пример #1
0
    def run_cmd(self, argv, rpcs=[], exit_code=None,
                out_words_ok=[], out_words_no=[],
                err_words_ok=[], err_words_no=[]):
        """Runs the command in argv.
        rpcs is a list of tuples, each representing one RPC:
             (op, **dargs, success, expected)
        exit_code should be set if you expect the command
        to fail
        The words are lists of words that are expected"""
        sys.argv = argv

        self.mock_rpcs(rpcs)

        if not (CLI_USING_PDB and CLI_UT_DEBUG):
            self.god.mock_io()
        if exit_code is not None:
            sys.exit.expect_call(exit_code).and_raises(ExitException)
            self.assertRaises(ExitException, atest.main)
        else:
            atest.main()
        (out, err) = self.god.unmock_io()
        self.god.check_playback()
        self._check_output(out, out_words_ok, out_words_no,
                           err, err_words_ok, err_words_no)
        return (out, err)
Пример #2
0
    def run_cmd(self, argv, rpcs=[], exit_code=None,
                out_words_ok=[], out_words_no=[],
                err_words_ok=[], err_words_no=[]):
        """Runs the command in argv.
        rpcs is a list of tuples, each representing one RPC:
             (op, **dargs, success, expected)
        exit_code should be set if you expect the command
        to fail
        The words are lists of words that are expected"""
        sys.argv = argv

        self.mock_rpcs(rpcs)

        if not (CLI_USING_PDB and CLI_UT_DEBUG):
            self.god.mock_io()
        if exit_code is not None:
            sys.exit.expect_call(exit_code).and_raises(ExitException)
            self.assertRaises(ExitException, atest.main)
        else:
            atest.main()
        (out, err) = self.god.unmock_io()
        self.god.check_playback()
        self._check_output(out, out_words_ok, out_words_no,
                           err, err_words_ok, err_words_no)
        return (out, err)
Пример #3
0
    def run_cmd(self, argv, rpcs=[], exit_code=None,
                out_words_ok=[], out_words_no=[],
                err_words_ok=[], err_words_no=[]):
        """Run an atest command with arguments.

        An empty list for out_words_ok or err_words_ok means that the stdout
        or stderr (respectively) must be empty.

        @param argv: List of command and arguments as strings.
        @param rpcs: List of rpcs to expect the command to perform.
        @param exit_code: Expected exit code of the command (if not 0).
        @param out_words_ok: List of strings to expect in stdout.
        @param out_words_no: List of strings that must not be in stdout.
        @param err_words_ok: List of strings to expect in stderr.
        @param err_words_no: List of strings that must not be in stderr.

        @raises: AssertionError or CheckPlaybackError.

        @returns: stdout, stderr
        """
        sys.argv = argv

        self.mock_rpcs(rpcs)

        if not (CLI_USING_PDB and CLI_UT_DEBUG):
            self.god.mock_io()
        if exit_code is not None:
            sys.exit.expect_call(exit_code).and_raises(ExitException)
            self.assertRaises(ExitException, atest.main)
        else:
            atest.main()
        (out, err) = self.god.unmock_io()
        self.god.check_playback()
        self._check_output(out, out_words_ok, out_words_no,
                           err, err_words_ok, err_words_no)
        return (out, err)
Пример #4
0
#!/usr/bin/python -u
import os
import sys

import common

_AUTOTEST_ROOT = os.path.realpath(os.path.join(__file__, '..', '..'))
_CHROMIUMOS_ROOT = os.path.abspath(
    os.path.join(_AUTOTEST_ROOT, '..', '..', '..', '..'))
_SKYLAB_INVENTORY_DIR = os.path.join(_CHROMIUMOS_ROOT, 'infra',
                                     'skylab_inventory', 'venv')
# In any sane chromiumos checkout
sys.path.append(_SKYLAB_INVENTORY_DIR)
# TODO: Where is this checked out on infra servers?

try:
    import skylab_inventory  # pylint: disable=unused-import
except ImportError as e:
    raise Exception(
        'Error when importing skylab_inventory (venv dir: %s): %s' %
        (_SKYLAB_INVENTORY_DIR, e))

# Import atest after 'import skylab_inventory' as it uses skylab_inventory
from autotest_lib.cli import atest

sys.exit(atest.main())