standalone_test: unset log level on root logger when

Other modules may have messed with the root logger already, so if we
don't reset the root logger log level, messages go through the logger
even after we add the console and file handlers later.

This problem wasn't visible before because an autotest module was
unconditionally setting the root logger log level to DEBUG, but a recent
patch I sent to autotest removes that unconditional logging setup code.

This patch also renames configure_logging() to reset_logging(), as it
doesn't configure any handler, but just remove the existing logging
configuration).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
./run: make stdout redirect/restore API simpler

Today, if _restore_stdout() is called twice, stdout gets silenced again.
Instead of having API that requires the caller to remember what's the
internal state of the object to know what will happen, we can simply
have two separate methods to redirect and restore stdout.

The main problem with the current approach is that it makes it very
difficult to gradually disable the hack in various parts of the code[1],
as changing the moment we silence/restore stdout could break existing
parts of the code that calls the switch() method assuming stdout is
already silenced.

[1] In a perfect world we wouldn't need any stdout hacking at all, we
    would just need to ask the test runner and autotest to be more
    silent. But to achieve that, we need to do it gradually (e.g. trying
    to disable stdout/stderr only when actually running the tests, not
    when parsing configs or loading modules)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
bootstrap.py: fix log message formatting

The arguments for logging.info are the format string parameters
themselves, not a tuple. This was causing logging error tracebacks on my
tests.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
run: List all test types in --help output

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
./run: use imp module for AUTOTEST_PATH setup

Instead of hacking sys.path, just use the Python imp module to load the
module using the full path.

Also change the check for AUTOTEST_PATH to not rely on Exception
handling for flow control.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
./run: print clearer error message if AUTOTEST_PATH doesn't work

Error message before:

  $ ./run
  Traceback (most recent call last):
    File "./run", line 558, in <module>
      app = VirtTestApp()
    File "./run", line 271, in __init__
      self.option_parser = VirtTestRunParser()
    File "./run", line 151, in __init__
      _import_autotest_modules()
    File "./run", line 106, in _import_autotest_modules
      setup_modules_path)
  IOError: [Errno 2] No such file or directory
  $

Error message after:

  $ ./run
  Failed to import autotest modules from $AUTOTEST_PATH
  Could not load Python module /home/ehabkost/pessoal/proj/virt/autotestx/client/setup_modules.py
  $

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
./run: isolate initialization code that affects the whole process

The new system_setup() function will be used for the stuff that affects
the whole Python interpreter.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
./run: give AUTOTEST_PATH precedence over sys.path

If AUTOTEST_PATH is set, try to use it instead of the autotest modules
in sys.path.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
./run: try to import autotest modules at the very beginning

The _import_autotest_modules() function doesn't need to be called
multiple times, and calling it as early as possible will allow us to use
some autotest modules very early.

This also adds a workaround to an Autotest bug in some versions where it
enables debug logging as soon as the modules are imported.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
run: Get rid of the last places using standalone_test.print_stdout

Now the appropriate path is to call _restore_stdout() and
then use simple prints, rather than importing standalone_test
and then use print_stdout.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
run: Fix typo

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>