1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
8 #include <rte_common.h>
13 #ifndef RTE_EXEC_ENV_WINDOWS
14 static volatile int flag;
17 test_alarm_callback(void *cb_arg)
20 printf("Callback setting flag - OK. [cb_arg = %p]\n", cb_arg);
27 #ifdef RTE_EXEC_ENV_FREEBSD
28 printf("The alarm API is not supported on FreeBSD\n");
32 #ifndef RTE_EXEC_ENV_WINDOWS
33 /* check if it will fail to set alarm with wrong us value */
34 printf("check if it will fail to set alarm with wrong ms values\n");
35 if (rte_eal_alarm_set(0, test_alarm_callback,
37 printf("should not be successful with 0 us value\n");
40 if (rte_eal_alarm_set(UINT64_MAX - 1, test_alarm_callback,
42 printf("should not be successful with (UINT64_MAX-1) us value\n");
47 /* check if it will fail to set alarm with null callback parameter */
48 printf("check if it will fail to set alarm with null callback parameter\n");
49 if (rte_eal_alarm_set(10 /* ms */, NULL, NULL) >= 0) {
50 printf("should not be successful to set alarm with null callback parameter\n");
54 /* check if it will fail to remove alarm with null callback parameter */
55 printf("check if it will fail to remove alarm with null callback parameter\n");
56 if (rte_eal_alarm_cancel(NULL, NULL) == 0) {
57 printf("should not be successful to remove alarm with null callback parameter");
64 REGISTER_TEST_COMMAND(alarm_autotest, test_alarm);