Commit Graph

1901 Commits

Author SHA1 Message Date
simonb
7f74343bad Sprinkle a few more \n's and the end of some debug printfs. 2021-03-19 00:44:09 +00:00
christos
d2bbb37090 Adjust for conditional NLS 2021-02-25 22:37:36 +00:00
rillig
2632d6d7a1 tests/libcurses: add test for '\b' in addch
Just to ensure that addch and addstr behave the same, after the recent
fix for handling '\t'.
2021-02-25 01:07:43 +00:00
rillig
e9c1f91ac6 tests/libcurses: use common style for parse error messages 2021-02-25 00:50:10 +00:00
rillig
fecd441893 tests/libcurses: use common syntax for accessing array elements
Writing *(p+1) is needlessly confusing, even though it adds a little
symmetry between *p and *(p+1).  Still, one of these expressions has
parentheses, the other doesn't, which breaks the symmetry.

Wrap overly long code line.

It's confusing to refer to the digits after the backslash once with
index 0 to 2, and the other time with index 1 to 3.
2021-02-25 00:42:00 +00:00
rillig
fede2462fc tests/libcurses: reduce indentation
No functional change.
2021-02-25 00:32:44 +00:00
rillig
91f6e103ad libcurses: ensure that '\b' in handled correctly in addstr
Just to ensure that the recent fix for '\t' handling in addstr/addch
didn't introduce another bug.
2021-02-25 00:26:57 +00:00
rillig
166112aa2a libcurses: prevent unknown escpae sequences in tests
Before, '\b' was interpreted as a simple 'b', which is confusing for C
programmers.  Same for '\a'.  There is absolutely no reason to escape
letters, so fail early in these cases.

The '\h' in the test addchstr was obviously a typo that was easy to
detect, if only the compiler had been strict enough from the very
beginning.

The code is wider than 80 characters, same as the code that parses octal
escape sequences a few lines above it.  This code will be refactored to
use less indentation in a follow-up commit.
2021-02-25 00:25:31 +00:00
christos
0cd1e61982 remove casts 2021-02-24 18:18:53 +00:00
christos
5e019a0a0d minimal fix to match the library code (really make the constants unsigned
instead)
2021-02-24 02:33:56 +00:00
christos
8621598a26 Add REG_GNU 2021-02-23 17:13:44 +00:00
christos
e78273b60d Add support for ENOSYS (was never set) 2021-02-23 16:00:37 +00:00
christos
3d2aab1347 Add REG_POSIX, and make compile on linux where we don't have a lot of the
internal flags.
2021-02-23 15:00:01 +00:00
christos
df5681bdd2 Delete category stuff that has changed with the new regex; make compile
on linux and with TRE
2021-02-23 14:59:09 +00:00
christos
cd73f43310 Comment out tests that the new stricter regex does not like 2021-02-23 14:57:16 +00:00
martin
2916a307c1 PR kern/55272: do not skip this test on single cpu machines - it is not
the only test causing the watchdog starvation and we better find and
fix the real issue.
2021-02-19 18:36:50 +00:00
joerg
dd4f4a95ae Simplify to avoid copy based on the size of the source. 2021-02-15 15:55:50 +00:00
rillig
65e35d76dc tests/libcurses: fix error handling for non-system errors
These errors are unrelated to errno.  The scanf family of functions also
does not set errno.
2021-02-15 07:06:27 +00:00
rillig
f6084dc243 tests/libcurses: document the history about tab bugs in addch/addstr
Verified by installing all versions of libcurses from 2012 to 2021 and
running a simple test program on them:

	#include <stdio.h>
	#include <curses.h>

	int
	main(int argc, char **argv)
	{
		int xstr, ystr, xch, ych;

		initscr();

		addstr("\t");
		xstr = getcurx(stdscr);
		addstr("\n");
		ystr = getcury(stdscr);

		addch('\t');
		xch = getcurx(stdscr);
		addch('\n');
		ych = getcury(stdscr);

		endwin();

		fprintf(stderr, "%s\t%d,%d\t%d,%d\n",
		    argv[1], ystr, xstr, ych, xch);
	}

