-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verify that slave pseudo-terminal fails reading/writing if master has been closed. Reviewed-by: Cyril Hrubis <[email protected]> Signed-off-by: Andrea Cervesato <[email protected]>
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ pty04 pty04 | |
pty05 pty05 | ||
pty06 pty06 | ||
pty07 pty07 | ||
pty08 pty08 | ||
ptem01 ptem01 | ||
ptem02 ptem02 | ||
ptem03 ptem03 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ | |
/pty05 | ||
/pty06 | ||
/pty07 | ||
/pty08 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
/* | ||
* Copyright (c) International Business Machines Corp., 2002 | ||
* Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]> | ||
*/ | ||
|
||
/*\ | ||
* [Description] | ||
* | ||
* Verify that slave pseudo-terminal fails reading/writing if master has been | ||
* closed. | ||
*/ | ||
|
||
#define _GNU_SOURCE | ||
|
||
#include "common.h" | ||
|
||
static void run(void) | ||
{ | ||
int slavefd; | ||
int masterfd; | ||
char buf; | ||
|
||
masterfd = open_master(); | ||
slavefd = open_slave(masterfd); | ||
|
||
tst_res(TINFO, "Closing master communication"); | ||
SAFE_CLOSE(masterfd); | ||
|
||
TST_EXP_EQ_LI(read(slavefd, &buf, 1), 0); | ||
TST_EXP_FAIL(write(slavefd, &buf, 1), EIO); | ||
|
||
SAFE_CLOSE(slavefd); | ||
} | ||
|
||
static struct tst_test test = { | ||
.test_all = run, | ||
}; |