1 /*
2 * Copyright (c) 2020-2023 Huawei Device Co., Ltd.
3 *
4 * HDF is dual licensed: you can use it either under the terms of
5 * the GPL, or the BSD license, at your option.
6 * See the LICENSE file in the root of this repository for complete details.
7 */
8
9 #include "hdf_wifi_test.h"
10 #include "flow_control_test.h"
11 #include "hdf_module_test.h"
12 #include "hdf_log.h"
13 #include "hdf_message_test.h"
14 #include "hdf_netbuf_test.h"
15 #include "net_device_test.h"
16 #include "osal.h"
17
18 // add test case entry
19 static HdfTestCaseList g_hdfWiFiTestCaseList[] = {
20 {WIFI_NET_DEVICE_INIT, WiFiNetDviceTestInit},
21 {WIFI_NET_DEVICE_DEINIT, WiFiNetDviceTestDeInit},
22 {WIFI_NET_DEVICE_ADD, WiFiNetDviceTestAdd},
23 {WIFI_NET_DEVICE_DELETE, WiFiNetDviceTestDelete},
24 {WIFI_NET_DEVICE_GET, WiFiNetDviceTestGetDevice},
25 {WIFI_NET_DEVICE_GET_COUNT, WiFiNetDviceTestGetCount},
26 {WIFI_NET_DEVICE_GET_CAP, WiFiNetDviceTestGetCap},
27 {WIFI_NET_DEVICE_SET_ADDR, WiFiNetDviceTestSetAddr},
28 {WIFI_NET_DEVICE_SET_STATUS, WiFiNetDviceTestSetStatus},
29 {WIFI_NET_DEVICE_SET_LINK_STATUS, WiFiNetDviceTestSetLinkStatus},
30 {WIFI_NET_DEVICE_RX, WiFiNetDviceTestRx},
31 {WIFI_NET_DEVICE_DHCPC, WifiNetDeviceDhcpClient},
32 {WIFI_NET_DEVICE_DHCPS, WifiNetDeviceDhcpServer},
33 {WIFI_NET_BUF_TEST, HdfNetBufTest},
34 {WIFI_NET_BUF_QUEUE_TEST, HdfNetBufQueueTest},
35 {WIFI_MODULE_CREATE_MODULE, WiFiModuleTestCreateModule},
36 {WIFI_MODULE_DELETE_MODULE, WiFiModuleTestDeleteModule},
37 {WIFI_MODULE_ADD_FEATURE, WiFiModuleTestAddFeature},
38 {WIFI_MODULE_DELETE_FEATURE, WiFiModuleTestDelFeature},
39 {WIFI_FLOW_CONTROL_INIT, WiFiFlowControlTestInit},
40 {WIFI_FLOW_CONTROL_DEINIT, WiFiFlowControlTestDeinit},
41 {WIFI_FLOW_CONTROL_GET_QUEUE_ID, WiFiFlowControlTestGetEapolQueueId},
42 {WIFI_FLOW_CONTROL_SEND_DATA, WiFiFlowControlTestSendData},
43 {WIFI_MESSAGE_QUEUE_001, MessageQueueTest001},
44 {WIFI_MESSAGE_QUEUE_002, MessageQueueTest002},
45 {WIFI_MESSAGE_QUEUE_003, MessageQueueTest003},
46 {WIFI_MESSAGE_SINGLE_NODE_001, MessageSingleNodeTest001},
47 {WIFI_MESSAGE_SINGLE_NODE_002, MessageSingleNodeTest002},
48 {WIFI_MESSAGE_SINGLE_NODE_003, MessageSingleNodeTest003},
49 {WIFI_MESSAGE_SINGLE_NODE_004, MessageSingleNodeTest004},
50 {WIFI_MESSAGE_SINGLE_NODE_005, MessageSingleNodeTest005},
51 };
52
HdfWifiEntry(HdfTestMsg * msg)53 int32_t HdfWifiEntry(HdfTestMsg *msg)
54 {
55 int32_t result;
56 int32_t i;
57
58 if (msg == NULL) {
59 HDF_LOGE("%s is fail: HdfTestMsg is NULL!", __func__);
60 return HDF_SUCCESS;
61 }
62
63 for (i = 0; i < sizeof(g_hdfWiFiTestCaseList) / sizeof(g_hdfWiFiTestCaseList[0]); ++i) {
64 if ((msg->subCmd == g_hdfWiFiTestCaseList[i].subCmd) && (g_hdfWiFiTestCaseList[i].testFunc != NULL)) {
65 result = g_hdfWiFiTestCaseList[i].testFunc();
66 HDF_LOGE("HdfTest:Wifi test result[%s-%u]", ((result == 0) ? "pass" : "fail"), msg->subCmd);
67 msg->result = (result == 0) ? HDF_SUCCESS : HDF_FAILURE;
68 return HDF_SUCCESS;
69 }
70 }
71 return HDF_SUCCESS;
72 }