1/* 2 * Copyright (C) 2022 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 <stdlib.h> 17#include <unistd.h> 18#include <threads.h> 19#include "functionalext.h" 20 21static mtx_t g_mtx; 22 23/** 24 * @tc.name : mtx_init. 25 * @tc.desc : Verify mtx_init process success when second args is mtx_plain. 26 * @tc.desc : level 0 27 */ 28void mtx_init_0100(void) 29{ 30 int32_t ret = 0; 31 ret = mtx_init(&g_mtx, mtx_plain); 32 EXPECT_EQ("mtx_init_0100", ret, thrd_success); 33} 34 35/** 36 * @tc.name : mtx_init. 37 * @tc.desc : Verify mtx_init process success when second args is mtx_timed. 38 * @tc.desc : level 1 39 */ 40void mtx_init_0200(void) 41{ 42 int32_t ret = 0; 43 ret = mtx_init(&g_mtx, mtx_timed); 44 EXPECT_EQ("mtx_init_0200", ret, thrd_success); 45} 46 47/** 48 * @tc.name : mtx_init. 49 * @tc.desc : Verify mtx_init process success when second args is mtx_plain | mtx_recursive. 50 * @tc.desc : level 0 51 */ 52void mtx_init_0300(void) 53{ 54 int32_t ret = 0; 55 ret = mtx_init(&g_mtx, mtx_plain | mtx_recursive); 56 EXPECT_EQ("mtx_init_0300", ret, thrd_success); 57} 58 59/** 60 * @tc.name : mtx_init. 61 * @tc.desc : Verify mtx_init process success when second args is mtx_timed | mtx_recursive. 62 * @tc.desc : level 0 63 */ 64void mtx_init_0400(void) 65{ 66 int32_t ret = 0; 67 ret = mtx_init(&g_mtx, mtx_timed | mtx_recursive); 68 EXPECT_EQ("mtx_init_0400", ret, thrd_success); 69} 70 71int main(void) 72{ 73 mtx_init_0100(); 74 mtx_init_0200(); 75 mtx_init_0300(); 76 mtx_init_0400(); 77 return t_status; 78} 79