• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <errno.h>
17 #include <fcntl.h>
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <termios.h>
21 #include "test.h"
22 
23 /**
24  * @tc.name      : tcgetsid_0100
25  * @tc.desc      : Get session ID
26  * @tc.level     : Level 0
27  */
tcgetsid_0100(void)28 void tcgetsid_0100(void)
29 {
30     errno = 0;
31     pid_t sid;
32 
33     sid = tcgetsid(STDIN_FILENO);
34     if (sid == -1) {
35         t_error("%s tcgetsid failed\n", __func__);
36     }
37     if (errno != 0) {
38         t_error("%s errno is %d\n", __func__, errno);
39     }
40 }
41 
42 /**
43  * @tc.name      : tcgetsid_0200
44  * @tc.desc      : Fd is not a valid file descriptor
45  * @tc.level     : Level 2
46  */
tcgetsid_0200(void)47 void tcgetsid_0200(void)
48 {
49     errno = 0;
50     pid_t sid;
51     sid = tcgetsid(-1);
52     if (sid != -1) {
53         t_error("%s tcgetsid should failed, sid is %d", __func__, sid);
54     }
55     if (errno != EBADF) {
56         t_error("%s errno is %d", __func__, errno);
57     }
58 }
59 
main(int argc,char * argv[])60 int main(int argc, char *argv[])
61 {
62     tcgetsid_0100();
63     tcgetsid_0200();
64     return t_status;
65 }