~jamesodhunt/upstart/handle-no-home-var

« back to all changes in this revision

Viewing changes to README.tests

  • Committer: James Hunt
  • Date: 2013-08-06 16:54:28 UTC
  • mto: This revision was merged to the branch mainline in revision 1518.
  • Revision ID: james.hunt@ubuntu.com-20130806165428-erp6u1kigm0znd1n
* README.tests: Explanation of the tests and how to run them.
* Makefile.am: Ensure README.tests gets distributed.
* scripts/tests/__init__.py: Empty file to allow python3's unittest
  module to auto-discover tests.
* scripts/Makefile.am: Ensure __init__.py gets distributed.
* scripts/tests/test_pyupstart_session_init.py: TestSessionUpstart.setUp():
  Created XDG_RUNTIME_DIR if necessary (for example if running as root).
* scripts/tests/test_pyupstart_system_init.py: TestSystemUpstart.setUp():
  Skip test if not running as root rather than asserting.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Unit Tests
 
2
==========
 
3
 
 
4
Upstarts unit tests are run via::
 
5
 
 
6
  make check
 
7
 
 
8
Integration Tests
 
9
=================
 
10
 
 
11
Python 3 scripts that make use of the ``pyupstart.py`` test module.
 
12
There are 2 classes of integration tests:
 
13
 
 
14
Session-level Integration Tests
 
15
-------------------------------
 
16
 
 
17
These can be run as a non-root user or as root. Ideally, run them as
 
18
both users.
 
19
 
 
20
To run the tests::
 
21
 
 
22
  $ cd scripts/tests && ./test_pyupstart_session_init.py
 
23
 
 
24
The tests make use of some of the sample Job Configuration (``.conf``)
 
25
files shipped with Upstart. However, if the
 
26
``UPSTART_TEST_USE_INSTALLED_CONF`` variable is set to any value, if the
 
27
tests find an *installed* session job of the same name, they will use
 
28
those jobs instead. The current sample jobs the tests use are:
 
29
 
 
30
- ``re-exec.conf``
 
31
- ``upstart-file-bridge.conf``
 
32
 
 
33
System-level Integration Tests
 
34
------------------------------
 
35
 
 
36
These tests must be run as ``root`` (the tests will be skipped if called
 
37
by a non-root user) and operate on the PID 1 executable. The tests will
 
38
create a subdirectory below ``/etc/init/`` in an attempt to isolate
 
39
themselves from the rest of the system. However, these tests are
 
40
designed to be run *on test systems only*.
 
41
 
 
42
The tests also exercise the chroot abilities of Upstart. If the
 
43
environment variable ``UPSTART_TEST_CHROOT_PATH`` is set and points to a
 
44
valid chroot in which Upstart is installed this chroot will participate
 
45
in the tests.
 
46
 
 
47
To run the system-level integration tests::
 
48
 
 
49
  $ su
 
50
  # export UPSTART_TEST_CHROOT_PATH=/full/path/to/chroot
 
51
  # cd scripts/tests && ./test_pyupstart_system_init.py
 
52
 
 
53
Running All the Tests Together
 
54
------------------------------
 
55
 
 
56
WARNING: Running the tests as ``root`` in this way will modify your
 
57
``/etc/init/`` directory. See `System-level Integration Tests`_.
 
58
 
 
59
You can make use of python3's unittest module to run all the tests in
 
60
the normal fashion:
 
61
 
 
62
  $ cd scripts && python3 -munittest
 
63
  $ su
 
64
  # cd scripts && python3 -munittest
 
65