Commit Graph

4630 Commits

Author SHA1 Message Date
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 3ab762d4ac Will be fixed with regex update 2021-02-23 21:09:14 +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
rillig 199346cc31 lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
2021-02-22 15:09:50 +00:00
rillig 352df404f7 indent: add test demonstrating that indent cannot handle C99
indent cannot handle line-end comments.

The indent test suite requires each test file to have both a NetBSD and
a FreeBSD RCS ID.  If the FreeBSD RCS ID is missing, the test will
silently pass since in that case, an empty file is compared with an
empty file.  See the /start/,/end/ operator in t_indent.sh.
2021-02-21 21:26:26 +00:00
rillig 0826316a44 lint: add test for bit-field initialisation in traditional C 2021-02-21 14:49:23 +00:00
rillig 4bbce6e96b lint: add debug logging for initializing an array of unknown size
It is possible that the type name 'array[unknown_size]' may spill into
the user-visible diagnostics.  The current test suite does not cover
such a case.  Anyway, saying 'array[unknown_size]' is still better than
saying 'array[0]', which would be misleading.
2021-02-21 14:19:27 +00:00
rillig 43a6794406 lint: add test for initializing a character array using a string
The previous attempt took another code path than expected.  The
initialization of static_duration actually calls initstack_string.
2021-02-21 13:10:57 +00:00
rillig 6a0956331d lint: add more tests for C99 initialization 2021-02-21 12:49:05 +00:00
rillig 4c4ccffbb5 lint: add type information to message about enum mismatch 2021-02-21 10:28:32 +00:00
rillig c6411a2f09 lint: add test for enum mismatch in initialization
This warning is currently not user-friendly because it omits any type
information, but that information is crucial.
2021-02-21 10:12:29 +00:00
rillig 1214ba323a lint: add another test case for initializing an object 2021-02-21 09:19:53 +00:00
rillig ab7cfcc59b lint: fix wrong warning about main falling off the bottom in C99 mode
This gets lint a small step closer to implementing C99.
2021-02-21 09:17:55 +00:00
rillig 7eea542cc1 lint: force each test to declare the expected diagnostics
By listing the expected diagnostics directly at the code that triggers
the diagnostics, it is easier to cross-check whether the diagnostics
make sense.

No functional change to lint itself.
2021-02-21 09:07:58 +00:00
rillig 331de0363e lint: add another test for C99 initializers 2021-02-21 08:05:51 +00:00
rillig e83db15a89 lint: clean up some of the C99 tests
Several C99 tests do not actually test C99 features but instead GCC
features.  All these tests should be double-checked again.

In some other tests, split the initializers into more lines, which makes
it easier to read the debug log corresponding to these tests.  This will
be necessary for reworking the initializer code to actually conform to
C99.
2021-02-20 22:31:20 +00:00
rillig cc8ff9b7e7 lint: ensure that '# line' directives in tests are correct
It's too easy to forget one of them when adding or removing some lines.
This would make it more difficult to locate the lines referenced in the
error messages.
2021-02-20 22:18:32 +00:00
rillig d4c07c2ea4 lint: do not warn about 'do { ... } while (false)' in strict bool mode 2021-02-20 18:55:10 +00:00
rillig 2ed239de2f lint: add test for 'do { ... } while (false)' in strict bool mode
Right now, this variant of the popular macro pattern is flagged as
needing a /*CONSTCOND*/ annotation.  As with 'do { ... } while (0)',
there is nothing wrong with this pattern, therefore there should be no
warning.
2021-02-20 18:52:58 +00:00
rillig 9c7ebc631b lint: enable heuristics in test for strict bool mode
This is a preparation for allowing 'do { ... } while (false)', in
addition to the commonly used 'do { ... } while (0)', without declaring
the controlling expression /*CONSTCOND*/.
2021-02-20 18:49:26 +00:00
rillig 59c3c702bb lint: add test for using a bool as array index in strict bool mode 2021-02-20 18:02:58 +00:00
rillig c76961adb2 lint: add machine-readable expectations to test for initializer 2021-02-20 16:55:32 +00:00
rillig 2a03f024cd lint: fix typo in test for pop_member
The leader of a city should rather be a mayor than a major.
2021-02-20 16:51:18 +00:00
rillig 6e51f5af89 lint: reproduce the crash from ckgetopt.c 1.2
The intention of the getopt check was to analyze only those while loops
whose condition consists of the usual getopt call.  For all other while
loops, ck.while_level was intended to stay at 0.

This was not the case in ckgetopt.c 1.2 and has been fixed in ckgetopt.c
1.3.  The code did not document the intended invariants though, which it
should have done.  This will be done in a follow-up commit.
2021-02-20 09:40:42 +00:00
nia ada1367bac patch(1): add test cases for various backup file formats 2021-02-20 08:59:24 +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
rillig 746e9c89cf lint: warn about mismatch in getopt handling 2021-02-19 12:28:56 +00:00
kre 6974a2b259 PR bin/55979
Add a sh ATF test to demonstrate a bug in the way that \0 characters
are dropped from scripts.   This test will eventually be extended to
test other potential sh script input related issues.

When initially committed, this test should fail.  It should succeed
when the fix for the PR is committed (soon).

Nb: this tests only the \0 related issues from the PR, the MSAN
detected uninitialised variable (struct field) can only be detected
by MSAN, as it has no visible impact on the operation of the shell
when running on any real (or even emulated) hardware.
(It will, however, also be fixed).
2021-02-16 09:46:24 +00:00
joerg dd4f4a95ae Simplify to avoid copy based on the size of the source. 2021-02-15 15:55:50 +00:00
rillig 2944115b18 tests/lint: fix comments in test for message 124 2021-02-15 07:18:20 +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
joerg 0cf30132cd Adjust test cases to hit the fudge case after the changes in nbperf
itself.
2021-02-14 01:27:33 +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