avocado.plugins: Simplify commands --xunit/--json.

Simplify commands for xUnit and JSON output plugins:

* Remove options --xunit-output and --json-output.
* Use '-' to stdout or filename to options --xunit and --json.

Usage examples:

$ avocado --xunit - run sleeptest  # goes to stdout
$ avocado --xunit /tmp/foo.xml run sleeptest
$ avocado --xunit - --json /tmp/foo.json run sleeptest.

Signed-off-by: Ruda Moura <rmoura@redhat.com>
Merge pull request #134 from ruda/simplify_cmd_options

avocado.plugins: Simplify commands --xunit/--json.
avocado.utils.process: Add new SubProcess API send_signal()

Add send_signal(), that lets us to send arbitrary signals
to subprocesses, and rewrite kill() and terminate() in
terms of it.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.core.exceptions: Introducing TestInterruptError

Add a special exception for when tests are interrupted
by Ctrl + C, and the required mapping in status.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.job: Properly handle Ctrl+C inside avocado

Handle KeyboardInterrupt inside avocado, making
Ctrl+C to terminate the program, instead of generating
a python backtrace.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Set 'INTERRUPTED' status for interrupted tests

If we press Ctrl+C, the test that was being executed
still does not have a status, and that reflects in the
job log with a None printed in the final status.

So, if there's no status yet, we should safely (?)
assume that the test was interrupted.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
selftests/functional: Add Ctrl+C behavior test

Run avocado in a long test, interrupt it and verify if
the runner displays the appropriate behavior, in terms
of exit code and output.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado: Simplify human output messages

We can aim for a more terse output than what we have
today. This is my proposal to simplify things a bit,
while still being clear.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado: Rename job output dir

We used 'run' as a prefix for avocado job output directories
after virt-test (basically, inertia). Let's use something
better:

job-[first 8 characters of job id]-timestamp

This way the job id starts to be more prominent in the
human interface as well.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado: Refer to 'debug log' as 'job log'

Instead of using 'debug log' we can use 'job log', as it
is a human readable log of the job execution.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado: Change job results dir from 'logs' to 'job-results'

Another change to clarify the purpose of each directory.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado: Make job ID more prominent in avocado

Make some changes to bring the concept of job ID as a
user visible information:

* Make the human output to display the job ID
* Make the json output to have the job ID
* Record the job id in a file inside the results dir

Adapt functional tests to that new schema.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.core.data_dir: Changes in data dir format

Try as much as possible to turn timestamps into the
ISO format. In fact, iso requires hours and minutes
to be separated by a ':', but that makes URLs far
less convenient, requiring escape characters. So
let's replace it with a dot.

Also, put the short ID after the date, so date sort
can be properly done.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.job: Reduce the polling time to 0.01s

This is a workaround for the functional suite running
slow, until there's a more proper solution.

Reduce the polling time from 1 second to 0.01 second,
so short lived tests end quicker.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.core: Introduce job_id library

Separate the code that generates a job SHA1 on its own
library. It'll make things easier for unittesting and other
needs.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado: Use new job ID instead of UUID

Use a job ID that is a SHA1, similar to git, instead
of the UUID. Also, use the first 7 characters of the
job ID in the directory structure, to mirror the git
short SHA1 identifier.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
docs: Update avocado install instructions

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
docs: Updates with new avocado output and results structure

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado: Omit tag on first instance, reproduce test dir structure

Instead of starting tags at 1 and compulsorily putting
them on tests (even if it is the 1st execution of the test),
start with 0 and omit it if it is only the first test.

Also, reproduce the directory structure of tests in the
logs directory. This means that a test execution of

mydir/firstlevel.py
mydir/category/secondlevel.py

Would translate in the final directory results as:

mydir/firstlevel.py/
mydir/category/secondlevel.py/

Preserving the directory structure makes things more
consistent and intuitive, while preserving a unique
test ID.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.job.py: Change test name resolution

So avocado can correctly find data files for a test that
is referenced by its alias.

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