test: move to app directory
[dpdk.git] / app / test / test_power.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #include <stdio.h>
6 #include <stdint.h>
7 #include <unistd.h>
8 #include <limits.h>
9 #include <string.h>
10
11 #include "test.h"
12
13 #ifndef RTE_LIBRTE_POWER
14
15 static int
16 test_power(void)
17 {
18         printf("Power management library not supported, skipping test\n");
19         return TEST_SKIPPED;
20 }
21
22 #else
23
24 #include <rte_power.h>
25
26 static int
27 test_power(void)
28 {
29         int ret = -1;
30         enum power_management_env env;
31
32         /* Test setting an invalid environment */
33         ret = rte_power_set_env(PM_ENV_NOT_SET);
34         if (ret == 0) {
35                 printf("Unexpectedly succeeded on setting an invalid environment\n");
36                 return -1;
37         }
38
39         /* Test that the environment has not been set */
40         env = rte_power_get_env();
41         if (env != PM_ENV_NOT_SET) {
42                 printf("Unexpectedly got a valid environment configuration\n");
43                 return -1;
44         }
45
46         /* verify that function pointers are NULL */
47         if (rte_power_freqs != NULL) {
48                 printf("rte_power_freqs should be NULL, environment has not been "
49                                 "initialised\n");
50                 goto fail_all;
51         }
52         if (rte_power_get_freq != NULL) {
53                 printf("rte_power_get_freq should be NULL, environment has not been "
54                                 "initialised\n");
55                 goto fail_all;
56         }
57         if (rte_power_set_freq != NULL) {
58                 printf("rte_power_set_freq should be NULL, environment has not been "
59                                 "initialised\n");
60                 goto fail_all;
61         }
62         if (rte_power_freq_up != NULL) {
63                 printf("rte_power_freq_up should be NULL, environment has not been "
64                                 "initialised\n");
65                 goto fail_all;
66         }
67         if (rte_power_freq_down != NULL) {
68                 printf("rte_power_freq_down should be NULL, environment has not been "
69                                 "initialised\n");
70                 goto fail_all;
71         }
72         if (rte_power_freq_max != NULL) {
73                 printf("rte_power_freq_max should be NULL, environment has not been "
74                                 "initialised\n");
75                 goto fail_all;
76         }
77         if (rte_power_freq_min != NULL) {
78                 printf("rte_power_freq_min should be NULL, environment has not been "
79                                 "initialised\n");
80                 goto fail_all;
81         }
82         rte_power_unset_env();
83         return 0;
84 fail_all:
85         rte_power_unset_env();
86         return -1;
87 }
88 #endif
89
90 REGISTER_TEST_COMMAND(power_autotest, test_power);