test_detect_match_nonexistent_template: Make it check the right behaviour

`detect_match` should (and does) throw if the template name its given is
wrong, but the test looked like it just returned a non-matching
`MatchResult`.

This commit fixes this test to actually test the expected behaviour.
API: Allow treating `MatchResult` as a boolean

This is part of an effort to make the stbt match API more composible.
For instance with the addition of a `match()` method you will be able
to write something like:

    if match('template.png') or match('template2.png'):
        do_stuff()

The tests are updated to reflect the recommended way of expressing testing
for matches.
Merge pull request #183 from wmanley/api-matchresult-boolean

API: Allow treating `MatchResult` as a boolean
stbt control: Allow specifying keymap file in stbt config

With this change the keymap file will default to the value stored in
"control.keymap" rather than and falling back to
`~/.config/stbt/control.conf`.  This makes it easier for the use-case
where you have a config file per device under test and you want to be
able to easily switch between them using the `STBT_CONFIG_FILE`
environment variable.
Merge pull request #181 from wmanley/config-control-conf

stbt control: Allow specifying keymap file in stbt config
tests: Run (no of cores +4) tests in parallel

If available `make check` uses GNU parallel to run tests in parallel.  By
default it will run (no of cores) tasks in parallel.  This commit boosts
this number by 4 as on Travis we only have a single core to play with, but
our tests aren't CPU bound so we can further parallelize and further
reduce test run time.

On @drothlis's dual-core laptop the time is reduced from 2m to 1m30s and
on my 4 core laptop it is reduced from 1m2s to 51s.
tests: Fix race between test_stbt_batch_run_killtree and test_killtree

When run in parallel, e.g. with GNU parallel as a part of `make check`
`test_stbt_batch_run_killtree` and `test_killtree` can fail.  You can
reproduce this with

    printf 'test_stbt_batch_run_killtree\ntest_killtree' \
        | parallel ./tests/run-tests.sh -i

The race exists because the `test_stbt_batch_run_killtree` is actually
calling `test_killtree` which in turn tests that it has killed all the
processes that it started up by `grep`ing `ps` output for the program
name - which is the shared by both tests.

This commit fixes this race by naming the program names according to the
pid of the test process (which is the root of the process tree that it's
checking that it's killed).

This race has existed since cb9cb71f5 but we only started seeing it now as
we are trying to get Travis to run the tests in parallel.
Travis: Install GNU parallel to speed up tests

Debian (and by extension Ubuntu) systems have two packages that provide
the command `/usr/bin/parallel`: moreutils and parallel.  Unfortunately
they do not have compatible syntax.  stb-tester depends on moreutils so
we have to install that package.  With GNU parallel (provided by the
Debian package "parallel") we can parallelize the tests we run and so
make them faster.

With this commit we build and install GNU parallel as a part of Travis
commands to allow us to use GNU parallel on Travis' Ubuntu 12.04 and
thus accelerate the testing process.

Reduces Travis build time from ~10mins to 3m47, even though we've added
downloading, compiling and installing GNU parallel to the build process.

Incidentally of the 3m47s when I measured this 2m21s was spent
installing dependencies and 1m26s was spent actually running `make` and
`make check`.
Merge pull request #184 from wmanley/travis-parallel

Travis: Install GNU parallel to speed up tests
test_x11_remote: Print xterm log to investigate intermittent failure
test_that_stbt_run_exits_on_ctrl_c: Fix intermittent failure

I saw this test fail on Travis, possibly because we added parallelism to
the Travis test-runner in b46b3939 and now 5 seconds isn't enough for
the killing process to be scheduled when the Travis host is under heavy
load?
make check: Silence parallel's citation notice

Otherwise you see this in the `make check` output:

> When using programs that use GNU Parallel to process data for
> publication please cite:
>
> O. Tange (2011): GNU Parallel - The Command-Line Power Tool,
>
> ;login: The USENIX Magazine, February 2011:42-47.
>
> This helps funding further development; and it won't cost you a cent.
>
> To silence this citation notice run 'parallel --bibtex' once or use
> '--no-notice'.
Merge pull request #185 from drothlis/fix-test-x11-remote

test_x11_remote: Print xterm log to investigate intermittent failure
test_detect_match_nonexistent_template: Cleanup unused import

Thanks to Lewis Haley for spotting this.
test_that_stbt_batch_*: Increase timeouts

These two tests fail intermittently on Travis CI, possibly because we
increased the number of tests that run in parallel in b46b3939.
_numpy_from_sample: Improve error reporting

Print a more useful message when wrong type passed to `_numpy_from_sample`.

I ran into this when mistakenly passing a region as the first argument to
`stbt.ocr`.
stbt._set_config: Don't fail if ~/.config/stbt/ doesn't exist

This happens if the user hasn't created `~/.config/stbt/` and hasn't
specified `$STBT_CONFIG_FILE`.
Makefile: Don't use parallel "--no-notice"

Because it isn't available in all versions of GNU parallel (thanks to
Lewis Haley for the heads-up).

I had introduced this in e3aa9fd to avoid verbose output on Travis CI,
so I'll place the workaround in the Travis setup instead.
Merge pull request #189 from drothlis/travis-silence-parallel-citation-notice

Makefile: Don't use parallel "--no-notice"
stbt._find_tessdata_dir: add tessdata directory suffix for Fedora

As tested on Fedora 17, 19 and 20, the `tessdata` directory is
`/usr/share/tesseract/tessdata`, which wasn't being found by
`_find_tessdata_dir`. This commit adds the valid suffix so that, among
other things, the selftests which require this function works.