gleantest_tests.py: Make one test more robust

The test for glean returncodes relied on unsetting os.environ to cause
glean to fail. This is fairly reliable, but it is possible to break it.
A much more robust implementation is to just set
instance.result['returncode'] = 1 and then run interpret_result(), with
the added bonus of focusing the test better.

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
utils.py: add boilerplate to work around nose bug

The gist of the bug is that the way nose uses generators to create tests
it yields the same instance multiple times, and it uses an instance
attribute to set the name of the test. It then prints the results of the
tests all at once, meaning that the final assignment of that instance
attribute is displayed for all failing tests.

The class is a proxy object that is used to create a unique instance for
each test. This works around the bug since the attribute that stores the
test description isn't overwritten each time a new test is generated.

The decorator is used for generators to transparently replace the
function yielded by the test generator with a proxy object. This allows
generated tests to return the correct name; all without any modification
to the test generator. This means that if nose ever solves this problem
making use of nose's solution is a single deleted line per generator.

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
core_tests.py: Use the utils.nose_generator decorator

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
dmesg_tests.py: Use utils.nose_generator decorator

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
log_tests.py: use utils.nose_generator

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
status_tests.py: use utils.nose_generator

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
summary_tests.py: use utils.nose_generator

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
test_lists.py: use utils.nose_generator

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
status_tests.py: Convert large test case into generator

This gives more fine-grained results
dmesg_tests.py: refactor a few tests

This drops some unused variable assignments, and refactors a test that
uses a test for providing data.
dmesg_tests.py: Cleanup pylint warnings:

- replace oldstyle class with newstyle class
- add self to arguments for DummyLog methods

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
dmesg_tests.py: Promote some helpers to toplevel classes

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
dmesg_tests.py: remove duplicate helper functions

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
framework/tests: Add sudo to the names of privileged tests

This makes it very easy to exclude only the tests that use sudo, so
running "nostests framework/tests -e sudo" will run all tests except
the ones that need privileged support.

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
dmesg_tests.py: rename variables named dmesg

This is groundwork to do away with import ... from

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
dmesg_tests.py: use namespaces for imports

This makes things nicer

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
dmesg_tests.py: cleanup pylint and pep8 warnings

These are all formatting warnings, so there is zero functional change in
this patch.

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
dmesg.py: Use Abstract Base Class

This change isn't really a functional change, but it should allow
someone to implement a dmesg class for another OS (OSX, BSD, Linux
without timestamps, etc) more readily, since it simplifies subclassing.

The immediate reason for doing this however, is that it creates a clean
separation between update_dmesg() and update_result(), which makes it
easier to test update_result() without needing privileged access (or
even a posix machine).

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
dmesg_tests.py: Make tests easier to run

This patch adds one new test that uses sudo (to prove that dmesg
reading actually works), and then adds a TestDmesg class, which uses the
same update_result() method as LinuxDmesg, but doesn't use
update_dmesg(), opting instead to pass results directly into the
_new_messages field. This means that a large number of tests that
previously needed sudo no longer need sudo.

With this patch nose reports our coverage at 92%, and the remaining 8%
isn't relevant for testing.

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
status_tests.py: make status tests comprehensive

One can use nose to generate test coverage reports:
nosetests framework/tests/status_tests.py --with-coverage
--cover-package=framework

This series adds a large number of operator tests based on Status and
NoChangeStatus for testing all of it's magic methods (Python refers to
__<method>__ as magic methods, because they are designed to be used by
helper functions).

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>