1/* 2 * Copyright (c) 2023 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 16import { beforeEach, describe, expect, it } from '@ohos/hypium' 17import Utils from './Utils' 18import mman from 'libmmanndk.so' 19 20export default function mmanNdkTest() { 21 describe('MuslMmanTest', () => { 22 23 beforeEach(async () => { 24 await Utils.sleep(50) 25 }) 26 27 /** 28 * @tc.number : SUB_THIRDPARTY_MUSL_MMAN_MEMFDCREATE_0100 29 * @tc.name : testMuslMmanmemfdCreate001 30 * @tc.desc : test memfd_create 31 * @tc.size : MediumTest 32 * @tc.type : Function 33 * @tc.level : Level 2 34 */ 35 it('testMuslMmanmemfdCreate001', 0, async (done: Function) => { 36 let data: number = mman.memfdCreate(); 37 console.info("Test NAPI data= " + JSON.stringify(data)); 38 expect(data).assertEqual(0); 39 done() 40 }); 41 /** 42 * @tc.number : SUB_THIRDPARTY_MUSL_MMAN_MINCORE_0100 43 * @tc.name : testMuslMmanMinCore001 44 * @tc.desc : test mincore 45 * @tc.size : MediumTest 46 * @tc.type : Function 47 * @tc.level : Level 2 48 */ 49 it('testMuslMmanMinCore001', 0, async (done: Function) => { 50 let data: number = mman.mincore(); 51 console.info("Test NAPI data= " + JSON.stringify(data)); 52 expect(data).assertEqual(0); 53 done() 54 }); 55 56 /** 57 * @tc.number : SUB_THIRDPARTY_MUSL_MMAN_MUNMAP_0100 58 * @tc.name : testMuslMmanMunmap001 59 * @tc.desc : test munmap 60 * @tc.size : MediumTest 61 * @tc.type : Function 62 * @tc.level : Level 1 63 */ 64 it('testMuslMmanMunmap001', 0, async (done: Function) => { 65 let a = 4; 66 let data: number = mman.munmap(a); 67 console.info("Test NAPI data = \"" + data + "\""); 68 expect(data).assertEqual(0); 69 done(); 70 }); 71 /** 72 * @tc.number : SUB_THIRDPARTY_MUSL_MMAN_MPROTECT_0100 73 * @tc.name : testMuslMmanMProtect001 74 * @tc.desc : test mprotect 75 * @tc.size : MediumTest 76 * @tc.type : Function 77 * @tc.level : Level 1 78 */ 79 it('testMuslMmanMProtect001', 0, async (done: Function) => { 80 let data: number = mman.mProtect(); 81 console.info("Test NAPI data= " + JSON.stringify(data)); 82 expect(data).assertEqual(0); 83 done() 84 }); 85 /** 86 * @tc.number : SUB_THIRDPARTY_MUSL_MMAN_MREMAP_0100 87 * @tc.name : testMuslMmanMreMap001 88 * @tc.desc : test mremap 89 * @tc.size : MediumTest 90 * @tc.type : Function 91 * @tc.level : Level 1 92 */ 93 it('testMuslMmanMreMap001', 0, async (done: Function) => { 94 let data: number = mman.mreMap(); 95 console.info("Test NAPI data= " + JSON.stringify(data)); 96 expect(data).assertEqual(0); 97 done() 98 }); 99 /** 100 * @tc.number : SUB_THIRDPARTY_MUSL_MMAN_MSYNC_0100 101 * @tc.name : testMuslMmanMSync001 102 * @tc.desc : test mremap 103 * @tc.size : MediumTest 104 * @tc.type : Function 105 * @tc.level : Level 1 106 */ 107 it('testMuslMmanMSync001', 0, async (done: Function) => { 108 let data: number = mman.mSync(); 109 console.info("Test NAPI data= " + JSON.stringify(data)); 110 expect(data).assertEqual(0); 111 done() 112 }); 113 /** 114 * @tc.number : SUB_THIRDPARTY_MUSL_MMAN_MUNLOCK_0100 115 * @tc.name : testMuslMmanMunlock001 116 * @tc.desc : test munlock 117 * @tc.size : MediumTest 118 * @tc.type : Function 119 * @tc.level : Level 1 120 */ 121 it('testMuslMmanMunlock001', 0, async (done: Function) => { 122 let data: number = mman.mUnLock(); 123 console.info("Test NAPI data= " + JSON.stringify(data)); 124 expect(data).assertEqual(0); 125 done() 126 }); 127 /** 128 * @tc.number : SUB_THIRDPARTY_MUSL_MMAN_MUNLOCKALL_0100 129 * @tc.name : testMuslMmanMunlockAll001 130 * @tc.desc : test munlockall 131 * @tc.size : MediumTest 132 * @tc.type : Function 133 * @tc.level : Level 1 134 */ 135 it('testMuslMmanMunlockAll001', 0, async (done: Function) => { 136 let data: number = mman.mUnLockAll(); 137 console.info("Test NAPI data= " + JSON.stringify(data)); 138 expect(data).assertEqual(0); 139 done() 140 }); 141 /** 142 * @tc.number : SUB_THIRDPARTY_MUSL_MMAN_MADVISE_0100 143 * @tc.name : testMuslMmanMadvise001 144 * @tc.desc : test madvise 145 * @tc.size : MediumTest 146 * @tc.type : Function 147 * @tc.level : Level 1 148 */ 149 it('testMuslMmanMadvise001', 0, async (done: Function) => { 150 let data: number = mman.mAdvise(); 151 console.info("Test NAPI data= " + JSON.stringify(data)); 152 expect(data).assertEqual(0); 153 done() 154 }); 155 /** 156 * @tc.number : SUB_THIRDPARTY_MUSL_MMAN_MLOCK_0100 157 * @tc.name : testMuslMmanMLock001 158 * @tc.desc : test mlock 159 * @tc.size : MediumTest 160 * @tc.type : Function 161 * @tc.level : Level 1 162 */ 163 it('testMuslMmanMLock001', 0, async (done: Function) => { 164 let result: number = mman.mLock(0); 165 expect(result).assertEqual(0) 166 done() 167 }); 168 169 /** 170 * @tc.number : SUB_THIRDPARTY_MUSL_MMAN_MLOCK_0200 171 * @tc.name : testMuslMmanMLock002 172 * @tc.desc : test mlock 173 * @tc.size : MediumTest 174 * @tc.type : Function 175 * @tc.level : Level 2 176 */ 177 it('testMuslMmanMLock002', 0, async (done: Function) => { 178 let result: number = mman.mLock(-1); 179 expect(result).assertEqual(-1) 180 done() 181 }); 182 183 /** 184 * @tc.number : SUB_THIRDPARTY_MUSL_MMAN_MLOCK2_0100 185 * @tc.name : testMuslMmanMLock2001 186 * @tc.desc : test mlock2 187 * @tc.size : MediumTest 188 * @tc.type : Function 189 * @tc.level : Level 1 190 */ 191 it('testMuslMmanMLock2001', 0, async (done: Function) => { 192 let result: number = mman.mLock2(0); 193 expect(result).assertEqual(0) 194 done() 195 }); 196 197 /** 198 * @tc.number : SUB_THIRDPARTY_MUSL_MMAN_MLOCK2_0200 199 * @tc.name : testMuslMmanMLock2002 200 * @tc.desc : test mlock2 201 * @tc.size : MediumTest 202 * @tc.type : Function 203 * @tc.level : Level 2 204 */ 205 it('testMuslMmanMLock2002', 0, async (done: Function) => { 206 let result: number = mman.mLock2(-1); 207 expect(result).assertEqual(-1) 208 done() 209 }); 210 211 /** 212 * @tc.number : SUB_THIRDPARTY_MUSL_MMAN_MLOCKALL_0100 213 * @tc.name : testMuslMmanMLockAll001 214 * @tc.desc : test mlockall 215 * @tc.size : MediumTest 216 * @tc.type : Function 217 * @tc.level : Level 1 218 */ 219 it('testMuslMmanMLockAll001', 0, async (done: Function) => { 220 let result: number = mman.mLockAll(); 221 expect(result).assertEqual(0) 222 done() 223 }); 224 225 /** 226 * @tc.number : SUB_THIRDPARTY_MUSL_MMAN_MMAP64_0100 227 * @tc.name : testMuslMmanMmap64001 228 * @tc.desc : test mmap64 229 * @tc.size : MediumTest 230 * @tc.type : Function 231 * @tc.level : Level 1 232 */ 233 it('testMuslMmanMmap64001', 0, async (done: Function) => { 234 let result: number = mman.mmap64(); 235 expect(result).assertEqual(0) 236 done() 237 }); 238 239 }) 240 241}