Commit Graph

1901 Commits

Author SHA1 Message Date
rillig
b1b4392b00 tests/libcurses: reduce boilerplate in function dispatcher
This makes the code more declarative and easier to reason about.

The generated code stays exactly the same.
2021-02-12 08:55:32 +00:00
rillig
518cbcb21b tests/libcurses: add missing space after control flow keywords 2021-02-09 20:42:31 +00:00
rillig
6938509815 tests/libcurses: replace remaining strcasecmp with strcmp
There is no reason to write special functions in a different case than
the canonical one, just like for the regular curses functions.
2021-02-09 20:39:20 +00:00
rillig
e91849a6b1 tests/libcurses: fix spelling of the special call to DRAIN 2021-02-09 20:31:02 +00:00
rillig
82a08c1a4a tests/libcurses: compare function names case-sensitive
There is absolutely no reason to write function names in upper case or
mixed case.
2021-02-09 20:24:02 +00:00
rillig
74a9e3d2cc tests/libcurses: fix scanf parameter for unsigned int 2021-02-09 20:22:11 +00:00
rillig
03f821dbf2 tests/libcurses: fix off-by-one error in line numbers in diagnostics
I had broken this in testlang_parse.y 1.22 from 2021-02-07, when I
extracted the common 'eol' from the statements.  Extracting 'eol' had
the effect that the action for the statement was run before the line
number increased.

Now the line numbers in the diagnostics are the same again as before.

For lines that end with a backslash, the reported line number is the one
from the last of these lines, not the first one, also as before.  This
feature is not used by any of the current tests though.
2021-02-08 23:54:03 +00:00
joerg
cfe420e9b1 Don't define a label twice. 2021-02-08 23:50:25 +00:00
rillig
facc9c9e92 tests/libcurses: use consistent indentation for grammar rules 2021-02-08 20:55:42 +00:00
rillig
91cc09774d tests/libcurses: extract functions 'input' and 'noinput' from grammar 2021-02-08 20:39:33 +00:00
rillig
9e7915b0b6 tests/libcurses: indent grammar functions consistently 2021-02-08 20:26:46 +00:00
rillig
66374bbd09 tests/libcurses: declare %type in grammar
It looks as if the original author just didn't know how to declare the
type of non-terminals.  The explicit types in the '$' expressions were
all consistent.

No functional change.
2021-02-08 20:09:45 +00:00
rillig
9dc059c978 tests/libcurses: extract function 'delay_millis' from the grammar 2021-02-08 19:35:21 +00:00
rillig
b798190935 tests/libcurses: move function 'check' out of the grammar section
This removes the inconsistent indentation.
2021-02-08 19:28:08 +00:00
rillig
09f966d145 tests/libcurses: fix typo in license text 2021-02-08 19:15:20 +00:00
rillig
057f5777ce tests/libcurses: remove unused token DRAIN
There is a special function named 'DRAIN', but not a statement.  The
function name does not need its own token.
2021-02-08 19:09:59 +00:00
rillig
12fb37738f tests/libcurses: fix sentinel for execl
For systems where NULL is defined as a simple 0 or 0L.
2021-02-08 19:04:37 +00:00
rillig
dc127031c2 tests/libcurses: on errors, print nonprintable characters as well 2021-02-08 19:00:22 +00:00
rillig
7879077738 tests/libcurses: fix undefined behavior in test addch
The libcurses framework is not strictly typed and thus provides plenty
of ways to shoot yourself in the foot.  It's a waste of time debugging
things that a proper programming language can easily prevent.

The function addch expects an argument of type 'chtype'.  Passing a
"double-quoted" string does not match this, as 'chtype' is completely
different from a plain 'char'.  Instead, functions taking a 'chtype'
must be passed a `backtick-quoted` string.
2021-02-07 23:30:33 +00:00
rillig
1f48f93d43 tests/libcurses: use a single message style for diagnostics
Previously, there were several concurring styles:

	$msg in line %zu of file %s
	$msg line %zu of file %s
	%s, %zu: $msg

