tests: Add valgrind support

Add support for running tests under valgrind and reporting
valgrind-detected errors.

Allow forcing valgrind on arbitrary tests by setting USE_VALGRIND=1.

Add new 'test_write_and_read_with_valgrind' test case, which runs
the usual 'test_write_and_read' under valgrind.

Change-Id: Ia5590a21a21569b7ef7046dc6438a882db4bc7ec