Skip to content

Commit 222a93e

Browse files
author
DragonOS Dev
committed
test(tty): remove meaningless errno != ENOTTY checks after successful ioctl
L4: CHECK(errno != ENOTTY) and EXPECT_NE(errno, ENOTTY) guards after a successful ioctl call are meaningless — errno is undefined on success. The ioctl == 0 check already confirms the call did not fail, making the errno check redundant. Removed from both c_unitest and dunitest versions.
1 parent 2a69de6 commit 222a93e

2 files changed

Lines changed: 0 additions & 8 deletions

File tree

user/apps/c_unitest/test_tty_termios.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,16 @@ int main(void) {
8484

8585
errno = 0;
8686
CHECK(ioctl(pts, TCGETA, &tio) == 0, "ioctl TCGETA succeeds");
87-
CHECK(errno != ENOTTY, "TCGETA does not return ENOTTY");
8887

8988
tio.c_lflag |= ISIG;
9089
errno = 0;
9190
CHECK(ioctl(pts, TCSETA, &tio) == 0, "ioctl TCSETA succeeds");
92-
CHECK(errno != ENOTTY, "TCSETA does not return ENOTTY");
9391

9492
errno = 0;
9593
CHECK(ioctl(pts, TCSETAW, &tio) == 0, "ioctl TCSETAW succeeds");
96-
CHECK(errno != ENOTTY, "TCSETAW does not return ENOTTY");
9794

9895
errno = 0;
9996
CHECK(ioctl(pts, TCSETAF, &tio) == 0, "ioctl TCSETAF succeeds");
100-
CHECK(errno != ENOTTY, "TCSETAF does not return ENOTTY");
10197

10298
/* 5. Cross-check: TCGETA reports low 16 bits of what TCGETS reports. */
10399
struct termios full;

user/apps/tests/dunitest/suites/normal/tty_termios.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ TEST(TtyTermios, LegacyTcgeta) {
170170
errno = 0;
171171
ASSERT_EQ(ioctl(pty.slave.get(), TCGETA, &tio), 0)
172172
<< "TCGETA should succeed: errno=" << errno << " (" << strerror(errno) << ")";
173-
EXPECT_NE(errno, ENOTTY) << "TCGETA must not return ENOTTY";
174173
}
175174

176175
/* --------------------------------------------------------------------------
@@ -184,17 +183,14 @@ TEST(TtyTermios, LegacyTcsetaFamily) {
184183
errno = 0;
185184
EXPECT_EQ(ioctl(pty.slave.get(), TCSETA, &tio), 0)
186185
<< "TCSETA: errno=" << errno << " (" << strerror(errno) << ")";
187-
EXPECT_NE(errno, ENOTTY);
188186

189187
errno = 0;
190188
EXPECT_EQ(ioctl(pty.slave.get(), TCSETAW, &tio), 0)
191189
<< "TCSETAW: errno=" << errno << " (" << strerror(errno) << ")";
192-
EXPECT_NE(errno, ENOTTY);
193190

194191
errno = 0;
195192
EXPECT_EQ(ioctl(pty.slave.get(), TCSETAF, &tio), 0)
196193
<< "TCSETAF: errno=" << errno << " (" << strerror(errno) << ")";
197-
EXPECT_NE(errno, ENOTTY);
198194
}
199195

200196
/* --------------------------------------------------------------------------

0 commit comments

Comments
 (0)