test: add reciprocal based division
[dpdk.git] / test / 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 #include <rte_power.h>
14
15 static int
16 test_power(void)
17 {
18         int ret = -1;
19         enum power_management_env env;
20
21         /* Test setting an invalid environment */
22         ret = rte_power_set_env(PM_ENV_NOT_SET);
23         if (ret == 0) {
24                 printf("Unexpectedly succeeded on setting an invalid environment\n");
25                 return -1;
26         }
27
28         /* Test that the environment has not been set */
29         env = rte_power_get_env();
30         if (env != PM_ENV_NOT_SET) {
31                 printf("Unexpectedly got a valid environment configuration\n");
32                 return -1;
33         }
34
35         /* verify that function pointers are NULL */
36         if (rte_power_freqs != NULL) {
37                 printf("rte_power_freqs should be NULL, environment has not been "
38                                 "initialised\n");
39                 goto fail_all;
40         }
41         if (rte_power_get_freq != NULL) {
42                 printf("rte_power_get_freq should be NULL, environment has not been "
43                                 "initialised\n");
44                 goto fail_all;
45         }
46         if (rte_power_set_freq != NULL) {
47                 printf("rte_power_set_freq should be NULL, environment has not been "
48                                 "initialised\n");
49                 goto fail_all;
50         }
51         if (rte_power_freq_up != NULL) {
52                 printf("rte_power_freq_up should be NULL, environment has not been "
53                                 "initialised\n");
54                 goto fail_all;
55         }
56         if (rte_power_freq_down != NULL) {
57                 printf("rte_power_freq_down should be NULL, environment has not been "
58                                 "initialised\n");
59                 goto fail_all;
60         }
61         if (rte_power_freq_max != NULL) {
62                 printf("rte_power_freq_max should be NULL, environment has not been "
63                                 "initialised\n");
64                 goto fail_all;
65         }
66         if (rte_power_freq_min != NULL) {
67                 printf("rte_power_freq_min should be NULL, environment has not been "
68                                 "initialised\n");
69                 goto fail_all;
70         }
71         rte_power_unset_env();
72         return 0;
73 fail_all:
74         rte_power_unset_env();
75         return -1;
76 }
77
78 REGISTER_TEST_COMMAND(power_autotest, test_power);