GetStartedGuide.rst 2.8 KB
Newer Older
1 2
.. _get-started:

3
=============================
4 5 6 7 8 9 10 11 12
Getting started guide - users
=============================

If you want to simply use avocado as a test runner/test API, you can install a distro package. For Ubuntu, you can look at `lmr's autotest PPA`_, while for Fedora, you can look at `lmr's autotest COPR`_.

.. _lmr's autotest PPA: https://launchpad.net/~lmr/+archive/autotest
.. _lmr's autotest COPR: http://copr.fedoraproject.org/coprs/lmr/Autotest

Installing avocado - Ubuntu
13
---------------------------
14 15 16 17 18 19 20 21 22 23 24

You can install the debian package by performing the following commands:

::

    sudo add-apt-repository ppa:lmr/autotest
    sudo apt-get update
    sudo apt-get install avocado


Installing avocado - Fedora
25
---------------------------
26 27 28 29 30 31 32

You can install the rpm package by performing the following commands:

::

    sudo curl http://copr.fedoraproject.org/coprs/lmr/Autotest/repo/fedora-20-i386/ > /etc/yum.repos.d/autotest.repo
    sudo yum update
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
    sudo yum install avocado


Running the avocado test runner
-------------------------------

The test runner is designed to conveniently run tests on your laptop. The tests
you can run are:

* Tests written in python, using the avocado API, which we'll call `native`.
* Any executable in your box, really. The criteria for PASS/FAIL is the return
  code of the executable. If it returns 0, the test PASSed, if it returned
  != 0, it FAILed. We'll call those tests `dropin`.

Avocado looks for avocado "native" tests in some locations, the main one is in
the config file ``/etc/avocado/settings.ini``, section ``runner``, ``test_dir``
key. You can list tests by::

    $ avocado list
    Tests available:
        failtest
        sleeptest
        synctest

You can run them using the subcommand ``run``::

    $ scripts/avocado run sleeptest
    DEBUG LOG: /home/lmr/Code/avocado/logs/run-2014-04-23-19.06.39/debug.log
    TOTAL TESTS: 1
    (1/1) sleeptest.1:  PASS (1.09 s)
    TOTAL PASSED: 1
    TOTAL ERROR: 0
    TOTAL FAILED: 0
    TOTAL SKIPPED: 0
    TOTAL WARNED: 0
    ELAPSED TIME: 1.09 s

You can run any number of test in an arbitrary order, as well as mix and match
native tests and dropin tests::

    $ echo '#!/bin/bash' > /tmp/script_that_passes.sh
    $ echo 'true' >> /tmp/script_that_passes.sh
    $ scripts/avocado run "failtest sleeptest synctest failtest synctest /tmp/script_that_passes.sh"
    DEBUG LOG: /home/lmr/Code/avocado/logs/run-2014-04-23-19.16.46/debug.log
    TOTAL TESTS: 6
    (1/6) failtest.1:  FAIL (0.09 s)
    (2/6) sleeptest.1:  PASS (1.09 s)
    (3/6) synctest.1:  PASS (2.33 s)
    (4/6) failtest.2:  FAIL (0.10 s)
    (5/6) synctest.2:  PASS (1.94 s)
    (6/6) script_that_passes.1:  PASS (0.11 s)
    TOTAL PASSED: 4
    TOTAL ERROR: 0
    TOTAL FAILED: 2
    TOTAL SKIPPED: 0
    TOTAL WARNED: 0
    ELAPSED TIME: 5.67 s