[PATCH 1/4] test: update alarm test
Bruce Richardson
bruce.richardson at intel.com
Fri Jul 19 12:17:43 CEST 2024
On Thu, Jul 18, 2024 at 12:07:12PM -0700, Stephen Hemminger wrote:
> This test should be using the TEST_ASSERT macros, and can be
> run as part of the fast test suite now.
>
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> ---
> app/test/test_alarm.c | 53 ++++++++++++++++---------------------------
> 1 file changed, 20 insertions(+), 33 deletions(-)
>
> diff --git a/app/test/test_alarm.c b/app/test/test_alarm.c
> index 70e97a3109..4ba8aa1af2 100644
> --- a/app/test/test_alarm.c
> +++ b/app/test/test_alarm.c
> @@ -10,7 +10,8 @@
>
> #include "test.h"
>
> -#ifndef RTE_EXEC_ENV_WINDOWS
> +#define US_PER_SEC 1000000
> +
> static volatile int flag;
>
> static void
> @@ -19,46 +20,32 @@ test_alarm_callback(void *cb_arg)
> flag = 1;
> printf("Callback setting flag - OK. [cb_arg = %p]\n", cb_arg);
> }
> -#endif
>
> static int
> test_alarm(void)
> {
> -#ifdef RTE_EXEC_ENV_FREEBSD
> - printf("The alarm API is not supported on FreeBSD\n");
> - return 0;
> -#endif
> + int ret;
> +
> + ret = rte_eal_alarm_set(0, test_alarm_callback, NULL);
> + TEST_ASSERT_FAIL(ret, "should not be succeed with 0 us value");
> +
> + ret = rte_eal_alarm_set(UINT64_MAX - 1, test_alarm_callback, NULL);
> + TEST_ASSERT_FAIL(ret, "should not be succeed with (UINT64_MAX-1) us value");
> +
> + ret = rte_eal_alarm_set(10, NULL, NULL);
> + TEST_ASSERT_FAIL(ret, "should not succeed with null callback parameter");
>
+1 to use of TEST_ASSERT_FAIL, the test is a lot cleaner now.
However, I think we still need the #ifdefs in it if some of it doesn't work
on Windows/BSD.
/Bruce
More information about the dev
mailing list