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 <string.h>
17 #include <termios.h>
18 #include "test.h"
19
20 /**
21 * @tc.name : cfmakeraw_0100
22 * @tc.desc : Verify that the terminal is set to raw mode.
23 * @tc.level : Level 0
24 */
cfmakeraw_0100(void)25 void cfmakeraw_0100(void)
26 {
27 struct termios t;
28 memset(&t, 0xff, sizeof(t));
29 cfmakeraw(&t);
30
31 if ((t.c_iflag & (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON)) != 0U) {
32 t_error("%s t.c_iflag failed\n", __func__);
33 }
34 if ((t.c_oflag & OPOST) != 0U) {
35 t_error("%s t.c_oflag failed\n", __func__);
36 }
37 if ((t.c_lflag & (ECHO | ECHONL | ICANON | ISIG | IEXTEN)) != 0U) {
38 t_error("%s t.c_lflag failed\n", __func__);
39 }
40 if ((t.c_cflag & PARENB) != 0U) {
41 t_error("%s t.c_cflag failed\n", __func__);
42 }
43 if ((int)(t.c_cflag & CSIZE) != CS8) {
44 t_error("%s t.c_cflag failed\n", __func__);
45 }
46 if (t.c_cc[VMIN] != 1) {
47 t_error("%s t.c_cc[VMIN] failed\n", __func__);
48 }
49 if (t.c_cc[VTIME] != 0) {
50 t_error("%s t.c_cc[VTIME] failed\n", __func__);
51 }
52 }
53
main(int argc,char * argv[])54 int main(int argc, char *argv[])
55 {
56 cfmakeraw_0100();
57 return t_status;
58 }