1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
8 #include <rte_common.h>
13 static volatile int flag;
16 test_alarm_callback(void *cb_arg)
19 printf("Callback setting flag - OK. [cb_arg = %p]\n", cb_arg);
25 #ifdef RTE_EXEC_ENV_FREEBSD
26 printf("The alarm API is not supported on FreeBSD\n");
30 /* check if it will fail to set alarm with wrong us value */
31 printf("check if it will fail to set alarm with wrong ms values\n");
32 if (rte_eal_alarm_set(0, test_alarm_callback,
34 printf("should not be successful with 0 us value\n");
37 if (rte_eal_alarm_set(UINT64_MAX - 1, test_alarm_callback,
39 printf("should not be successful with (UINT64_MAX-1) us value\n");
43 /* check if it will fail to set alarm with null callback parameter */
44 printf("check if it will fail to set alarm with null callback parameter\n");
45 if (rte_eal_alarm_set(10 /* ms */, NULL, NULL) >= 0) {
46 printf("should not be successful to set alarm with null callback parameter\n");
50 /* check if it will fail to remove alarm with null callback parameter */
51 printf("check if it will fail to remove alarm with null callback parameter\n");
52 if (rte_eal_alarm_cancel(NULL, NULL) == 0) {
53 printf("should not be successful to remove alarm with null callback parameter");
60 REGISTER_TEST_COMMAND(alarm_autotest, test_alarm);