• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) International Business Machines  Corp., 2002
4  * Copyright (c) 2020 Petr Vorel <pvorel@suse.cz>
5  * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
6  */
7 
8 /*\
9  * [Description]
10  *
11  * Verify that it's possible to open a pseudo-terminal via /dev/ptmx, obtain a
12  * slave device and to send a break to both master and slave.
13  */
14 
15 #define _GNU_SOURCE
16 
17 #include <termios.h>
18 #include "common.h"
19 
20 static int masterfd = -1;
21 
run(void)22 static void run(void)
23 {
24 	int slavefd;
25 
26 	slavefd = open_slave(masterfd);
27 
28 	TST_EXP_PASS(tcsendbreak(masterfd, 10));
29 	TST_EXP_PASS(tcsendbreak(slavefd, 10));
30 
31 	SAFE_CLOSE(slavefd);
32 }
33 
setup(void)34 static void setup(void)
35 {
36 	masterfd = open_master();
37 }
38 
cleanup(void)39 static void cleanup(void)
40 {
41 	if (masterfd != -1)
42 		SAFE_CLOSE(masterfd);
43 }
44 
45 static struct tst_test test = {
46 	.test_all = run,
47 	.setup = setup,
48 	.cleanup = cleanup,
49 };
50