1 /*
2 * Copyright (c) 2020-2021 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 "hcs_parser_test.h"
10 #include "hcs_config_test.h"
11 #include "hcs_macro_cases.h"
12
13 // add test case entry
14 HdfTestCaseList g_hdfConfigTestCaseList[] = {
15 { HDF_CREATE_DM_HCS_TO_TREE_001, HcsTestCreateDMHcsToTree },
16 { HDF_GET_NODE_BY_ATTR_VALUE_001, HcsTestGetNodeByMatchAttrSuccess },
17 { HDF_GET_NODE_BY_ATTR_VALUE_002, HcsTestGetNodeByMatchAttrFail },
18 { HDF_GET_BOOL_ATTR_VALUE_001, HcsTestGetBoolAttrValueSuccess },
19 { HDF_GET_BOOL_ATTR_VALUE_002, HcsTestGetBoolAttrValueFail },
20 { HDF_GET_UINT8_ATTR_VALUE_001, HcsTestGetUint8AttrValueSuccess },
21 { HDF_GET_UINT8_ATTR_VALUE_002, HcsTestGetUint8AttrValueFail },
22 { HDF_GET_UINT8_ARRAY_ELEM_ATTR_VALUE_001, HcsTestGetUint8ArrayElemSuccess },
23 { HDF_GET_UINT8_ARRAY_ELEM_ATTR_VALUE_002, HcsTestGetUint8ArrayElemFail },
24 { HDF_GET_UINT8_ARRAY_ATTR_VALUE_001, HcsTestGetUint8ArraySuccess },
25 { HDF_GET_UINT8_ARRAY_ATTR_VALUE_002, HcsTestGetUint8ArrayFail },
26 { HDF_GET_UINT16_ATTR_VALUE_001, HcsTestGetUint16AttrValueSuccess },
27 { HDF_GET_UINT16_ATTR_VALUE_002, HcsTestGetUint16AttrValueFail },
28 { HDF_GET_UINT16_ARRAY_ELEM_ATTR_VALUE_001, HcsTestGetUint16ArrayElemSuccess },
29 { HDF_GET_UINT16_ARRAY_ELEM_ATTR_VALUE_002, HcsTestGetUint16ArrayElemFail },
30 { HDF_GET_UINT16_ARRAY_ATTR_VALUE_001, HcsTestGetUint16ArraySuccess },
31 { HDF_GET_UINT16_ARRAY_ATTR_VALUE_002, HcsTestGetUint16ArrayFail },
32 { HDF_GET_UINT32_ATTR_VALUE_001, HcsTestGetUint32AttrValueSuccess },
33 { HDF_GET_UINT32_ATTR_VALUE_002, HcsTestGetUint32AttrValueFail },
34 { HDF_GET_UINT32_ARRAY_ELEM_ATTR_VALUE_001, HcsTestGetUint32ArrayElemSuccess },
35 { HDF_GET_UINT32_ARRAY_ELEM_ATTR_VALUE_002, HcsTestGetUint32ArrayElemFail },
36 { HDF_GET_UINT32_ARRAY_ATTR_VALUE_001, HcsTestGetUint32ArraySuccess },
37 { HDF_GET_UINT32_ARRAY_ATTR_VALUE_002, HcsTestGetUint32ArrayFail },
38 { HDF_GET_UINT64_ATTR_VALUE_001, HcsTestGetUint64AttrValueSuccess },
39 { HDF_GET_UINT64_ATTR_VALUE_002, HcsTestGetUint64AttrValueFail },
40 { HDF_GET_UINT64_ARRAY_ELEM_ATTR_VALUE_001, HcsTestGetUint64ArrayElemSuccess },
41 { HDF_GET_UINT64_ARRAY_ELEM_ATTR_VALUE_002, HcsTestGetUint64ArrayElemFail },
42 { HDF_GET_UINT64_ARRAY_ATTR_VALUE_001, HcsTestGetUint64ArraySuccess },
43 { HDF_GET_UINT64_ARRAY_ATTR_VALUE_002, HcsTestGetUint64ArrayFail },
44 { HDF_GET_ELEM_NUM_VALUE_001, HcsTestGetElemNumSuccess },
45 { HDF_GET_ELEM_NUM_VALUE_002, HcsTestGetElemNumFail },
46 { HDF_GET_CHILD_NODE_001, HcsTestGetChildNodeSuccess },
47 { HDF_GET_CHILD_NODE_002, HcsTestGetChildNodeFail },
48 { HDF_TRAVERSE_ATTR_IN_NODE_001, HcsTestTraverseAttrInNodeSuccess },
49 { HDF_TRAVERSE_ATTR_IN_NODE_002, HcsTestTraverseAttrInNodeFail },
50 { HDF_GET_STRING_ATTR_VALUE_001, HcsTestGetStringSuccess },
51 { HDF_GET_STRING_ATTR_VALUE_002, HcsTestGetStringFail },
52 { HDF_GET_STRING_ARRAY_ELEM_ATTR_VALUE_001, HcsTestGetStringArrayElemSuccess },
53 { HDF_GET_STRING_ARRAY_ELEM_ATTR_VALUE_002, HcsTestGetStringArrayElemFail },
54 { HDF_GET_NODE_BY_ATTR_REF_001, HcsTestGetNodeAttrRefSuccess },
55 { HDF_GET_NODE_BY_ATTR_REF_002, HcsTestGetNodeAttrRefFail },
56 { HDF_MACRO_GET_ONE_NODE, HcsMacroGetOneNode },
57 { HDF_MACRO_CHECK_NODE_EXISTS, HcsMacroCheckNodeExists },
58 { HDF_MACRO_CHECK_NODE_NOT_EXISTS, HcsMacroCheckNodeNotExists },
59 { HDF_MACRO_GET_ONE_NODE_PROP, HcsMacroCheckPropExists },
60 { HDF_MACRO_CHECK_NODE_PROP_EXISTS, HcsMacroCheckPropNotExists },
61 { HDF_MACRO_CHECK_NODE_PROP_NOT_EXISTS, HcsMacroGetOneNodeProp },
62 { HDF_MACRO_TRAVERSAL_ONE_NODE, HcsMacroTraversalOneNode },
63 { HDF_MACRO_GET_ARRAY_SIZE, HcsMacroGetArraySize },
64 { HDF_MACRO_GET_ONE_ARRAY_ELEMENT, HcsMacroGetArrayElement },
65 { HDF_MACRO_TRAVERSAL_ONE_ARRAY, HcsMacroTraversalOneArray },
66 { HDF_MACRO_TRAVERSAL_ALL_ARRAY, HcsMacroTraversalAllArray },
67 { HDF_MACRO_TRAVERSAL_NODE_CHILD, HcsMacroTraversalOneNodeChild },
68 { HDF_MACRO_TRAVERSAL_NODE_CHILD_VARGS, HcsMacroTraversalOneNodeChildVargs },
69 { HDF_MACRO_GET_ONE_FILE, HcsMacroGetOneFile },
70 };
71
HdfConfigEntry(HdfTestMsg * msg)72 int32_t HdfConfigEntry(HdfTestMsg *msg)
73 {
74 int i;
75 if (msg == NULL) {
76 return HDF_FAILURE;
77 }
78
79 for (i = 0; i < sizeof(g_hdfConfigTestCaseList) / sizeof(g_hdfConfigTestCaseList[0]); ++i) {
80 if (msg->subCmd != g_hdfConfigTestCaseList[i].subCmd) {
81 continue;
82 }
83 if (g_hdfConfigTestCaseList[i].testFunc == NULL) {
84 msg->result = HDF_FAILURE;
85 return HDF_FAILURE;
86 }
87 msg->result = g_hdfConfigTestCaseList[i].testFunc();
88 if (msg->result != HDF_SUCCESS) {
89 return HDF_FAILURE;
90 }
91 }
92 return HDF_SUCCESS;
93 }
94