virt: aexpect support parallel unittesting

* Allow server's BASE_DIR to be set by caller.
  (allows sequestration of unittest test data)

* Allow Spawn class to alter server's
  BASE_DIR (supports unittesting)

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: aexpect code cleanup

* aexpect should timeout instead of busy-wait
* aexpect should log server activity
* Make server reader & buffer handling match client
* Remove empty string from reader list
* Move aexpect server code into a function
* Move file cleanup into client close() method
virt: fix aexpect bug server inheriting client fds

On the line prior, the client uses _lock() which opens
a file descriptor.  The server was inheriting this open
fd via the subprocess.POpen() call.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: Fix aexpect bug client loosing stdin/out fds

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: Add aexpect unittests

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: aexpect be obvious when not using fds

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: Move aexpect.Tail tail_thread attribute def

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: aexpect server should log exceptions

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: more aexpect unittests

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: aexpect needn't only reference fd integers

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: aexpect should validate parameters

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: aexpect.Spawn should hold base_dir private

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: aexpect.Spawn use  _open_reader_fds() method

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: aexpect.Spawn can be new-style + pickle

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: aexpect.Spawn should use os.open() less

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: Update aexpect.Tail + new unittests

* Protect shared attributes with a lock
* Provide for instance-level thread-exit condition
* _start_thread shouldn't assume not yet started
* Added some basic Tail unittests

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: aexpect Spawn non-blocking readline()

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: Fix aexpect pickling & add unittests

* There's no reason for sub.stdin/stdout to remain open after
  Spawn.__init__(), so we just close them.
* Spawn.close() is now waits for the server to exit before
  cleaning files.  Otherwise it could clean, then new ones
  could still be written.
* Fixed up new-style pickle-support methods
* Added basic pickle test for Spawn class

Signed-off-by: Chris Evich <cevich@redhat.com>
squash! virt: Fix aexpect pickling & add unittests

Signed-off-by: Chris Evich <cevich@redhat.com>