Some selected outputs:

	...
	2016.11.24.14.49.08	1,0	2,8
	2016.11.28.18.25.26     1,8	2,8
	...
	2019.05.12.02.29.00	1,8	2,8
	2019.05.20.22.17.41	1,8	2,16
	...
	2021.02.13.10.37.00	1,8	2,16
	2021.02.13.14.30.37	1,8	2,8
2021-02-14 11:21:37 +00:00
rillig
1131246067 tests/libcurses: note that addbytes is not part of the API
https://mail-index.netbsd.org/source-changes-d/2021/02/13/msg013199.html
2021-02-13 22:19:47 +00:00
rillig
73417462e0 tests/libcurses: protect against short writes
The previous code only errored out if a write failed completely.  If it
was partially written, the program continued without writing the rest of
it.

Extract the common code into a few functions that write raw data to the
parent process.
2021-02-13 19:23:11 +00:00
rillig
9966483c8a tests/libcurses: remove unused code in linter 2021-02-13 18:24:11 +00:00
rillig
f48ee0a965 tests/libcurses: use ASCII only in terminfo description 2021-02-13 16:43:12 +00:00
rillig
c12d26a726 tests/libcurses: split terminfo entry over more lines
This provides space to see each capability on its own, instead of having
to search them in the blob of text.
2021-02-13 16:38:02 +00:00
rillig
609d11bc47 libcurses: fix wrong tab width for addch
In sysinst, the installation screen is indented with tabs.  Sysinst uses
msgc, which brings its own text layout engine.  This engine does not use
addbytes but addch.  In addch, the x position for each tab was advanced
twice as much as needed.  The menu items were thus not indented by 8
spaces but by 16, which caused an ugly line break in the German
translation.

This bug largely went unnoticed because most other applications use
addbytes instead, which worked fine all the time.  It had been
introduced somewhere between NetBSD 8.0 and NetBSD 9.0.

The code around this bug used aliased variables for win->curx and
win->cury a lot.  Getting this right is difficult and needs a thorough
test suite.  Even though libcurses has 201 tests, that is not nearly
enough to cover all the relations between the various functions in
libcurses that call each other, crossing API boundaries from internal
to external, doing character conversions on the way and juggling around
4 different types of characters (char, wchar_t, chtype, cchar_t).

The simplest fix was to remove all this aliasing, while keeping the
API the same.  If _cursesi_waddbytes is not considered part of the API,
it would be possible to replace px with win->curx in all places, same
for py and win->cury.

The complicated code with the aliasing may have been meant for
performance reasons, but it's hard to see any advantage if both points
of truth need to be synchronized all the time.

Libcurses can be built in 2 modes: with wide character support or
without (-DDISABLE_WCHAR).  The test suite only covers the variant with
wide characters.  The single-byte variant has to be tested manually.
Running sysinst with the single-byte libcurses produces the correct
layout.
2021-02-13 14:30:37 +00:00
rillig
86536876fb tests/libcurses: extract read_command_argument from process_commands
Having code indented so far to the right that each word gets its own
line is ridiculous.  Fix that.

While here, remove the cargo-cult realloc pattern, which is not needed
if the process exits immediately on error.

While here, reduce the indentation of the code by returning early.

No functional change.
2021-02-13 10:03:49 +00:00
rillig
78dd027b59 tests/libcurses: fix reading from the parent process
In case of a short read, processing the incomplete data invoked
undefined behavior.
2021-02-13 09:28:27 +00:00
rillig
2eec569208 tests/libcurses: fix child process handling
The child process needs to be properly controlled by the parent process.
Otherwise it is not possible to get code coverage data from it using
gcov since that requires the child process to exit normally.  Previously
the child process had been killed because its parent had exited.
2021-02-13 09:18:12 +00:00
rillig
2d435e1f5f tests/libcurses: fix error messages 2021-02-13 08:43:03 +00:00
rillig
c671531bee tests/libcurses: "fix" test mvwin
The test mvwin previously expected an endless stream of bytes, by
comparing the actual output with /dev/zero.  This didn't make sense as
the curses output does not contain '\0' in any of the test cases.