All these are now replaced with "%s:%zu: $msg".
2021-02-07 21:33:27 +00:00
rillig
9b3211a8fb tests/libcurses: make grammar for test cases conflict-free
No functional change.
2021-02-07 20:48:07 +00:00
rillig
9903d631af tests/libcurses: fix grammar for arrays
Previously, commas were completely ignored by the grammar.  Erroring out
on invalid characters made some of the tests fail since the comma was
not recognized anymore.  Add it back, but only for defining arrays.  It
would have been possible to leave out the commas or make them optional,
but since the current tests do not make use of that, keep the grammar as
strict as possible.

Fix an unclosed string literal in a test.  This had been wrongly
accepted before by the grammar.
2021-02-07 20:40:05 +00:00
rillig
925203b1c3 tests/libcurses: do not allow control characters in paths 2021-02-07 20:32:25 +00:00
rillig
c2ad8acebe tests/libcurses: error out on trying to parse /dev/zero
Be strict when parsing the tests.  Any unknown character is an error.
This avoids an endless loop when running "./director /dev/zero".  There
is no point in silently ignoring other invalid characters as well, as
this would only leave potential test writers in an unclear state,
without any benefit.
2021-02-07 20:27:40 +00:00
rillig
b30645eb36 tests/libcurses: fix documentation of call[234]
The function getyx is not a function but a macro.  It does not return
int, but void.  Since these changes destroy the simplicity of the
example, combining a regular return value and pass-by-reference return
values, I rewrote the whole section and added more examples.
2021-02-07 20:20:06 +00:00
rillig
ccd1df52a9 tests/libcurses: require keywords to be lowercase, except for OK and ERR
There is no need to write the keywords in upper case or mixed case.  The
only case where a keyword did not have the canonical form yet was a
single lowercase 'ok' in the test case 'innstr'.
2021-02-07 19:49:32 +00:00
rillig
183d5aec4d tests/libcurses: add missing semicolon in grammar 2021-02-07 19:44:34 +00:00
rillig
6989eb7749 tests/libcurses: fix typo in comment 2021-02-07 19:28:07 +00:00
rillig
1134970fd4 tests/libcurses: fix expected test output
The test framework doesn't check the files strictly, it only checks
whether the expected output is a prefix of the actual output, or vice
versa.  This allows several deviations to pass unnoticed, which is
wrong.
2021-02-07 18:56:37 +00:00
rillig
cfcf82e703 tests/libcurses: add const to some function parameters 2021-02-07 18:32:20 +00:00
rillig
58e6134faa tests/libcurses: simplify code for writing to the .exp file
If a write(2) returns less than 1, it must be an error.
2021-02-07 18:14:43 +00:00
rillig
bdb9e6b7f3 tests/libcurses: actually compare the stream to an absolute path
Up to now, the test command "compare /dev/null" was a no-op since the
command was only parsed but not run at all.  Now run it.

This makes the test mvwin fail.  That test will have to be fixed.

Comparing to /dev/null is certainly possible and may make sense,
comparing to /dev/zero is nonsense since the actual stream can never be
endless.  Some tests do that nevertheless, for whatever reason.

In order to have the expected test output closer to the curses commands
that cause it, it may be a good idea to add another command
'compare_str' that would work independently of an external file and at
the same time allow the expected output to be commented and explained.
This is not possible right now since the .chk files are read exactly
as-is.
2021-02-07 17:50:16 +00:00
rillig
1398f05953 tests/libcurses: use more common abbreviations for tokens 2021-02-07 17:32:55 +00:00
rillig
d3b5ee28db tests/libcurses: use standard indentation for grammar rule 'arg' 2021-02-07 17:26:15 +00:00
rillig
126b3d158a tests/libcurses: extract grammar rule 'arg' 2021-02-07 17:23:29 +00:00
rillig
aaac17ccef tests/libcurses: error out if called with too many arguments
This helps against users who try to add more options after the first
non-option argument and wonder why these options are silently ignored.
2021-02-07 13:56:23 +00:00
rillig
c1b0da3370 tests/libcurses: document another bug in the test director 2021-02-07 13:44:22 +00:00
rillig
fb153a60d3 tests/libcurses: fix usage of director 2021-02-07 13:22:23 +00:00
rillig
2eb448fe3b tests/libcurses: demonstrate more bugs in addch 2021-02-07 13:06:02 +00:00
rillig
4e30fe2ad3 tests/libcurses: fail on syntax errors in test files
Previously, a syntax error in a test file made the test pass, which was
outright dangerous.
2021-02-07 12:56:53 +00:00
rillig
d51c9371c9 tests/libcurses: use a single indentation style in the test grammar
The grammar rule 'args' has been left as-is since it needs to be split
into 'args' and 'arg' first, to avoid the redundancy.

