meson: debug output on unit test failures

Ensure the testlog.txt file is output to the console if any unit tests
fail. This will help with debug of CI failures in jenkins where only the
console log is available.

Testing: Verified file is output to console on a failure

Change-Id: I4978d676c744c8cd52ff89d316ba7b7fb15674cd
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index 1f2bf2a..0dd9fda 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -626,6 +626,19 @@
         output = e.output
     return not re.search('Test setup .* not found from project', output)
 
+def run_unit_tests_meson():
+    """
+    Runs the unit tests for the meson based package
+    """
+    try:
+        check_call_cmd('meson', 'test', '-C', 'build')
+    except CalledProcessError:
+        for root, _, files in os.walk(os.getcwd()):
+            if 'testlog.txt' not in files:
+                continue
+            check_call_cmd('cat', os.path.join(root, 'testlog.txt'))
+        raise Exception('Unit tests failed')
+
 def maybe_meson_valgrind():
     """
     Potentially runs the unit tests through valgrind for the package
@@ -862,7 +875,7 @@
                 # Run coverage checks
                 check_call_cmd('meson', 'configure', 'build',
                                '-Db_coverage=true')
-                check_call_cmd('meson', 'test', '-C', 'build')
+                run_unit_tests_meson()
                 # Only build coverage HTML if coverage files were produced
                 for root, dirs, files in os.walk('build'):
                     if any([f.endswith('.gcda') for f in files]):
@@ -872,7 +885,8 @@
                 check_call_cmd('meson', 'configure', 'build',
                                '-Db_coverage=false')
             else:
-                check_call_cmd('meson', 'test', '-C', 'build')
+                run_unit_tests_meson()
+
         else:
             run_unit_tests()
             if not TEST_ONLY: