Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src libcurses: demonstrate bug in addch that doubles tab indenta...



details:   https://anonhg.NetBSD.org/src/rev/272de1855610
branches:  trunk
changeset: 951590:272de1855610
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 07 01:53:54 2021 +0000

description:
libcurses: demonstrate bug in addch that doubles tab indentation

When adding "\t" via addch, win.curx advances by twice the spaces as
intended.  This bug was introduced somewhere between NetBSD 8.0 and 9.0.

Adding "\t" via addstr does not have this bug.

This bug causes the installation menu of sysinst to be have its menu
items indented by 16 characters instead of only 8.  This in turn
produces an ugly line break in the German translation.

The test framework for libcurses is not well integrated into ATF.
Whenever the expected output is longer than the actual output, or vice
versa, the test passes nevertheless.  This makes it necessary to
constantly look into atf-run.log to see whether the actual output is
indeed equal to the expected output, which is crucial, especially for
telling the difference between addstr and addnstr.

Reusing the .chk files for several tests is not a good idea either.  For
example, addstr and waddstr are supposed to produce the same result for
ASCII-only text, so it was tempting to use the same file.  But waddstr
seems to have a bug (maybe undefined behavior), at least waddstr returns
ERR in one case where it shouldn't.  This means that currently the
expected output (acknowledging the bug) must be different.

The "expected" test output in waddstr.chk looks completely broken, but
that's exactly what the test produces right now.

diffstat:

 distrib/sets/lists/tests/mi                 |   4 +++-
 tests/lib/libcurses/check_files/Makefile    |   4 +++-
 tests/lib/libcurses/check_files/addch.chk   |   3 ++-
 tests/lib/libcurses/check_files/addnstr.chk |   1 +
 tests/lib/libcurses/check_files/addstr.chk  |   3 ++-
 tests/lib/libcurses/check_files/waddstr.chk |   1 +
 tests/lib/libcurses/tests/addch             |  18 +++++++++++++++++-
 tests/lib/libcurses/tests/addnstr           |   3 +--
 tests/lib/libcurses/tests/addstr            |   5 ++++-
 tests/lib/libcurses/tests/waddnstr          |   2 +-
 tests/lib/libcurses/tests/waddstr           |  11 ++++++++---
 11 files changed, 43 insertions(+), 12 deletions(-)

diffs (152 lines):

diff -r 3565f21199b4 -r 272de1855610 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sat Feb 06 22:00:59 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Feb 07 01:53:54 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1015 2021/02/01 20:31:41 rillig Exp $
+# $NetBSD: mi,v 1.1016 2021/02/07 01:53:54 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3265,6 +3265,7 @@
 ./usr/tests/lib/libcurses/check_files/addchstr.chk             tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/addchstr2.chk            tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/addchstr3.chk            tests-lib-tests         compattestfile,atf
+./usr/tests/lib/libcurses/check_files/addnstr.chk              tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/addnwstr1.chk            tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/addnwstr2.chk            tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/addstr.chk               tests-lib-tests         compattestfile,atf
@@ -3475,6 +3476,7 @@
 ./usr/tests/lib/libcurses/check_files/waddchstr.chk            tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/waddnwstr1.chk           tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/waddnwstr2.chk           tests-lib-tests         compattestfile,atf
+./usr/tests/lib/libcurses/check_files/waddstr.chk              tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/waddwstr1.chk            tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/waddwstr2.chk            tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libcurses/check_files/waddwstr3.chk            tests-lib-tests         compattestfile,atf
diff -r 3565f21199b4 -r 272de1855610 tests/lib/libcurses/check_files/Makefile
--- a/tests/lib/libcurses/check_files/Makefile  Sat Feb 06 22:00:59 2021 +0000
+++ b/tests/lib/libcurses/check_files/Makefile  Sun Feb 07 01:53:54 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4 2020/10/24 14:21:25 martin Exp $
+# $NetBSD: Makefile,v 1.5 2021/02/07 01:53:54 rillig Exp $
 
 NOMAN=         # defined
 
@@ -17,6 +17,7 @@
 FILES+=                addchstr.chk
 FILES+=                addchstr2.chk
 FILES+=                addchstr3.chk
+FILES+=                addnstr.chk
 FILES+=                addnwstr1.chk
 FILES+=                addnwstr2.chk
 FILES+=                addstr.chk
@@ -226,6 +227,7 @@
 FILES+=                waddchstr.chk
 FILES+=                waddnwstr1.chk
 FILES+=                waddnwstr2.chk
+FILES+=                waddstr.chk
 FILES+=                waddwstr1.chk
 FILES+=                waddwstr2.chk
 FILES+=                waddwstr3.chk