The braces in "if (create_check_file)" were misleading.  It's strange that
GCC didn't reject this.
2021-02-07 12:48:34 +00:00
rillig
8de39c39e7 tests/libcurses: clean up test case grammar for statements
Previously, each statement ended with 'eol'.  This was unnecessarily
verbose since the 'eol' is not really part of the statement, it's part
of a line.

No functional change.
2021-02-07 12:24:18 +00:00
rillig
df2132f7f3 tests/libcurses: fix name of grammar rule
A list of assignments is not a statement, it's several statements.

No functional change.
2021-02-07 12:16:26 +00:00
rillig
a13a3f7e27 tests/libcurses: unary minus doesn't make sense on bool expressions
No functional change since -1 is as non-zero as 1.
2021-02-07 12:08:42 +00:00
rillig
4cf90fec0d tests/libcurses: allow end-of-line comments in data lines as well
This makes it possible to write small remarks directly in the affected
line, which not only makes for a clean visual appearance but also shows
up prominently in "cvs annotate" or "git blame", showing when such a
remark has been modified.
2021-02-07 12:05:36 +00:00
rillig
77df4d33b5 tests/libcurses: indent lexer code consistently
Several of the braces were misaligned.  For the simple keywords, there
is no need to write these braces at all, they only made the code look
more complicated than it really is.

I stumbled upon this because syntax errors in the test cases currently
let the test case succeed instead of fail, which is another ingredient
for unreliable tests, besides the loose output matching.
2021-02-07 11:52:43 +00:00
rillig
25d40489d1 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.
2021-02-07 01:53:54 +00:00
rillig
74e4499250 libcurses: fix typos in introduction to the curses test framework 2021-02-06 20:09:43 +00:00
simonb
14893fad26 Use .set noreorder and use reg names.
atf- lib/libc/sys/t_mprotect mprotect_mremap_exec is a bit happier now.
2021-01-21 00:56:41 +00:00
simonb
b64a04d2b4 Check for MAP_FAILED instead of NULL when looking for an error from mmap(2). 2021-01-18 05:44:20 +00:00
skrll
95cbb4a14b skip sigbus_adraln on MIPS 2021-01-13 06:44:55 +00:00
christos
d25fab543f Only try to create up-to NAME_MAX filenames.
XXX: this should be moved to stdio/t_mktemp.c where the rest of the tests
are and the code lives.
2021-01-11 20:31:34 +00:00
skrll
6285957ff6 PR/55715: pmax testbed panics with "assertion "asid == curcpu()->ci_pmap_asid_cur" failed"
It's GXemul that has the bug! Unfortunately, there's no way (currently) to
detect if we're running under GXemul emulation, so disable for all mips
for now.  Hopefully, GXemul will get fixed soon.
2021-01-11 07:17:49 +00:00
skrll
8be367b3f6 PR/55715: pmax testbed panics with "assertion "asid == curcpu()->ci_pmap_asid_cur" failed"
disable the sigbus_adraln test on qemu for now
2021-01-10 20:46:14 +00:00
reinoud
e6b71c1487 Implement support for trapping REP CMPS instructions in NVMM.
Qemu would abort hard when NVMM would get a memory trap on the instruction
since it didn't know it.
2020-12-27 20:56:14 +00:00
gson
2e0ec785ec Disable the lib/libossaudio/t_ossaudio:oss_dsp_trigger_read test case
on sparc until PR port-sparc/55876 gets fixed.
2020-12-26 15:28:52 +00:00
nia
a26ac9a7a3 t_ossaudio: More descriptive failure cases 2020-12-14 10:58:08 +00:00
nia
d00c08ec75 add some basic tests for libossaudio
since there are already tests for audio this is focused on making
sure the ioctls translate properly and implement the necessary OSS
compat quirks.

