warn_collector_test: make it actually work

The warn_collector_test.c wrapper which calls system() assumes that the
return value of system() is the exit code when it's really a wait status.
That means we'd often get back values like 256 which, when masked with
0377, we get back 0 and so this test would always "pass".

Once we fix that, we see that the script has been failing for all boards
other than link because of hardcoded paths in the setup:
warn_collector: error while loading shared libraries: libmetrics.so:
	cannot open shared object file: No such file or directory

Analysis of these vars show that we haven't even been testing the local
compiled binary.  Instead, we've been trying to test the one installed
into the $SYSROOT due to the $PATH munging.  I cleaned that up as well
as generally tidied up this test script.

Once we fix that, we then see that the collection doesn't work properly
and fails with:
expected 2 lines in warn-test-log, found this:

This last bug is due to the regex matching less than was expected:
<PRE_WARN>[^ ]+\n         if (WarnStart()) {  /* yytext is file:line */
But the actual line looks like:
Apr 31 25:25:25 localhost kernel: [117959.231100] WARNING: at /mnt/host/source/src/third_party/kernel/files/drivers/gpu/drm/i915/intel_dp.c:351 intel_dp_check_edp+0x6b/0xb9()

You can see there is a space between the <file> and the <symbol> which
means we pass in to the start function in this (*not* the file:line):

When the test script runs, it tries to use sed to mung the error message
to get a new file path, but the collector only looks at the func name,
so the calculated hashes continue to match.

We can fix this latter part in two ways: change the test to mung the
func name, or change the lex to pass in the file+func name.  I've gone
the latter route as that seems to have been the intention.

TEST=`cros_run_unit_tests --board=x86-alex -p crash-reporter` passes

Change-Id: I5b3490c56280bb5260198af930b6744cea585c46
Reviewed-on: https://gerrit.chromium.org/gerrit/56305
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
3 files changed
tree: 558bd6a251695d0a7ffee51c55ea7b0b82ec324e
  1. crash_reporter/