[dpdk-dev,1/2] test/test: fix missed failures when running meson test

Message ID 20171221101510.181082-2-bruce.richardson@intel.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Bruce Richardson Dec. 21, 2017, 10:15 a.m. UTC
  When using meson test, and/or the DPDK_TEST environment variable for
running specific tests, the return value from the test binary was the value
returned from the unit test runner function. However, not all tests use
that unit test runner infrastructure - some are regular functions, and so
the failure of those tests would not be recognised.

Fix this by setting the last_test_result value inside the command-line
function that calls the individual test fns and that prints the "Test OK"
or "Test Failure" messages.

Fixes: d79a9657a78c ("meson: add tests app to build")

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 test/test/commands.c | 1 +
 test/test/test.c     | 2 +-
 test/test/test.h     | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)
  

Comments

Van Haaren, Harry Dec. 21, 2017, 10:44 a.m. UTC | #1
> From: Richardson, Bruce
> Sent: Thursday, December 21, 2017 10:15 AM
> To: dev@dpdk.org
> Cc: Van Haaren, Harry <harry.van.haaren@intel.com>; Richardson, Bruce
> <bruce.richardson@intel.com>
> Subject: [PATCH 1/2] test/test: fix missed failures when running meson test
> 
> When using meson test, and/or the DPDK_TEST environment variable for
> running specific tests, the return value from the test binary was the value
> returned from the unit test runner function. However, not all tests use
> that unit test runner infrastructure - some are regular functions, and so
> the failure of those tests would not be recognised.
> 
> Fix this by setting the last_test_result value inside the command-line
> function that calls the individual test fns and that prints the "Test OK"
> or "Test Failure" messages.
> 
> Fixes: d79a9657a78c ("meson: add tests app to build")
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>


Reviewed-by: Harry van Haaren <harry.van.haaren@intel.com>
  

Patch

diff --git a/test/test/commands.c b/test/test/commands.c
index 4097a3310..6649cfc32 100644
--- a/test/test/commands.c
+++ b/test/test/commands.c
@@ -103,6 +103,7 @@  static void cmd_autotest_parsed(void *parsed_result,
 			ret = t->callback();
 	}
 
+	last_test_result = ret;
 	if (ret == 0)
 		printf("Test OK\n");
 	else
diff --git a/test/test/test.c b/test/test/test.c
index fb4d4753e..bc273db07 100644
--- a/test/test/test.c
+++ b/test/test/test.c
@@ -102,7 +102,7 @@  do_recursive_call(void)
 	return -1;
 }
 
-static int last_test_result;
+int last_test_result;
 
 int
 main(int argc, char **argv)
diff --git a/test/test/test.h b/test/test/test.h
index 08ffe949c..2e9018437 100644
--- a/test/test/test.h
+++ b/test/test/test.h
@@ -218,6 +218,7 @@  struct unit_test_suite {
 };
 
 int unit_test_suite_runner(struct unit_test_suite *suite);
+extern int last_test_result;
 
 #define RECURSIVE_ENV_VAR "RTE_TEST_RECURSIVE"