Compare with /dev/null instead.  This is as wrong as before, but the
curses test framework currently ignores this situation, as for many
other test cases.  See the numerous "Excess" messages in atf-run.log.
2021-02-13 08:37:21 +00:00
rillig
08813b709b tests/libcurses: remove undocumented, unused command line option
The option -T has the same effect as the removed option -p.
2021-02-13 08:26:12 +00:00
rillig
dcdcb866a3 tests/libcurses: remove include path from usage message
The option has been removed a few minutes ago.
2021-02-13 08:22:34 +00:00
rillig
177fdb97a1 tests/libcurses: clean up remaining include guard, comments
No functional change.
2021-02-13 08:17:15 +00:00
rillig
cf012ad48f tests/libcurses: clean up inclusion guards, function declarations
No functional change.
2021-02-13 08:14:46 +00:00
rillig
dfef510f35 tests/libcurses: remove include path handling
All include commands in the current test suite use relative paths.
Instead of a fixed include path, interpret the included filename
relative to the including file.
2021-02-13 08:00:07 +00:00
rillig
8e1e8b7233 tests/libcurses: align comments 2021-02-13 07:32:19 +00:00
rillig
c8713e3dc5 tests/libcurses: fix misleading usage documentation
The check-files are not config files.
2021-02-13 07:31:07 +00:00
rillig
1b4c237756 tests/libcurses: fix pipe handling in the parent process
The parent process, like the child process, needs only 2 of the 4 pipe
ends.

In verbose mode (now at testlang_parse.y:1151 and :1154), both ends of the
pipe_from_slave were examined.  This looked like a typo and has been fixed
to those pipe ends that are relevant to the parent process.
2021-02-13 07:08:45 +00:00
rillig
26ce28a5a0 tests/libcurses: fix pipe handling in child process
The child process only ever needs 2 ends of the pipes: one for reading
the commands, one for writing back the results.
2021-02-13 06:45:42 +00:00
rillig
ff6217c297 tests/libcurses: add test for addbytes 2021-02-13 06:29:45 +00:00
rillig
2f4dbca7fd tests/libcurses: fix warnings for missing environment variables 2021-02-13 05:38:16 +00:00
rillig
ef1df6f9cf tests/libcurses: format misleading do-while loop 2021-02-12 21:29:54 +00:00
rillig
18799db59b tests/libcurses: remove wrong comments 2021-02-12 21:29:03 +00:00
rillig
ca234efa6a tests/libcurses: remove excess empty lines 2021-02-12 20:45:00 +00:00
rillig
450da2d661 tests/libcurses: query function arguments in consistent order 2021-02-12 20:41:37 +00:00
rillig
25ddeb49df tests/libcurses: don't access args directly
By providing declarative syntax for accessing the arguments, the
unnecessarily detailed boilerplate code is hidden.  This allows easy
inspection by tools and humans, to check for typos and other mistakes.
2021-02-12 18:20:05 +00:00
rillig
5326ff7afe tests/libcurses: replace ARG_CHTYPE_STRING with ARG_CHTYPE
All uses of the previous macro did not treat the argument as a string or
array of chtype, but as a single chtype.  It's strange that the previous
code arbitrarily split the access to the argument by first storing it as
a pointer and then dereferencing it.

No functional change.
2021-02-12 16:59:32 +00:00
rillig
a346ecb379 tests/libcurses: add shortcut macros for SCREEN and unsigned int 2021-02-12 16:49:18 +00:00
rillig
c7ac460c19 tests/libcurses: remove redundant comments
There is nothing surprising about call2, call3 or call4.
2021-02-12 14:05:57 +00:00
rillig
1fe7fa71d8 tests/libcurses: reduce boilerplate in function dispatcher
No functional change.  The generated code for GCC 9.3 on NetBSD 9.99.80
x86_64 is exactly the same as before.
2021-02-12 12:58:52 +00:00