right now this only covers the dsp ioctls, it should also cover the
mixer ioctls, although that's significantly harder.
2020-12-11 12:29:27 +00:00
christos
43d7e2f9be map enough space for both the page we write and the guard so that we make
sure we own the guard page before we set its protection to none. This fixes
random SEGVs where the page we set protection to none probably belonged to
the dynamic linker. Reported by gson@
2020-11-27 16:50:02 +00:00
gson
10c9b659e2 delete trailing whitespace 2020-11-27 15:37:06 +00:00
martin
3a37f06f8b PR 55338: re-enable threxec test for more test coverage. 2020-11-08 08:54:50 +00:00
gson
086d077df3 Make the mkstemps_basic and mkostemps_basic test cases not randomly
fail when the replacement string happens to contain the letter "y".
2020-11-01 18:19:54 +00:00
christos
ed75ee8266 PR/55663: Ruslan Nikolaev: Add support for EVFILT_USER in kqueue(2) 2020-10-31 01:08:31 +00:00
blymn
865079658a Disable the wgetch test as it appears to be missing at the moment. 2020-10-29 00:27:50 +00:00
martin
bc61105d29 Use the relative paths in the installed version, not the (different)
source pathes.
2020-10-27 11:01:22 +00:00
mgorny
fc2fc80ae1 Add tests for AVX-512 registers (zmm0..zmm31, k0..7)
Thanks to David Seifert <soap@gentoo.org> for providing a VM
on an AVX-512 capable hardware

Reviewed by kamil
2020-10-27 08:32:36 +00:00
roy
033e3d74df Remove extra parens 2020-10-24 14:45:06 +00:00
martin
675eb1fbbe Add the new tests + check files, sort. 2020-10-24 14:21:25 +00:00
mgorny
120793c21a Issue 64-bit versions of *XSAVE* for 64-bit amd64 programs
When calling FXSAVE, XSAVE, FXRSTOR, ... for 64-bit programs on amd64
use the 64-suffixed variant in order to include the complete FIP/FDP
registers in the x87 area.

The difference between the two variants is that the FXSAVE64 (new)
variant represents FIP/FDP as 64-bit fields (union fp_addr.fa_64),
while the legacy FXSAVE variant uses split fields: 32-bit offset,
16-bit segment and 16-bit reserved field (union fp_addr.fa_32).
The latter implies that the actual addresses are truncated to 32 bits
which is insufficient in modern programs.

The change is applied only to 64-bit programs on amd64.  Plain i386
and compat32 continue using plain FXSAVE.  Similarly, NVMM is not
changed as I am not familiar with that code.

This is a potentially breaking change.  However, I don't think it likely
to actually break anything because the data provided by the old variant
were not meaningful (because of the truncated pointer).
2020-10-24 07:14:29 +00:00
blymn
ce321bb046 Merge in code from Google Summer of Code project which dramatically
increases the number of tests performed.

Thanks to Naman Jain <jnaman806@gmail.com> for his excellent work on
this GSoC project.
2020-10-24 04:46:16 +00:00
kre
e12ce6c4ea Adapt for change to parsedate() which now follows POSIX and altered the
dividing line between 21st and 20th century conversions from 69/70 to
68/69.   Adapt the tests for this to conform.
2020-10-19 15:06:49 +00:00
mgorny
fb8e91f57b Remove leftover commented out #if 0 2020-10-16 08:51:12 +00:00
rin
9b836018df Apply fix in rev 1.2 for core_dump_procinfo to aarch64 and arm:
http://cvsweb.netbsd.org/bsdweb.cgi/src/tests/lib/libc/sys/t_ptrace_core_wait.h#rev1.2

