• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3  * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this list of
9  * conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12  * of conditions and the following disclaimer in the documentation and/or other materials
13  * provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16  * to endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #include "It_los_mem.h"
33 
34 void *g_memPool = NULL;
35 void *g_testPool = NULL;
36 
MemStart(void)37 void MemStart(void)
38 {
39     g_memPool = LOS_MemAlloc(LOSCFG_SYS_HEAP_ADDR, TEST_MEM_SIZE);
40     g_testPool = LOS_MemAlloc(LOSCFG_SYS_HEAP_ADDR, TEST_POOL_SIZE);
41 
42     if ((g_memPool == NULL) || (g_testPool == NULL)) {
43         PRINT_ERR("alloc failed , mem TestCase would be failed!!!!%p !!! %p", g_memPool, g_testPool);
44     }
45 }
46 
MemEnd(void)47 void MemEnd(void)
48 {
49     LOS_MemFree(LOSCFG_SYS_HEAP_ADDR, g_memPool);
50     LOS_MemFree(LOSCFG_SYS_HEAP_ADDR, g_testPool);
51 }
52 
MemInit(void)53 void MemInit(void)
54 {
55     (void)LOS_MemInit(g_memPool, TEST_MEM_SIZE);
56 }
57 
MemFree(void)58 void MemFree(void)
59 {
60     (void)LOS_MemDeInit(g_memPool);
61 }
62 
MemGetFreeSize(void * pool)63 UINT32 MemGetFreeSize(void *pool)
64 {
65     return LOS_MemPoolSizeGet(pool) - LOS_MemTotalUsedGet(pool);
66 }
67 
CalPow(UINT32 exp)68 UINT32 CalPow(UINT32 exp)
69 {
70     UINT32 pw = 1;
71     pw <<= exp;
72     return pw;
73 }
74 
ItSuiteLosMem(void)75 VOID ItSuiteLosMem(void)
76 {
77     MemStart();
78 
79     ItLosMem001();
80     ItLosMem002();
81     ItLosMem003();
82     ItLosMem004();
83     ItLosMem006();
84     ItLosMem007();
85     ItLosMem008();
86     ItLosMem009();
87     ItLosMem010();
88     ItLosMem011();
89     ItLosMem012();
90     ItLosMem013();
91     ItLosMem014();
92     ItLosMem015();
93     ItLosMem016();
94     ItLosMem017();
95     ItLosMem018();
96     ItLosMem019();
97     ItLosMem020();
98 #if (LOSCFG_TEST_MUCH_LOG == 1) // when open this, Too many logs will printed
99     ItLosMem035();
100     ItLosMem036();
101     ItLosMem037();
102     ItLosMem038();
103 #endif
104     ItLosMem040();
105     ItLosMem045();
106 #if (LOSCFG_MEM_MUL_REGIONS == 1)
107     ItLosMem046();
108     ItLosMem047();
109 #endif
110 
111 #if (LOS_KERNEL_TEST_FULL == 1)
112     ItLosTick001();
113 #endif
114     MemEnd();
115 }
116