Commit Graph

286 Commits

Author SHA1 Message Date
christos da8b7648ed Add a $ORIGIN test 2019-06-07 21:18:16 +00:00
kamil 173c420d5d Fix a mistake in a test for KERN_PROC_CWD
Emit properly ENOENT scenario in chroot. For some reason the final patch
did not hit the tree.
2019-06-01 22:18:23 +00:00
kamil 707a3080aa Add ATF KERN_PROC_CWD tests 2019-06-01 19:49:02 +00:00
christos 64bf11ba3e unexpand 2019-05-21 04:10:20 +00:00
christos 38217df340 add printf attribute 2019-05-21 04:09:46 +00:00
kre 8b2a560acf Make the t_subr_prf test build after changes to sys/kern/subr_prf.c
and while here add a simple test for the new kernel vasprintf().
2019-05-21 03:46:45 +00:00
kamil 14fc6dc308 Fix typo 2019-04-25 19:37:09 +00:00
mgorny f5c01693d5 Fix reporting EOF via kevent and add a test case
Fix the kernel pty driver to report closed slave via master's kevent
EVFILT_READ.  This behavior matches the behavior for pipes, is
consistent with how FreeBSD implements it and is relied upon by LLDB's
main loop implementation.

Includes feedback by kre and kamil (from tech-kern), commit approved
by kamil.
2019-02-15 18:57:15 +00:00
mrg 5bb852d0c6 - tests explicitly check failure modes, ignore those warnings 2019-02-04 05:24:18 +00:00
mrg 37649e4074 - enlarge buffer to avoid snprintf() truncation 2019-02-03 10:48:46 +00:00
thorpej 68e270a267 Implement support for "pshared" POSIX semaphores.
Fixes lib/53273 (and Firefox's multi-process tab feature).
2019-02-03 03:20:23 +00:00
martin b39c506b5a Clean up terminology: modern arm CPUs do properly implement IEEE 754
floating point exceptions - but some (actually all currently know ones)
do not implement sending traps when these exceptions are raised.

Pointed out by Peter Maydell.
2019-01-30 12:16:28 +00:00
christos e9c3f5723c vaxinate against ieeefp.h 2019-01-27 16:29:56 +00:00
martin 15fd2d17a6 Some arm CPUs do not implement traps on floating point exceptions. 2019-01-26 16:44:30 +00:00
christos 78928445f5 PR/53908: Alex Raschi: Test that require modules belong in modules; move the
threadpool test from kernel to modules.
2019-01-25 18:33:58 +00:00
christos 323118b11c add call error checks, requested by mrg@ 2019-01-14 00:23:43 +00:00
christos 42bad95822 Increase the timeout a bit, and make sure we join so that there is no
race.
2019-01-13 15:36:57 +00:00
thorpej 3cc63623bb kre@ notified me that the kernel/t_threadpool "rapid" test was occasionally
tripping a KASSERT() failure in the i386-qemu test rig.  It turns out this
is due to "rapid" simply being a buggy test that makes assumptions that
aren't always true, especially on slower / uniprocesor hardware.  So, the
right thing to do is just remove the test.
2018-12-28 16:01:53 +00:00
thorpej ad5e13cec6 Fix spurios whitespace (thank you substandard vi clones). 2018-12-26 22:21:10 +00:00
thorpej fd47102229 - De-opaque'ify struct threadpool_job.
- De-_t'ify all of the structure types.

No functional chage, no ABI change (verified with old rump unit test
before and after new librump.so).

Per Taylor's request.
2018-12-26 18:54:19 +00:00
thorpej 2834fa0ab4 Add threadpool(9), an abstraction that provides shared pools of kernel
threads running at specific priorities, with support for unbound pools
and per-cpu pools.

Written by riastradh@, and based on the May 2014 draft, with a few changes
by me:
- Working on the assumption that a relative few priorities will actually
  be used, reduce the memory footprint by using linked lists, rather than
  2 large (and mostly empty) tables.  The performance impact is essentially
  nil, since these lists are consulted only when pools are created (and
  destroyed, for DIAGNOSTIC checks), and the lists will have at most 225
  entries.
- Make threadpool job object, which the caller must allocate storage for,
  really opaque.
- Use typedefs for the threadpool types, to reduce the verbosity of the
  API somewhat.
- Fix a bunch of pool / worker thread / job object lifecycle bugs.

Also include an ATF unit test, written by me, that exercises the basics
of the API by loading a kernel module that exposes several sysctls that
allow the ATF test script to create and destroy threadpools, schedule a
basic job, and verify that it ran.

And thus NetBSD 8.99.29 has arrived.
2018-12-24 16:58:53 +00:00
riastradh ae35b062b5 Make fenv.h optional for this test to unbreak the vax build. 2018-11-12 05:02:00 +00:00
riastradh a31ad98a39 Use feenableexcept to trap fp exceptions, and trigger one, for SIGFPE.
Not every CPU traps integer division by zero -- aarch64, powerpc,
&c., just return zero.
2018-11-11 01:26:08 +00:00
riastradh bb7a1ff9e2 Sort #includes. 2018-11-11 01:26:00 +00:00
kamil 6abbe0506f Add a comment for the workaround in trigger_bus()
Explain PROT_READ|PROT_WRITE.
2018-05-30 17:48:13 +00:00
kamil 398835f368 Make the trigger_bus() test compatible with more CPUs (at least ALPHA)
If we write a byte character into a pointer, a compiler can emit a
read-modify-write operation, especially when a CPU cannot access directly
a character wide address.

In this scenario calling mmap(2) with PROT_WRITE, without PROT_READ will
emit unexpected trap.

There are two possible workarounds for this issue:
 - write register wide memory without rmw sequence,
 - mark the region with additional protection PROT_READ

Both work for NetBSD/alpha.

Go for the latter as perhaps more safe for dump compilers emitting rmw
sequences.

Investigated by <martin>
2018-05-30 17:31:34 +00:00
kamil 49994bfcd7 Handle FPE and BUS scenarios in the ATF t_trapsignal tests
These crash signals are crucial for proper handling of abnormal conditions
in a program. The additional purpose of these tests it to assure the proper
handling of these signals for the coming ptrace(2)-related changes in the
signal routing code.

Add a stub for ILL scenarios.

All tests pass (on amd64).

The shell ATF script contains duplicated code. There should be a way to
deduplicate it, without rewrite to C.

Sponsored by <The NetBSD Foundation>
2018-05-27 17:04:45 +00:00
kamil aaef92583a Extend ATF tests in t_trapsignal.sh to verify software breakpoint traps
There are at least four types of SIGTRAP events:
 - software/hardware single step (trace trap)
 - software breakpoint
 - hardware breakpoint/watchpoint
 - kernel event (exec, fork, vfork, vfork-done, lwp-create, lwp-exit)

A program can execute software breakpoint without the context of being
traced and this is a regular crash signal emitting SIGTRAP (TRAP_BRKPT).

Rename original trap_* tests (trap_simple, trap_handle, trap_mask,
trap_handle_recurse and trap_ignore) to segv_* tests and restrict them for
SIGSEGV.

Add new tests: trap_* testing the same scenarios as segv_ ones, however
verifying the software breakpoint trap (SIGTRAP).

Keep the original name of h_segv.c, and extend it for software breakpoint
events.

The purpose of these tests is to verify SIGTRAP kernel paths without the
ptrace(2) context.

All tests pass.

Sponsored by <The NetBSD Foundation>
2018-05-22 04:32:56 +00:00
kamil 5607b39231 Add new ATF test: t_trapsignal:trap_ignore
Test ignored trap with right exit code.

This test passes.

Sponsored by <The NetBSD Foundation>
2018-05-21 08:49:03 +00:00
kamil ed68aafd9d Correct assert in ATF t_zombie test
A failure is reported with -1, not 1.

Sponsored by <The NetBSD Foundation>
2018-05-18 00:25:30 +00:00
kamil ce34db38fd Add new ATF tests: kernel/t_zombie
New tests attempting to kill, stop, drop or revive a zombie:
 - signal1 (SIGKILL)
 - signal2 (SIGSTOP)
 - signal3 (SIGABRT)
 - signal4 (SIGHUP)
 - signal5 (SIGCONT)

New test race1 verifying whether there are any kernel races when processing
signals to zombies, executing in a loop for 5 seconds.

These tests were inspired by a kernel unexpected behavior when a lookup
of a dying process could result in two detected entities once as an alive
process and once as a zombie.

race1 is similar to t_ptrace_wait* race1, however without ptrace(2) involved.

Sponsored by <The NetBSD Foundation>
2018-03-14 02:13:47 +00:00
pgoyette 96bdb2f1f0 * Use 'struct testmsg' rather than 'struct mymsg' (avoids a conflict
with FreeBSD)
* Fix a broken call to open(2) with O_CREAT and no permission argument.
* ANSIfy function definitions.
* Improve failure messages.

From freebsd.org via Brooks Davis - Thanks!
2018-02-03 02:57:15 +00:00
martin cea0645f8c Add EVFILT_FS 2018-01-09 17:35:29 +00:00
martin 35cce3cf1f Double the nanosleep() time to make the test work more reliably on my
dual CPU alpha (where previously we sometimes ended up with no delay
at all).
2017-12-30 17:06:27 +00:00
nakayama 036e3ece76 Use SCRIPTS instead of PROGS to avoid strip(1) if STRIPFLAG=-s. 2017-12-14 14:38:17 +00:00
christos 3fd3ffc3a1 PR/52812: scole_mail: src/tests/kernel/t_timeleft.c doesn't compile with MKRUMP=no
It needs libpthread regardless MKRUMP..
2017-12-12 18:19:45 +00:00
christos f765c47147 Add tests to make sure that the program name is what it is supposed to be. 2017-12-10 15:37:54 +00:00
christos 0b33a75d8f fix usage. 2017-12-08 14:40:45 +00:00
christos 85bf85b701 make _lwp_park return the remaining time to sleep in the "ts" argument
if it is a relative timestamp, as discussed in tech-kern.
XXX: pullup-8
2017-12-08 01:19:29 +00:00
christos 962d0d23f1 Add trapsignal tests that make sure that traps don't end up spinning
indefinitely, discussed in tech-kern.
2017-12-07 19:46:40 +00:00
christos f2c3026d0a add a test to check that the interpreter is preserved when executing scripts. 2017-12-06 13:54:26 +00:00
riastradh 894367af71 Stress rump hyperentropy a little harder. 2017-04-16 18:24:23 +00:00
kamil 97a670fdb7 Remove tests/kernel/t_ptrace* from the tree
ptrace(2) tests have been moved to tests/lib/libc/sys

Sponsored by <The NetBSD Foundation>
2017-04-03 05:06:28 +00:00
kamil cc4260326d Remove kernel/arch/{amd64,i386,x86} tests
These files were merged with kernel/t_ptrace_wait*

This removes MD test files.

Sponsored by <The NetBSD Foundation>
2017-04-02 01:49:51 +00:00
kamil 8021fa5d7a Merge kernel/t_ptrace_wait with kernel/arch/amd64/t_ptrace_wait
This aims to remove MD-specific tests files for ptrace(2).

Prefix i386 and amd64 tests with unique strings "i386_" and "x86_64_".
This removes conflicts with generic tests.

Sponsored by <The NetBSD Foundation>
2017-04-02 01:14:35 +00:00
kamil 558f1d1e36 Merge kernel/t_ptrace_wait with kernel/arch/i386/t_ptrace_wait
This aims to remove MD-specific tests files for ptrace(2).

Sponsored by <The NetBSD Foundation>
2017-04-02 00:40:12 +00:00
kamil c2be869a55 Merge kernel/t_ptrace_wait with kernel/arch/x86/t_ptrace_wait
This aims to remove MD-specific tests files for ptrace(2).

Sponsored by <The NetBSD Foundation>
2017-04-02 00:29:07 +00:00
kamil e884bc2dfc Correct another string about securelevel in t_ptrace
Change:
    Test must be run with securelevel >= 1

To:
    Test must be run with securelevel >= 0

In attach_pid1_securelevel.

Sponsored by <The NetBSD Foundation>
2017-04-02 00:06:09 +00:00
kamil bce52e0028 Deduplicate code in step* tests in t_ptrace_wait*
No functional change.

Sponsored by <The NetBSD Foundation>
2017-04-02 00:03:40 +00:00
kamil 5ab466b502 Correct securelevel in attach_pid1_securelevel
Assert that a debugger cannot attach to PID 1 with securelevel >= 0
(as root) instead of >= 1.

Sponsored by <The NetBSD Foundation>
2017-04-01 23:51:27 +00:00