subtests.docker_cli.top: Regexp and IndexError fix

This patch fixes the IndexError issue and corrects the
ps regexp. Additionally it fixes some pep8 fixes.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
subtests...dockerimport: Docker command bugfix

Sub-subtest incorrectly assumed string conversion was
equivalent to the command property.

Signed-off-by: Chris Evich <cevich@redhat.com>
Merge pull request #161 from ldoktor/top

subtests.docker_cli.top: Regexp and IndexError fix
dockertest.dockercmd: cmdresult property

Hide the underlying behavior of execute() by trying to
returning a fresh cmdresult value when possible, instead
of possibly a reference.  Do the same thing for __str__
so that the most current, detailed info is always available.

For the AsyncDockerCmd class, make the cmdresult attribute
into a property that always contains current stdout/stderr and
exit_status.  Deprecated update_result() method since it's now
covered by cmdresult property.  Updated unittests to match changes.

Add new sub/sub-subtest methods ``log_xn()`` to facilitate printing
multi-line messages where look-n-feel are important.  i.e. allow
debug output to go out w/o any further mangling.

Signed-off-by: Chris Evich <cevich@redhat.com>
dockertest.subtest: Combine common elements

Several dockertest modules would benefit from access to a
standardized interface for common-elements between the
Subtest and SubSubtest classes.  Combine those elements
in a new ``SubBase`` class.

Use multi-inheritance to guarantee the ``autotest.client``
test.test class interface is preserved.  With this change,
anything formerly accessing a ``Subtest`` instance for it's
``config`` and ``log*()`` methods, can now depend on
the ``Subbase`` interface being provided for
sub-subtests also.
dockertest.dockercmd: Accept SubBase instances

Allows DockerCmdBase subclasses to work with both
subtests and sub-subtests via the common SubBase
interface.  This helps keep debug/logging messages
at the right level of indentation, making it easier
to tell where various commands came from.

Signed-off-by: Chris Evich <cevich@redhat.com>
subtests...various: Pass sub-subtest to DockerCmd

Helps execution log messages appear next to the right
sub-subtest name prefix.

Signed-off-by: Chris Evich <cevich@redhat.com>
Merge pull request #145 from cevich/dockercmd_update

dockertest.dockercmd: cmdresult property
dockertest.dexpect: Simplified version of aexpect

This patch adds simplified version of aexpect (pexpect) which
implements basic routines to interact with shell-like processes.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
dockertest.subtest: Add support for autologging in cleanup

This patch adds (Sub)Subtest.log_in_cleanup = {}, which in case it's
non-empty is logged during cleanup as self.logwarning(). It's intended
for objects, which are useful for debugging unexpected exceptions.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
dockertest.dexpect: Add support for storing log records

This patch adds special method of logging, which just stores each
record and returns the complete log when Expect.get_log_records()
is called.

You can reset the log by calling Expect.set_logging(dexpect.STORE).

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
subtests.docker_cli.detach: New detach test

This test utilize the ctrl+p ctrl+q to detach from container.
There are 3 subtests, each focused on different part. Currently
it uses time.sleep(1) to workaround known bug but once the bug
is fixed these sleeps should be removed.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>