Skip to content

Commit 39f9060

Browse files
author
DragonOS Dev
committed
test(tty): document test duplication rationale and drain coverage gap
L3: Add header comment in test_tty_termios.c explaining why both the C (c_unitest) and C++ (dunitest) versions exist — the C version is a fast self-contained smoke test for environments where dunitest cannot run (no gtest/runner/rootfs). L5: Add TODO comments in both test files noting the missing drain stress test (master writes data → slave TCSADRAIN → verify drain actually waited for output completion).
1 parent 222a93e commit 39f9060

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

user/apps/c_unitest/test_tty_termios.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// test_tty_termios.c — quick smoke test for TTY termios/termio ioctls.
2+
//
3+
// This file intentionally overlaps with dunitest/suites/normal/tty_termios.cc.
4+
// The C version is a fast, self-contained static binary for QEMU serial-console
5+
// smoke testing. The C++ gtest version is the full CI regression suite.
6+
// Keep both: the C test catches regressions in environments where dunitest
7+
// (which requires gtest, a runner, and a rootfs) cannot run.
18
// test_tty_termios.c — verify TCSAFLUSH / TCSADRAIN and legacy termio ioctls
29
// on a valid TTY fd (PTY slave).
310
//
@@ -70,7 +77,9 @@ int main(void) {
7077
CHECK(tcgetattr(pts, &back) == 0, "tcgetattr after TCSANOW");
7178
CHECK((back.c_lflag & (ICANON | ECHO)) == 0, "TCSANOW settings survive");
7279

73-
/* 2. tcsetattr TCSADRAIN — must not fail with ENOTTY. */
80+
/* 2. tcsetattr TCSADRAIN — must not fail with ENOTTY.
81+
* TODO: add a stress test where master writes data → slave TCSADRAIN
82+
* → verify drain actually waited for output to complete. */
7483
CHECK(tcsetattr(pts, TCSADRAIN, &t) == 0, "tcsetattr TCSADRAIN succeeds");
7584

7685
/* 3. tcsetattr TCSAFLUSH — the dpkg/apt regression. */

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ TEST(TtyTermios, TcSanowRoundTrip) {
130130
}
131131

132132
/* --------------------------------------------------------------------------
133-
* tcsetattr TCSADRAIN — must not fail with ENOTTY
133+
* tcsetattr TCSADRAIN — must not fail with ENOTTY.
134+
* TODO: add a stress test where master writes data → slave TCSADRAIN
135+
* → verify drain actually waited for output to complete.
134136
* -------------------------------------------------------------------------- */
135137
TEST(TtyTermios, TcsadrainSucceeds) {
136138
auto pty = OpenRawPty();

0 commit comments

Comments
 (0)