Skip to content

Commit

Permalink
Add pty08 test
Browse files Browse the repository at this point in the history
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
acerv committed Jan 17, 2025
1 parent e04a831 commit b2399a3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions runtest/pty
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pty04 pty04
pty05 pty05
pty06 pty06
pty07 pty07
pty08 pty08
ptem01 ptem01
ptem02 ptem02
ptem03 ptem03
Expand Down
1 change: 1 addition & 0 deletions testcases/kernel/pty/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
/pty05
/pty06
/pty07
/pty08
38 changes: 38 additions & 0 deletions testcases/kernel/pty/pty08.c
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,
};

0 comments on commit b2399a3

Please sign in to comment.