framework/dmesg: Adds a new module for dmesg

This modules implements two classes and a helper function. The two
classes are both dmesg wrapper classes, one, PosixDmesg is used on posix
systems when requested to actually do checks on dmesg. The second class,
DummyDmesg, is used to reduce code complexity by providing dummy
versions of the methods in PosixDmesg. This means that we don't need
separate code paths for Posix systems wanting to check dmesg, Posix
systems not wanting to check dmesg, and non-posix systems which lack
dmesg.

Beyond reducing complexity this module also gives better isolation,
dmesg is only used in Test.execute(), no where else. Additional classes
don't need to worry about dmesg that way, it's just available.

v2: - Remove unnecessary assert from PosixDmesg.update_result()
    - simplify replace helper in PoixDmesg.update_result()
    - replace try/except with if check
    - Change PosixDmesg.update_dmesg() to work even if dmesg 'wraps'
v3: - Try/Except assignment of PosixDmesg._last_message in update_dmesg()
    - Set the dmesg levels the same as the previous implementation
    - Change PosixDmesg into LinuxDmesg and enforce that dmesg has
      timestamps
v4: - Add check in LinuxDmesg.__init__ to ensure there is something in
      dmesg before doing the timestamp check. This should make problems
      clearer
    - Refactor some code in LinuxDmesg.update_result()

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
Adds unit tests for the dmesg module

This adds a few tests for the dmesg class.

It also adds a test hook into core.Test. This is a little ugly, but I
just couldn't come up with any other solution that didn't involve
making the dmesg code more invasive or harder to read.

v2: - Adds tests to simulate dmesg 'wrapping'
v3: - Replace assert with nose.test assert helpers. These have the
      advantage of providing the option to add a message explaining what
      when wrong.
    - Adds test for LinuxDmesg's enforcement of timestamps
v4: - Remove timestamp error check test. It was polluting the entire
      environment's LinuxDmesg.DMESG_COMMAND in some cases
    - Refactor a few tests as a result of refactoring in framework/dmesg
    - Make the error message in the dmesg_wrap tests more helpful
    - Reduce test_dmesg_performance from .025 to .015 seconds.

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
Use the new dmesg class

This actually makes use of the new dmesg class rather than the dmesg
functions. It touches a lot of files, but almost all of these changes
are code removal rather than code addition.

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
piglit-run.py: Restrict dmesg to serial runs

Dmesg reporting has always been inaccurate with concurrent runs, and the
solution to concurrent runs would be to have each run take out a lock,
removing the chance that another test generated an error in dmesg while
it was running. But this effectively makes them a serial run, and at the
cost of greater code complexity. With that in mind it makes more sense
to just force --dmesg to imply -1.

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