numam-dpdk/app/test/test_alarm.c
Aaron Conole ee00af6017 test: remove strict timing requirements some tests
The tests 'alarm_autotest' and 'cycles_autotest' rely on the underlying
system having very accurate and precise timing.  On systems where the
timing isn't as rigid, or the load is particularly high, these tests are
unreliable since the wake latency from the scheduler can be high enough
to miss the timing window.

Remove the timing related tests from the test suites.  These tests now
ensure the add/remove callback infrastructure unit tests, but drop the
waits and reliance on system timing and load.

This avoids FAIL on various testing infrastructures.

Signed-off-by: Aaron Conole <aconole@redhat.com>
2021-06-03 18:08:57 +02:00

61 lines
1.6 KiB
C

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2014 Intel Corporation
*/
#include <stdio.h>
#include <stdint.h>
#include <rte_common.h>
#include <rte_alarm.h>
#include "test.h"
static volatile int flag;
static void
test_alarm_callback(void *cb_arg)
{
flag = 1;
printf("Callback setting flag - OK. [cb_arg = %p]\n", cb_arg);
}
static int
test_alarm(void)
{
#ifdef RTE_EXEC_ENV_FREEBSD
printf("The alarm API is not supported on FreeBSD\n");
return 0;
#endif
/* check if it will fail to set alarm with wrong us value */
printf("check if it will fail to set alarm with wrong ms values\n");
if (rte_eal_alarm_set(0, test_alarm_callback,
NULL) >= 0) {
printf("should not be successful with 0 us value\n");
return -1;
}
if (rte_eal_alarm_set(UINT64_MAX - 1, test_alarm_callback,
NULL) >= 0) {
printf("should not be successful with (UINT64_MAX-1) us value\n");
return -1;
}
/* check if it will fail to set alarm with null callback parameter */
printf("check if it will fail to set alarm with null callback parameter\n");
if (rte_eal_alarm_set(10 /* ms */, NULL, NULL) >= 0) {
printf("should not be successful to set alarm with null callback parameter\n");
return -1;
}
/* check if it will fail to remove alarm with null callback parameter */
printf("check if it will fail to remove alarm with null callback parameter\n");
if (rte_eal_alarm_cancel(NULL, NULL) == 0) {
printf("should not be successful to remove alarm with null callback parameter");
return -1;
}
return 0;
}
REGISTER_TEST_COMMAND(alarm_autotest, test_alarm);