Always build test programs

Building test programs on make check only is a good way to ensure they never
get updated...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Add support for comments everywhere with getline

Switch to using getline for per-line handling of input. Check each line for
a preceding comment character, then skip ahead. First line _may_ be the file
format version so we need to manually handle that with getline.

As a side-effect, this gives us support for end-of-line comments too since
we always discard what is in the buffer after our scanf ended. Plus it fixes
a bug where a mismatched input line would quietly confuse the parser.

Previously, an input line
I: 1 2 3 4 5 6\n
was parsed with fscanf("I: %04x %04x %04x %04x\n", &bustype, &vendor, &product, &version)

The next read to the file will point to "5" instead of the next line.
Treating each line independently fixes this issue, though we're still quiet
about the parsing errors.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=62272

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

Benjamin Tissoires:
* Change read_* to parse_* to reflect the semantic change.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Be strict about parsing errors

If a line isn't the input we need, complain and fail.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Skip over empty input lines

An empty input line should not case a parsing error, they can be silently
ignored.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
test: add test for reading in a device description

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
test: test for end-of-line comments

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
test: ensure we ignore events in description files

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
test: factor out a bit, make room for invalid file format checks

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
test: add test for empty lines

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
test: add tests for invalid file formats

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>