• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "hctest.h"
17 #include "iot_errno.h"
18 #include "iot_flash.h"
19 
20 #define TEST_FLASH_SIZE 8
21 #define TEST_FLASH_SIZE_4K 4096
22 #define TEST_FLASH_OFFSET 0xFFFFFFFF
23 
24 unsigned int (*g_ioTFlashWrite)(unsigned int flashOffset,
25                                 unsigned int size,
26                                 const unsigned char *ramData,
27                                 unsigned char doErase);
28 unsigned int (*g_ioTFlashRead)(unsigned int flashOffset, unsigned int size, unsigned char *ramData);
29 unsigned int (*g_ioTFlashErase)(unsigned int flashOffset, unsigned int size);
30 unsigned int (*g_ioTFlashInit)(void);
31 unsigned int (*g_ioTFlashDeinit)(void);
32 
33 /**
34  * @tc.desc      : register a test suite, this suite is used to test basic flow and interface dependency
35  * @param        : subsystem name is wifiiot
36  * @param        : module name is wifiiotlite
37  * @param        : test suite name is UtilsFileFuncTestSuite
38  */
39 LITE_TEST_SUIT(wifiiot, wifiiotlite, IotFlashTestSuite);
40 
41 /**
42  * @tc.setup     : setup for all testcases
43  * @return       : setup result, TRUE is success, FALSE is fail
44  */
IotFlashTestSuiteSetUp(void)45 static BOOL IotFlashTestSuiteSetUp(void)
46 {
47     return TRUE;
48 }
49 
50 /**
51  * @tc.teardown  : teardown for all testcases
52  * @return       : teardown result, TRUE is success, FALSE is fail
53  */
IotFlashTestSuiteTearDown(void)54 static BOOL IotFlashTestSuiteTearDown(void)
55 {
56     printf("+-------------------------------------------+\n");
57     return TRUE;
58 }
59 
60 /**
61  * @tc.number    : SUB_UTILS_WIFIIOT_API_0100
62  * @tc.name      : Flash operation with IoTFlashInit
63  * @tc.desc      : [C- SOFTWARE -0200]
64  */
65 LITE_TEST_CASE(IotFlashTestSuite, testIotFlash001, Function | MediumTest | Level1)
66 {
67     g_ioTFlashInit = IoTFlashInit;
68 };
69 
70 /**
71  * @tc.number    : SUB_UTILS_WIFIIOT_API_0200
72  * @tc.name      : Flash operation with IoTFlashWrite
73  * @tc.desc      : [C- SOFTWARE -0200]
74  */
75 LITE_TEST_CASE(IotFlashTestSuite, testIotFlash002, Function | MediumTest | Level1)
76 {
77     g_ioTFlashWrite = IoTFlashWrite;
78 
79 };
80 
81 /**
82  * @tc.number    : SUB_UTILS_WIFIIOT_API_0300
83  * @tc.name      : Flash operation with IoTFlashRead
84  * @tc.desc      : [C- SOFTWARE -0200]
85  */
86 LITE_TEST_CASE(IotFlashTestSuite, testIotFlash003, Function | MediumTest | Level1)
87 {
88     g_ioTFlashRead = IoTFlashRead;
89 };
90 
91 /**
92  * @tc.number    : SUB_UTILS_WIFIIOT_API_0400
93  * @tc.name      : Flash operation with IoTFlashErase
94  * @tc.desc      : [C- SOFTWARE -0200]
95  */
96 LITE_TEST_CASE(IotFlashTestSuite, testIotFlash004, Function | MediumTest | Level1)
97 {
98     g_ioTFlashErase = IoTFlashErase;
99 };
100 
101 /**
102  * @tc.number    : SUB_UTILS_WIFIIOT_API_0500
103  * @tc.name      : Flash operation with IoTFlashDeinit
104  * @tc.desc      : [C- SOFTWARE -0200]
105  */
106 LITE_TEST_CASE(IotFlashTestSuite, testIotFlash005, Function | MediumTest | Level1)
107 {
108     g_ioTFlashDeinit = IoTFlashDeinit;
109 };
110 
111 RUN_TEST_SUITE(IotFlashTestSuite);
112