> For powerpc, program counter is not automatically incremented by trap
> instruction. We cannot increment PC in the trap handler, which breaks
> applications depending on this behavior, e.g., GDB.

This statement is true for aarch64 and arm.

Also, use PTRACE_BREAKPOINT_SIZE instead of hard-coded 4 to address
instruction next to PC.

OK ryo
2020-10-15 22:59:50 +00:00
mgorny
e0a152e645 Fix s87_tw reconstruction to correctly indicate register states
Fix the code reconstructing s87_tw (full tag word) from fx_sw (abridged
tag word) to correctly represent all register states.  The previous code
only distinguished between empty/non-empty registers, and assigned
'regular value' to all non-empty registers.  The new code explicitly
distinguishes the two other tag word values: empty and special.
2020-10-15 17:43:08 +00:00
rin
d92bac2dfd Bump soft/hard limits for stack to 6MB for aarch64{,eb}, where old value
(~4MB) is too small to be accepted.
2020-10-13 06:58:57 +00:00
rin
dab17687cc For aarch64eb, no SIGBUS signal for unaligned accesses.
Convert to preprocessor directives.
2020-10-13 06:55:25 +00:00
mgorny
3a2c6ec6be Add tests for x87 FPU registers
Reviewed by kamil
2020-10-09 17:43:30 +00:00
mgorny
431834add9 Rename MM_REG macro to ST_MAN, and cover fpr/xstate with it
Rename the MM_REG macro to ST_MAN, to make it clearer that it gets
mantissa of ST registers which overlaps with MM registers but can be
also used to read ST registers (to be used in the next commit).  Extend
it to cover the difference between GETFPREGS and GETXSTATE,
and therefore avoid additional condition on i386.

Reviewed by kamil.
2020-10-09 17:43:07 +00:00
christos
c2bd2f1f7f PR/55648: Kyle Evans: Minor warnings in compilation of libexecinfo test2 2020-09-09 20:04:10 +00:00
mrg
8820a04cbb avoid new GCC 9 warnings. 2020-09-07 00:29:14 +00:00
mrg
45092b0582 don't pass NULL to printf(), but use "<memory>" to signify this
test is operating on an in-memory only database.
2020-09-07 00:28:44 +00:00
mrg
cb93b81028 add support for new GCC 9 warnings that may be too much to fix
right now.  new address-of-packed-member and format-overflow
warnings have new GCC_NO_ADDR_OF_PACKED_MEMBER amd
GCC_NO_FORMAT_OVERFLOW variables to remove these warnings.

apply to a bunch of the tree.  mostly, these are real bugs that
should be fixed, but in many cases, only by removing the 'packed'
attribute from some structure that doesn't really need it.  (i
looked at many different ones, and while perhaps 60-80% were
already properly aligned, it wasn't clear to me that the uses
were always coming from sane data vs network alignment, so it
doesn't seem safe to remove packed without careful research for
each affect struct.)  clang already warned (and was not erroring)
for many of these cases, but gcc picked up dozens more.
2020-09-06 07:20:26 +00:00
maxv
4a2e4dc388 nvmm: update copyright headers 2020-09-05 07:22:25 +00:00
martin
f834934d77 Skip threxec test pointing at PR 55338, this kills some test beds. 2020-08-29 05:46:34 +00:00
christos
7865465b60 PR/55612: Martin Husemann: libarchive tests pollute /tmp w/o cleanup
Set $TMPDIR to where we are.
2020-08-28 18:46:05 +00:00
gson
9d42296eb9 Only expect the fmod test case to fail when using qemu's TCG CPU emulation,
and not under hardware virtualization such as qemu -accel nvmm.
2020-08-25 13:39:16 +00:00
riastradh
c9aa4f445f Fix getrandom() tests.
Use sigaction() without SA_RESTART -- signal() implies SA_RESTART so
we never got the EINTR.

