Tuesday 21 February 2012

Sane Threads Fail

This weekend I decided to run the new test suite, across a 'range of machines' and all my 'testing OS's virtual machines'. These test runs showed a number of failures - segfaults on exit. Investigations showed that this is related to the calling of sane functions while within an httpd thread.

I knew that sane is not thread safe, but I thought I'd be OK if I did a 'sane_init ... sane work ... sane_exit', all within a single thread. But alas not.

So, I'm going to have to do a bit of refactoring to solve this problem. The current plan is to:
  • Move the sane_init and sane_exit in the main startup/shutdown methods.
  • Create a 'command socket' within the main block of the program.
  • Isolate sane activity from the current methods that do sane work and replace them with calls into the command socket.
  • Use a listening loop on the command socket to dispatch sane work - that will be done within the main part of the program (and not a thread).
Hopefully this will solve the problems, and has the added advantage of making 'sane and/or device' locking easier to implement. Therefore I'll be doing both of these at the same time.

Friday 17 February 2012

Testing is back up to scratch

The marathon that is 'better.testing' is over!

The old testing was based mainly around using the frontend to exercise the backend. This was a logical approach, but was flawed in a few ways.

  • First, it left little room for edge case testing - 'happy path' testing does not find issues.
  • Second, using the frontend and a valgrind run backend was painfully slow.
So, I've updating things a bit. First the current tests have been split into 'service starting/stopping scenarios', and the 'current frontend tests' (with valgrind checking removed).

A new set of tests have been created, that fire HTTP request at the services just as an AJAX request would do. The responses are checked for what is expected and the database compared to ensure the action have been performed correctly. These tests are also checked under valgrind, to give confidence with regard to memory violations. 

This changes not only cover a greater range, but also allows greater control for the tests we have and flexibility for new testing in the future. 

Will be available in the 0.8 releases.