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 <fcntl.h> 17#include <pty.h> 18#include <stdlib.h> 19#include <sys/ioctl.h> 20#include <unistd.h> 21#include "functionalext.h" 22 23/** 24 * @tc.name : openpty_0100 25 * @tc.desc : Open the ptm file to establish a pseudo terminal, and determine 26 * whether the terminal descriptor is successfully obtained 27 * @tc.level : Level 0 28 */ 29void openpty_0100(void) 30{ 31 int amaster, aslave; 32 int ret = openpty(&amaster, &aslave, NULL, NULL, NULL); 33 34 EXPECT_EQ("openpty_0100", ret, CMPFLAG); 35 EXPECT_NE("openpty_0100", amaster, ERREXPECT); 36 EXPECT_NE("openpty_0100", aslave, ERREXPECT); 37} 38 39/** 40 * @tc.name : openpty_0200 41 * @tc.desc : Open the ptm file to establish a pseudo terminal, and judge 42 * whether the function successfully obtains the terminal name 43 * @tc.level : Level 0 44 */ 45void openpty_0200(void) 46{ 47 int amaster, aslave; 48 char name[32] = {0}; 49 struct termios tio; 50 struct winsize size; 51 int ret = openpty(&amaster, &aslave, name, &tio, &size); 52 EXPECT_EQ("openpty_0200", ret, CMPFLAG); 53 EXPECT_NE("openpty_0200", amaster, ERREXPECT); 54 EXPECT_NE("openpty_0200", aslave, ERREXPECT); 55} 56 57int main(void) 58{ 59 openpty_0100(); 60 openpty_0200(); 61 return t_status; 62}