While here, reduce the timeout to something more reasonable so we
don't waste 20min of testbed time if anything goes wrong and the
one-second alarm doesn't fire.
2020-08-25 01:37:38 +00:00
gson
59b669221c Expect a failure to trap unaligned acesses only when running under
qemu's TCG CPU emulation, not when running under hardware virtualization
such as qemu -accel nvmm.
2020-08-24 06:55:16 +00:00
riastradh
bbfb23c92a Split getrandom tests into several cases to find out which ones hang. 2020-08-23 17:50:19 +00:00
gson
bd4d304f2b Expect failure only when running under qemu's TCG CPU emulation, not
when running under hardware virtualization such as qemu -accel nvmm.
2020-08-23 11:04:58 +00:00
gson
3b030f477c Provide separate functions to check for running under qemu in general
and for running under qemu's built-in TCG CPU emulation (as opposed to
hardware virtualization via NVMM or KVM).
2020-08-23 11:00:18 +00:00
riastradh
bdad8b2721 New system call getrandom() compatible with Linux and others.
Three ways to call:

getrandom(p, n, 0)              Blocks at boot until full entropy.
                                Returns up to n bytes at p; guarantees
                                up to 256 bytes even if interrupted
                                after blocking.  getrandom(0,0,0)
                                serves as an entropy barrier: return
                                only after system has full entropy.

getrandom(p, n, GRND_INSECURE)  Never blocks.  Guarantees up to 256
                                bytes even if interrupted.  Equivalent
                                to /dev/urandom.  Safe only after
                                successful getrandom(...,0),
                                getrandom(...,GRND_RANDOM), or read
                                from /dev/random.

getrandom(p, n, GRND_RANDOM)    May block at any time.  Returns up to n
                                bytes at p, but no guarantees about how
                                many -- may return as short as 1 byte.
                                Equivalent to /dev/random.  Legacy.
                                Provided only for source compatibility
                                with Linux.

Can also use flags|GRND_NONBLOCK to fail with EWOULDBLOCK/EAGAIN
without producing any output instead of blocking.

- The combination GRND_INSECURE|GRND_NONBLOCK is the same as
  GRND_INSECURE, since GRND_INSECURE never blocks anyway.

- The combinations GRND_INSECURE|GRND_RANDOM and
  GRND_INSECURE|GRND_RANDOM|GRND_NONBLOCK are nonsensical and fail
  with EINVAL.

As proposed on tech-userlevel, tech-crypto, tech-security, and
tech-kern, and subsequently adopted by core (minus the getentropy part
of the proposal, because other operating systems and participants in
the discussion couldn't come to an agreement about getentropy and
blocking semantics):

https://mail-index.netbsd.org/tech-userlevel/2020/05/02/msg012333.html
2020-08-14 00:53:15 +00:00
maxv
d3713544b3 Compile USER_LDT by default, but, put it behind a privileged sysctl that
defaults to disabled. To enable:

	# sysctl -w machdep.user_ldt=1
2020-07-19 14:31:31 +00:00
kamil
07e8492e26 Add ppoll() a compatibility wrapper around pollts(2)
Submitted by Apurva Nandan.
2020-07-17 15:34:16 +00:00
maxv
66af4cddad more 2020-07-03 16:07:52 +00:00
jruoho
04c087f823 Verify that PR lib/55041 is no longer an issue. 2020-07-03 03:13:10 +00:00
jruoho
55abcd082f Add basic checks for a64l(3), l64a(3), and l64a_r(3). 2020-07-01 07:16:37 +00:00
jruoho
7fed543511 Add basic tests for the rest of the mktemp(3) family of functions, including
a case for PR lib/55441.
2020-07-01 05:37:25 +00:00
jruoho
2ba250a115 After a comedy of errors, move t_mbtowc to its final resting place. 2020-06-30 16:09:40 +00:00
maya
f728d212f0 Avoid copyright issues and name the listed author as the copyright holder.
In a private email, Miloslav had agreed that if they had written the
test, then it can be licensed bsd-2-clause. I am going to assume this
is true as the file names Miloslav as the author.

This test was likely sent to tcsh (not netbsd) that had changed bug
report systems since.
2020-06-29 20:53:40 +00:00