diff -r 3565f21199b4 -r 272de1855610 tests/lib/libcurses/check_files/addch.chk
--- a/tests/lib/libcurses/check_files/addch.chk Sat Feb 06 22:00:59 2021 +0000
+++ b/tests/lib/libcurses/check_files/addch.chk Sun Feb 07 01:53:54 2021 +0000
@@ -1,1 +1,2 @@
-smsotrmsocup6;4Xsmsosmulermsormul
\ No newline at end of file
+smsotrmsocup6;4Xsmsosmulermsormulcup7;17X8
+0123456  8
diff -r 3565f21199b4 -r 272de1855610 tests/lib/libcurses/check_files/addnstr.chk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libcurses/check_files/addnstr.chk       Sun Feb 07 01:53:54 2021 +0000
@@ -0,0 +1,1 @@
+abcde
\ No newline at end of file
diff -r 3565f21199b4 -r 272de1855610 tests/lib/libcurses/check_files/addstr.chk
--- a/tests/lib/libcurses/check_files/addstr.chk        Sat Feb 06 22:00:59 2021 +0000
+++ b/tests/lib/libcurses/check_files/addstr.chk        Sun Feb 07 01:53:54 2021 +0000
@@ -1,1 +1,2 @@
-abcde
\ No newline at end of file
+abcdecup3;9X8
+0123456 8
diff -r 3565f21199b4 -r 272de1855610 tests/lib/libcurses/check_files/waddstr.chk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libcurses/check_files/waddstr.chk       Sun Feb 07 01:53:54 2021 +0000
@@ -0,0 +1,1 @@
+home
\ No newline at end of file
diff -r 3565f21199b4 -r 272de1855610 tests/lib/libcurses/tests/addch
--- a/tests/lib/libcurses/tests/addch   Sat Feb 06 22:00:59 2021 +0000
+++ b/tests/lib/libcurses/tests/addch   Sun Feb 07 01:53:54 2021 +0000
@@ -1,6 +1,22 @@
 include start
 call OK addch `\001t`
 call OK refresh
-call OK mvaddch 5 3`\003e`
+call OK mvaddch 5 3 `\003e`
+call OK refresh
+call OK addch "\n"
+
+# Somewhere between NetBSD 8.0 and 9.0, a bug was added to addch that
+# doubled the spaces for a tab.  Instead of 8 spaces, there are now 16.
+call OK addch "\t"
+call OK addch "8"
+call OK addch "\n"
+
+# Somewhere between NetBSD 8.0 and 9.0, a bug was added to addch that
+# doubled the spaces for a tab.  Instead of 1 space, there are now 2.
+call OK addstr "0123456"
+call OK addch "\t"
+call OK addch "8"
+call OK addch "\n"
+
 call OK refresh
 compare addch.chk
diff -r 3565f21199b4 -r 272de1855610 tests/lib/libcurses/tests/addnstr
--- a/tests/lib/libcurses/tests/addnstr Sat Feb 06 22:00:59 2021 +0000
+++ b/tests/lib/libcurses/tests/addnstr Sun Feb 07 01:53:54 2021 +0000
@@ -1,5 +1,4 @@
 include start
 call OK addnstr "abcdefg" 5
 call OK refresh
-# should be the same as addstr
-compare addstr.chk
+compare addnstr.chk
diff -r 3565f21199b4 -r 272de1855610 tests/lib/libcurses/tests/addstr
--- a/tests/lib/libcurses/tests/addstr  Sat Feb 06 22:00:59 2021 +0000
+++ b/tests/lib/libcurses/tests/addstr  Sun Feb 07 01:53:54 2021 +0000
@@ -1,4 +1,7 @@
 include start
-call OK addstr "abcde"
+call OK addstr "abcde\n"
+call OK addstr "\n"
+call OK addstr "\t8\n"
+call OK addstr "0123456\t8\n"
 call OK refresh
 compare addstr.chk
diff -r 3565f21199b4 -r 272de1855610 tests/lib/libcurses/tests/waddnstr
--- a/tests/lib/libcurses/tests/waddnstr        Sat Feb 06 22:00:59 2021 +0000
+++ b/tests/lib/libcurses/tests/waddnstr        Sun Feb 07 01:53:54 2021 +0000
@@ -1,4 +1,4 @@
 include window
 call OK waddnstr $win1 "abcdefg" 5
 call OK wrefresh $win1
-compare addstr.chk
+compare addnstr.chk
diff -r 3565f21199b4 -r 272de1855610 tests/lib/libcurses/tests/waddstr
--- a/tests/lib/libcurses/tests/waddstr Sat Feb 06 22:00:59 2021 +0000
+++ b/tests/lib/libcurses/tests/waddstr Sun Feb 07 01:53:54 2021 +0000
@@ -1,4 +1,9 @@
 include window
-call OK waddstr $win1 "abcde"
-call OK wrefresh $win1
-compare addstr.chk
+call OK waddstr $win1 "abcde\n"
+call OK waddstr $win1 "\n"
+call OK waddstr $win1 "\t8\n"
+# XXX: The following line causes an unexpected "ERR Resource temporarily
+# unavailable" on NetBSD/amd64 9.99.80.
+#call OK waddstr $win1 "0123456\t8\n"
+call OK refresh
+compare waddstr.chk



Home | Main Index | Thread Index | Old Index