Commit Graph

3854 Commits

Author SHA1 Message Date
kamil 32c33d29c1 Merge siginfo6 into other PT_STEP tests in t_ptrace_wait* 2019-02-11 05:51:20 +00:00
kamil bfae04bf15 Drop siginfo5 from ATF tests in t_ptrace_wait*
siginfo5 duplicates older tests verifying PTRACE_FORK.
2019-02-11 04:20:06 +00:00
kamil bc00947fe2 Initial refactoring of siginfo* tests in t_ptrace_wait*
Drop test siginfo1 as duplicated with earlier tests.

Rework and rename siginfo2 and siginfo3 into a single test body.

New tests:
 - siginfo_set_unmodified (replaces siginfo2)
 - siginfo_set_faked (replaces siginfo3)

All new tests pass.
2019-02-11 04:13:28 +00:00
mlelstv 82fe3e95ba provide a test function, avoids crashing tests with SIGSEGV. 2019-02-10 09:54:39 +00:00
kamil 5a04cbf366 Link t_ptrace_wait* tests with -pthread
While there, bump (c) for ATF ptrace(2) tests.

Add __used in infinite_thread() for consistency with other functions in
the file.
2019-02-10 02:13:45 +00:00
kamil 8ac77c305d Add initial pthread(3) tests in ATF t_prace_wait* tests
There were tested few scenarios with native _lwp_create(2) functions, using
this interface is not needed and it's easier to manage tests with
high-level pthread(3) API.

Rewrite original lwpinfo1 and lwpinfo2 tests into 8 new tests:
 - traceme_lwpinfo0 (0 spawned additional threads)
 - traceme_lwpinfo1 (1 spawned additional thread)
 - traceme_lwpinfo2 (2 spawned additional threads)
 - traceme_lwpinfo3 (3 spawned additional threads)
 - attach_lwpinfo0 (0 spawned additional threads)
 - attach_lwpinfo1 (1 spawned additional thread)
 - attach_lwpinfo2 (2 spawned additional threads)
 - attach_lwpinfo3 (3 spawned additional threads)

These tests verify primarily the PT_LWPINFO interface.

Build the t_ptrace_wait* tests with -pthread.

All tests pass.
2019-02-10 02:04:06 +00:00
kamil fb7fe14f74 Add infinite_thread() for ptrace(2) ATF tests
infinite_thread() is designed to be spawned as a pthread(3) function.

It will be used soon in new tests.
2019-02-09 23:10:42 +00:00
scole a253ff12d9 use HAVE_FPREGS not HAVE_FPGPREGS and move some register_t inside proper #define. fixes ia64 build. ok <kamil> 2019-02-09 23:03:01 +00:00
mrg 01ef24fd3f fix hello_profile's hello_profile_head function name. 2019-02-09 02:36:28 +00:00
mrg f4fc04f995 add $NetBSD$ tags. 2019-02-09 00:13:19 +00:00
mrg 9ca42b4c5e add very simple test that you can link -fopenmp.
currently fails, but should work soon...
2019-02-09 00:12:14 +00:00
kamil 120dbb13e3 Refactor kill* test in t_ptrace_wait*
Drop original scenario of kill1 (PT_CONTINUE(SIGKILL)) as it duplicates
traceme_sendsignal_simple1.

New kill tests:
 - kill1: ptrace(PT_KILL) (previously kill2)
 - kill2: kill(SIGKILL)
 - kill3: killpg(SIGKILL)

All kill* tests share the same function body.

All tests pass.
2019-02-08 03:08:00 +00:00
kamil fe7f44d815 Correct a style in description of PT_STEP tests in t_ptrace_wait* 2019-02-08 00:31:46 +00:00
kamil 60980e6752 Refactor definition of PT_STEP tests into single macro
No functional change intended.
2019-02-08 00:29:41 +00:00
kamil c18cba814b Refactor GPR and FPR tests in t_ptrace_wait* tests
This change deduplicates the code and puts all the test into shared
function body.

No functional change except ranaming tests regs* to access_regs* and
fpregs* to access_fpregs*.
2019-02-07 23:03:33 +00:00
maxv 83ed0b5e52 Improvements:
- Emulate the instructions by executing them directly on the host CPU.
   This is easier and probably faster than doing it in software
   manually.

 - Decode SUB from Primary, CMP from Group1, TEST from Group3, and add
   associated tests.

 - Handle correctly the cases where an instruction that always implicitly
   reads the register operand is executed with the mem operand as source
   (eg: "orq (%rbx),%rax").

 - Fix the MMU handling of 32bit-PAE. Under PAE CR3 is not page-aligned,
   so there are extra bits that are valid.

With these changes in place I can boot Windows XP on Qemu+NVMM.
2019-02-07 10:58:45 +00:00
kamil f51f2525b1 Enable 3 new ptrace(2) tests for SIGILL
Add missing code for SIGILL verification and enable new SIGILL tests:
 - traceme_crash_ill
 - traceme_vfork_crash_ill
 - unrelated_tracer_sees_crash_ill

SIGILL is caused by a crash signal and needs special treatement that has
to be asserted to behave correctly.

In the unrelated_tracer_sees_crash* tests add additional check to catch
scenarios when a test dies due to abnormal condition and it's not caught
as the tracer is collected by initproc.

All tests pass on NetBSD/amd64, other ports have temporarily unimplemented
PTRACE_ILLEGAL_ASM.
2019-02-07 00:24:59 +00:00
joerg abf7fd5db8 movzx is not AT&T syntax, but some bastard version of Intel syntax.
Switch to the equivalent mnenomic.
2019-02-06 15:42:31 +00:00
mrg 7081cfef47 use strncpy() into a buffer that may not be nul terminated. 2019-02-06 09:16:49 +00:00
kamil fdaf7bbf8c Add 2 new tests in t_fopen
Added:
 - fopen_nullptr (without COMPAT_10)
 - fopen_nullptr_compat10 (with COMPAT_10)

PR kern/53948

Reviewed by <mgorny>
2019-02-05 17:30:19 +00:00
maxv 0cfadc3649 Ah, I had warnings disabled, fix the build. 2019-02-05 17:03:10 +00:00
maxv ed8fc6e9ad Add 12 tests for libnvmm's I/O Assist. 2019-02-05 13:00:03 +00:00
kamil 9e1a0a9819 Add missing break keywords in t_ptrace_wait* x86 tests
Add missing break in switch() cases in dbregs_trap_variable().

Reported by <mrg>
Detected by GCC 7
2019-02-05 02:57:10 +00:00
mrg 844d41bff8 - add __unreachable() after ATF_REQUIRE(pid > 0) where pid <= 0.
- rearrange one switch so that the -1/0/default cases are the
  same order in all instances.
2019-02-04 09:35:11 +00:00
mrg 5bb852d0c6 - tests explicitly check failure modes, ignore those warnings 2019-02-04 05:24:18 +00:00
mrg bd9cab8c09 - make ERRX() return a value since it doesn't actually exit in the !TEST case. 2019-02-04 04:20:13 +00:00
mrg 466118942b - revert previous to t_ubsan.c, it is desired behaviour. from kamil.
- use -Wno-int-in-bool-context instead
2019-02-04 03:10:33 +00:00
mrg 37649e4074 - enlarge buffer to avoid snprintf() truncation 2019-02-03 10:48:46 +00:00
mrg 770680b518 - avoid multipling a boolean value, use &&. 2019-02-03 10:45:58 +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
mrg fbffadb9f8 - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
  this case, and thus can't be marked __dead easily
2019-02-03 03:19:25 +00:00
mrg 8dec05958d don't check the return value of execvp() for failure to call err().
assume if it returns at all something has failed.
2019-02-01 09:06:07 +00:00
maxv 2089a3819a Fix two issues:
* Uh I put the wrong masks in some GPRs, fuck.

 * When the opsize of MOVZX is 4, we need to combine the zero-extend from
   the instruction with the natural zero-extend of long mode.

Add two associated tests.
2019-02-01 06:49:58 +00:00
maxv a8470e3880 Put correct values in the seg fields. AMD doesn't check for that, but Intel
does, so they need to be correct.
2019-02-01 05:32:08 +00:00
martin d648db56e0 Move from uname -m to uname -p when checking if this target does support
ifunc - someone with a powerpc machine please double check!
2019-01-30 12:42:53 +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
mgorny de2592f9f0 Move common UBSAN test case code into ubsan_common.subr
Reviewed by <kamil>
2019-01-29 20:07:03 +00:00
mgorny ff295ecc8d Move common ASAN test case code into asan_common.subr
Reviewed by <kamil>
2019-01-29 20:02:34 +00:00
mgorny b4870a4524 Move common UBSAN test case code into ubsan_common.subr
Reviewed by <kamil>
2019-01-29 19:59:10 +00:00
mgorny bf6dc715c6 Move common ASAN test case code into asan_common.subr
Reviewed by <kamil>
2019-01-29 19:56:37 +00:00
christos e9c3f5723c vaxinate against ieeefp.h 2019-01-27 16:29:56 +00:00
pgoyette d91f98a871 Merge the [pgoyette-compat] branch 2019-01-27 02:08:33 +00:00
martin 15fd2d17a6 Some arm CPUs do not implement traps on floating point exceptions. 2019-01-26 16:44:30 +00:00
martin 8f6988db21 aarch64 does not trap on unaligned acces 2019-01-26 15:46:27 +00:00
christos 76d3dd6b3e PR/53908: Alex Raschi: One more file needs to move. 2019-01-25 18:34:45 +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
martin 076f00a246 There are aarch64 Cortex cpus that do not trap on some floating point
exceptions - so apply the arm handling for aarch64 as well.
2019-01-23 17:36:01 +00:00
kre 8d9df45b43 Add sub tests to the quoting test case, to demonstrate a parsing
bug (and its fix (depending upon whether the test is run against
an unfixed, or fixed, shell).

An obvious indication of the failure is the following (one of the
new sub-tests)

p=A
cat <<EOF
${p+\%$p\%}
${p+%$p%}
EOF

which should output

\%A\%
%A%


as a here doc is treated as a double quoted string, except
that the " character is just a character.  In such a string,
the \ is only an escape character when the following character
is special, otherwise it represents a literal \ (which is the
case here).

An unfixed shell will omit the backslashes in the output.

It gets even more wrong if the % chars are replaced by "
(double quote) chars, which should make no difference, other
than the corresponding change, in the output.   But doesn't
(it doesn't even produce output broken in a similar way).

This one is a harder case to be specific about however,
as while the fixed (and expected in the test) output is what
is technically correct, only a few shells actually produce
it, most generate something different (but not all the same.)
2019-01-22 14:31:53 +00:00
kamil 82a5a0ea60 Mark traceme_vfork_crash_bus as no longer failing
Fixed in src/sys/kern/core_elf32.c r. 1.58

Closes PR lib/53343
2019-01-22 03:47:45 +00:00
blymn 3e0ce67bf9 Fix script to use getopts instead of a hand rolled argument parser,
add option to set curses debug output file and other general fixes.
Thanks to kre@netbsd.org for comments and help with this.
2019-01-21 21:21:13 +00:00
kre 15320a4ac2 Add subtests to verify that both "sleep 0.2" and "sleep 0,2" work
when the locale is ru_RU.UTF-8 (which has ',' as its decimal radix char).
Inspired by a problem with rc.subr experiened by ru_RU.UTF-8 reported on
netbsd-users.  These are in the "fraction" test case.

While here, add some more (sub-)tests of invalid input, to make sure they
fail (in the "nonnumeric" test case), and for fun, a couple of subtests
testing hex input fractional delays (in the "hex" test case).
2019-01-21 13:19:18 +00:00
gson 0bd23f10c8 Call rump_pub_lwproc_newlwp() in the lfs cleaner thread to make its
rump system calls all use the same lwp.  Hopefully this will fix
PR kern/53884.  Also call rump_pub_lwproc_releaselwp() at the end.
2019-01-20 14:50:58 +00:00
christos 3f3dbbcd73 add a range and a repeat regex test. 2019-01-19 01:02:12 +00:00
knakahara 6e581475e6 Add ATF for ipsecif(4) pfil. 2019-01-17 02:49:11 +00:00
fox 4bfe81d9d9 Fixed issues with uvm_page_physunload_delete_end test case.
1. "avail_start" and "start" were different, resulting in unreachable code in
uvm_page_physunload(), where the condition check "avail_start" < "end" fails.
The test has been fixed by setting "avail_start" and "start" to the same value.

2. If "start" is the address with end address being "start + 2", we can
unplug twice, the first paddr_t would be "start" and the second one would be
"start + 1". Modified the ATF_CHECK_EQ() to reflect these changes.

Reviewed by <cherry>
2019-01-16 13:54:17 +00:00
fox 66ea64ecd5 Fixed issues with uvm_physseg_atboot_free_leak test case.
"\n" in ATF discriptions make it behave in weird ways, like saying "this
test is bogus.", fixed the issue by removing the "\n".

Reviewed by <cherry>
2019-01-16 13:45:29 +00:00
fox ff43743a55 Fixed issues with uvm_physseg_plug test case.
There is a condition check which failed for VM_PHYSSEG_MAX == 2 (not for
1 or 3 and above), in case of 2, pgs == slab + npages1 + npages3, so we
need to change ">" check to ">=" check.

Reviewed by <cherry>
2019-01-16 13:35:51 +00:00
fox 497a8f2bfd Fixed the build failures caused by incompatible type comparisons when
VM_PHYSSEG is > 1.

Reviewed by <cherry>
2019-01-16 13:21:02 +00:00
knakahara 06a59f7e0a Fix PR kern/53848. Add missing "ifconfig -w". 2019-01-15 05:34:37 +00:00
knakahara 2127b06f61 revert t_ipsec.sh:r1.7 2019-01-15 05:33:42 +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
gson 5a561c0cd0 Mark the fs/vfs/t_renamerace:udf_renamerace_dirs test case as an
expected failure referencing PR kern/53865, and force failure to avoid
reports of unexpected success as it does not realiably fail under
qemu.  This makes the treatment of udf_renamerace_dirs the same as
that of udf_renamerace, only with a different PR.  Also, make
whitespace consistent between the two.
2019-01-13 14:35:00 +00:00
gson c807c19194 Don't mark the traceme_vfork_crash_bus test case as an expected failure
when it is executing as part of the lib/libc/sys/t_ptrace_waitid test,
because that particular combination is not failing, at least not on amd64.
It is failing as part of other tests, so PR lib/53343 still applies.
2019-01-13 11:03:20 +00:00
knakahara b6794f2f31 workaround for PR kern/53848 2019-01-11 08:05:52 +00:00
pgoyette 12ca9da8a1 Remove extraneous && from check_output()
With this extra && the test case exits abnormally when the actual and
expected outputs don't match.
2019-01-10 11:13:50 +00:00
knakahara 3a6c5e3f5d tests/net/if_ipsec/t_ipsec disable dad. This may fix PR kern/53848 2019-01-10 00:45:08 +00:00
kre aa6bc89002 Add several sub-tests to the test for the "eval" builtin,
including testing correct handling of error cases.
One of these new tests located a bug which will be fixed
within minutes of this commit ...

While doing this, move the test that was used only in the
echo builtin test case (testing if the NetBSD shell was being
tested) into a utility function, and also call it in the eval
test, so NetBSD specific behaviour of what is unspecified in
the standard can be checked to ensure it is not accidentally
altered.
2019-01-09 10:51:23 +00:00
christos f629fca860 This now works too. 2019-01-08 00:22:11 +00:00
christos 82a6fadf05 this now works... 2019-01-08 00:21:19 +00:00
thorpej 9e7dc06b6e Fix a silly bug the "cancel thrash" test: the exit condition for the
job was never set, and so if the job actually got started before the
cancellation request came in, it would never finish and the cancellation
request would just hang forever.

Should address a spurious automated test failure reported by kre@.
2019-01-04 05:35:24 +00:00
thorpej 032c1d01a1 Add a test case that exercises repeated sceduling and cancelling of a job,
with periodic dropping of the interlock.
2018-12-28 19:54:36 +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
christos 20ef3dc45b Add an initfini_array test that does not depend on the linker putting it
there automatically.
2018-12-27 19:33:52 +00:00
maxv 38b2a665bf Several improvements and fixes:
* Change the Assist API. Rather than passing callbacks in each call, the
   callbacks are now registered beforehand. Then change the I/O Assist to
   fetch MMIO data via the Mem callback. This allows a guest to perform an
   I/O string operation on a memory that is itself an MMIO.

 * Introduce two new functions internal to libnvmm, read_guest_memory and
   write_guest_memory. They can handle mapped memory, MMIO memory and
   cross-page transactions.

 * Allow nvmm_gva_to_gpa and nvmm_gpa_to_hva to take non-page-aligned
   addresses. This simplifies a lot of things.

 * Support the MOVS instruction, and add a test for it. This instruction
   is special, in that it takes two implicit memory operands. In
   particular, it means that the two buffers can both be in MMIO memory,
   and we handle this case.

 * Fix gross copy-pasto in nvmm_hva_unmap. Also fix a few things here and
   there.
2018-12-27 07:22:31 +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 87d5cea604 Add -lrump after -lkernspace, because kernspace.a references symbols
from librump and hooray for static linking semantics.

Fixes sun2 build issue reported by kre@.

(XXX WTF did this only start failing after the addition of t_threadpool?)
2018-12-26 14:27:23 +00:00
knakahara 5eb3109a16 Add ATF for ipsecif(4) which connect to two peers in the same NAPT. 2018-12-26 08:59:41 +00:00
thorpej 41d71c6b2c Include some non-critical-but-still-for-correctness lines of code
in the cancellation unit test.  (I could have sworn I actually typed
these lines, no really...)
2018-12-25 21:26:31 +00:00
knakahara 99baf67288 Add ATF for NAT-T enabled ipsecif(4). 2018-12-25 03:54:44 +00:00
knakahara c037dbb205 reduce debug messages when $DEBUG is not true. 2018-12-25 03:28:29 +00:00
thorpej 77118773d1 Add rump-based test cases for threadpool(9). 2018-12-24 21:42:05 +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
kre 3e31d0bb60 Keep infrastructure setup and only exclude test for non-amd64 case.
Should be final nail in coffin of non-amd64 build failures (ie: Atffile
should get installed where it belongs rather than the root dir).
2018-12-24 05:06:45 +00:00
jakllsch 84cd64698f further build fixes 2018-12-23 16:40:15 +00:00
martin 84df641459 Fix the build 2018-12-23 16:23:24 +00:00
maxv 9159f72fc2 Add initial tests for libnvmm's Mem Assist, with 8 test cases. 2018-12-23 13:35:02 +00:00
dholland 519883bde6 Update error string 2018-12-18 08:39:03 +00:00
fox a85205fc7c Fixed the build failures caused by incompatible type comparisons.
Reviewed by <cherry>
2018-12-18 07:11:35 +00:00
dholland 6d6b8495d8 Update error string 2018-12-16 17:08:19 +00:00
hannken 61e6e59852 Have to hijack sysctl() and modctl() for zfs commands.
Should fix PR kern/53422
2018-12-16 14:04:14 +00:00
sevan f4e8600edf port-macppc/46319 is marked as resolved now.
Test on 8.99.26 build of NetBSD/macppc
2018-12-16 02:18:01 +00:00
kre e1be630664 Add a new test case for NetBSD specific readonly tests.
Add more sub-tests to the export_nbsd test case.
In both cases the new -q and -p VAR options are tested.
2018-12-12 11:52:05 +00:00
kre 6f3da39516 Add more subtests to the export and readonly built-in commands test cases.
In particular, add a readonly test to detect the bug that was just fixed...
(but there is more than that one added here).

Also, allow zsh to run more of these tests than it did, what is a builtin
command most places (including in POSIX) can be a reserved word in zsh!
2018-12-12 08:10:39 +00:00
ozaki-r 24e4ff1961 tests: add missing $af 2018-12-11 03:47:51 +00:00
ozaki-r 60afc5cb5b tests: check error messages strictly 2018-12-07 09:29:01 +00:00
ozaki-r fba119d2aa tests: reduce repeated phrases... (NFC) 2018-12-07 09:28:31 +00:00
kre 4474c9f596 Oops, this is 2018, not 2017 ... cut&paste (affects just copyright notice) 2018-12-05 02:48:04 +00:00
kre d8b51c8ab7 Add a new test program to test the "intermediate" shell built in
utilities.  That is, not the low level ones that look like syntax,
but aren't: break/continue/return; not those which are really
just external programs that are built in for efficiency (printf,
test, and kill - though kill really needs to be built in) - those
should all have separate test programs (there is a test here for the
built-in echo, as that is an entirely different thing to /bin/echo);
and also not those for which there are other tests because of the
nature of the built-in (like exit, wait, shift, ...).   Lastly not
"times" either as that just seems to be too hard to test rationally.

There is a test (well, framework) for ulimit and there's also t_ulimit.sh
one of those should go, but I am not yet sure which is the best way
to reconcile things.

Note: many (in fact) most of the test cases added here are either
entirely empty (no tests at all, beyond testing that the built-in is
in fact a shell built-in) or only very rudimentary tests - assistance
in fleshing those out would be welcome (the boilerplate is all here,
all that is needed is some actual tests to run...)
2018-12-05 02:45:05 +00:00
kre 62d35c4e21 Supply a missing \ ... this missing has meant that these tests
have not been testing everything they should have been testing.
Never mind, they still all succeed.
2018-12-04 09:47:25 +00:00
blymn d10c3fbbc9 Fix failing background test check file. 2018-12-04 09:32:50 +00:00
hannken 1c0c955e08 Skip zfs, it does not GOP_ALLOC.
PR kern/47656 test zfs_fillfs.
2018-11-30 09:52:39 +00:00
blymn d70ea1b172 Add script for assisting with debugging curses tests. 2018-11-30 04:57:02 +00:00
christos 90de07325c Add base-256 test (Micha Gorny) 2018-11-30 00:53:41 +00:00
hannken 6ac427e315 Redo the access check for setting va_flags in zfs_netbsd_setattr().
Use user flag UF_NODUMP instead of UF_IMMUTABLE for the test as it
is the only user flag supported by all tested file systems.

PR kern/47656 test zfs_flags.
2018-11-28 10:01:28 +00:00
hannken e4ec60fc8e Add missing access check for REMOVE into zfs_netbsd_lookup().
PR kern/47656 test zfs_dirperms.
2018-11-28 09:58:58 +00:00
hannken 5cbc5ce853 Add missing access check for setting va_Xtime into zfs_netbsd_setattr().
PR kern/47656 test zfs_times.
2018-11-28 09:57:59 +00:00
kre 9addc4465a Add two new test cases to add more tests for $@ expansions
(and a few more subtests in an existing test case).

The two new test cases currently fail, because of issues with
expanding "${1+$@}" which will (hopefully) be fixed soon.
(This looks to have been broken sometime during 2013 ... then I
made it even worse with some of the parser changes a while ago,
though the end result is that it appears less broken than it
really is.)
2018-11-27 09:59:30 +00:00
kre 7751e46b63 Add a new test case to test <> (open for input & output),
includion a test to make sure that the file doesn't get truncated.

Add new subtests to the "incorrect redirections" test case, to
validate correct behaviour of the shell when redirections fail in
various scenarios, including when the redirect is the whole command.

More along these lines are really needed, but this is better than nothing.

All the added tests pass on the /bin/sh currently in netbsd HEAD.
2018-11-27 09:55:32 +00:00
knakahara d1268e2e86 Add ATF for IPv6 NAT-T.
We use IPv6 NAT-T to avoid IPsec slowing down caused by dropping ESP packets
by some Customer Premises Equipments (CPE). I implement ATF to test such
situation.

I think it can also work with nat66, but I have not tested to the fine details.
2018-11-22 04:51:41 +00:00
kre fa836fad8c It turns out there are more cases where escaping of meta-chars
was not being done properly (too many different code paths inside sh)
so add even more subtests to the case_matching test case to verify
that all (that I can think of for now anyway) get fixed when this
gets cleaned up.   The case_matching test case still fails, but now
6 of its subtests should fail (until sh is corrected ... soon).
2018-11-18 13:41:24 +00:00
kre 0ebdf0f8fc Add some tests to detect the presence of a bug in sh reported by
Martijn Dekker (private e-mail.)   Variable expansions that are
double quoted result in literal characters (nver pattern matching
meta chars.)  This includes '\' (that one was the bug.)
[On the other hand, a variable in a case pattern expansion that is
unquoted, produces a pattern, and in that the \ character can be
used to excape other pattern meta-chars (and itself.]

This addition will cause the case_matching test case to fail (two
of the newly added sub-tests fail) until fixes to /bin/sh are made.
(That is comiung soon, the code exists already.)
2018-11-18 01:24:44 +00:00
riastradh 191d101a58 cbrtl_powl is xfail only if long double has more bits than double. 2018-11-15 05:14:20 +00:00
knakahara 3d0c03bef5 let ATF detect a bug fixed by if_vla.c:r1.132. 2018-11-14 05:07:48 +00:00
kre 0b70db4e58 Add a test for the bug in PR bin/53712 ( " { } > out " core dump )
Tested with both fixed, and unfixed, versions of /bin/sh (and in
posix mode, where that is a syntax error).
2018-11-14 02:37:51 +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
riastradh 1ba9f2bf59 Print the input to cosf on failure too. 2018-11-10 23:04:16 +00:00
ozaki-r 82733c9693 Add a test to show a large number of MAC addresses cached in a bridge 2018-11-09 06:45:03 +00:00
riastradh 6059a086c9 Disable x87 implementations of sin, cos, tan.
The x87 hardware uses a bad approximation to pi for argument
reduction, and consequently yields bad answers for inputs near pi or
pi/2.

Tweak one tanf test whose doubly rounded output is a little too far
from the correct answer on the doubly rounded input.
2018-11-07 04:00:12 +00:00
riastradh a8a8e5f56a Fix up libm tests.
- Fix up last few digits of a lot of known-answer tests.

  Confirmed with GNU mpfr to 200 bits of precision and cross-checked
  with whatever libm Ubuntu ships with.

- Test relative error, not absolute error.

- Set bounds in terms of *_EPSILON, not magic numbers.

  *_EPSILON is twice the largest relative error of a correctly
  rounded operation, and equal to the largest relative error of an
  operation with up to 1ulp error.

  Most of the operations we're testing are not correctly rounded, but
  they ought to be no more than 1ulp away.  For the few cases where
  that's not a priori clear (like comparing cbrt and pow(x, 1/3)),
  use twice *_EPSILON to allow some leeway.

- Write the success condition positively as error <= eps.

  This comes out false if the result is a NaN, meaning failure.  In
  contrast, if we write error > eps for the _failure_ condition, then
  if the result is a NaN, it will also come out false, but meaning
  success, which is not what we want.

- Fix the trigonometric test cases near bad spots.

  sin(pi - d) for nonzero d is not zero; it is d + O(d^3).  pi is not
  a floating-point number, so these results should be approximately
  the nonzero error of our approximation to pi.  Likewise with
  cos(pi/2 - d) and tan(pi + d).

  (Yes, I know the sin _function_ is ill-conditioned near pi so you
  shouldn't pass approximate inputs near there, but that's separate
  from whether a sin _implementation_ gives an answer that is wrong
  by quintillions of ulps.)

  Since on x86 (i386 and amd64 alike) we currently use x87 hardware
  trigonometric instructions, which are bad, these are marked xfail
  on x86 for now until we switch to software implementations (coming
  soon to a repository near you).

- Use %.8g, %.17g, %.35g to print float, double, long double in failures.

  This should be enough to identify the problematic outputs and/or
  reproduce the computation, even if long double is binary128 with
  115 bits of precision.

If there are any new libm test failures after this, tell me what
architecture you're on and send me the atf output and I'll try to
figure it out.
2018-11-07 03:59:36 +00:00
riastradh b1abfc8877 Build libm tests with -fno-builtin.
This way they test libm, not whatever the compiler does.

We should _also_ have automatic integration tests for what the
compiler does, as a separate thing.
2018-11-07 03:56:18 +00:00
christos 574faccec0 Add a test to enable rerror handling. 2018-11-06 17:55:04 +00:00
blymn a6da383444 Correct background check file for fixed curses behaviour.
This fixes lib/53676.
2018-11-06 09:43:25 +00:00
roy 4c5df848e8 Handle ENOBUFS better and clean some whitespace. 2018-10-16 09:23:29 +00:00
christos 7e431be058 simple memmem test to show buffer overrun. 2018-10-15 17:55:28 +00:00
gson 61e97463c5 A timeout of 480 seconds is not enough for the t_pubkey:ec test case
on qemu/sparc.
2018-09-29 10:54:35 +00:00
gson 683f5e4226 The default timeout of 300 seconds is not enough for the t_ciphers:evp
test case on qemu/sparc since the import of openssl 1.1.0i on 2018-08-18.
2018-09-29 10:50:33 +00:00
christos e1e91be8a7 Force libcrypto to be loaded after libcryptotest for the benefit of sun2 2018-09-28 23:40:45 +00:00
christos b4a1544ad5 Remove tests that don't exist anymore in OpenSSL-1.1.1 (We should add the
one ones it adds though :-)
2018-09-24 16:25:24 +00:00
christos 54bebabb33 Merge openssl-1.1.1 2018-09-23 13:34:57 +00:00
kre 30a7129418 Move the tests of character value args to floating conversions
out of the %e test and into the NetBSD specific tests, while POSIX
once (apparently) required (or seemed to require) support for that,
it no longer does (and character value args to float conversions do
not make much sense - char valuse are always integers).

When char conversions are supported, test that \'  (or \" ) (that is,
no character following the quote) works as an arg (should result in zero,
as there's a \0 in the arg after the quote char).

Add some big/small number %g conversion tests.
2018-09-14 19:57:57 +00:00
kre fdc5bd383d When the shell being tested for builtin printf supports "type -t"
use it to test if printf is built in, it is must more reliable that
guessing at the output format and message of "type" (without -t).
2018-09-14 19:52:23 +00:00
kre 15c15cae0c Add a test where printf is run twice in the same shell, and the
first invocation uses \c in a %b arg - make sure that 2nd invocation
is not affected by that  (it was until recently, for a very long time).
2018-09-10 15:02:11 +00:00
kre ecfbb4457e Make sure we're in the standard locale when testing for printf
being built in to the shell, so we don't receive an unrecognisable
(to the script) message from the shell when we ask it.
2018-09-08 18:24:01 +00:00
kre d1e529d31c Add ATF tests for printf(1)
Two new test programs, one for the version of printf in /bin/sh
and one for the command /usr/bin/printf (t_builtin and t_command)

Each test program has 28 test cases (the same in each) of which
currently 27 pass, and 1 is skipped.

See the test scripts themselves for more information.
2018-09-05 21:05:40 +00:00
maya f4f9a0f4e4 amend test case to also check for -fprofile-generate
(clang also supports this flag)

PR toolchain/53567
2018-09-03 21:54:57 +00:00
christos d8fc255716 Den't set SA_RESTART in the signal handler allowing the process to get
interrupted durning recv and exit (pointed out by kre@)
2018-08-22 06:31:37 +00:00
christos 510866dcf6 mark failed 2018-08-21 11:04:49 +00:00
christos 1cd154f24d should terminate and does with ktrace, but it does not normally. 2018-08-21 11:03:27 +00:00
christos fd6a62a9fd Now add the file I really meant to add. 2018-08-21 10:41:00 +00:00
christos 1d33257c91 revert copyright change. 2018-08-21 10:39:21 +00:00
christos a80aa007a5 more tests 2018-08-21 10:38:09 +00:00
kamil ab9ba7502e Add a new ATF ptrace(2) test: tracer_attach_to_unrelated_stopped_process
Reuse the body of tracer_sees_terminaton_before_the_parent_raw for a test
attaching to an unrelated stopped process.

This test passes.
2018-08-13 22:59:52 +00:00
kamil e483a1e648 Add a new ATF test parent_attach_to_its_stopped_child
Reuse the body of parent_attach_to_its_child for a test attaching to a
stopped child.

This test passes.
2018-08-13 22:00:45 +00:00
kamil d4145d9af3 Add await_stopped() in t_ptrace_wait.h
This is used in tests where a process awaits for a stopped process.
2018-08-13 21:49:37 +00:00
kamil 4e0b50601b Add a new ATF ptrace(2) test: child_attach_to_its_stopped_parent
Reuse the body of child_attach_to_its_parent for a test attaching to a
stopped parent.

As a workaround to ATF framework (atf-run), run this test in a subprocess.
The raise(SIGSTOP) call breaks the pipe from atf-run, that is polling
whether a process is in order.
According to code inspection the poll(2) call in safe_poll() receives
EINTR and this tears down the test.

This test passes.
2018-08-13 21:36:55 +00:00
christos 6922e2ba63 Fix stack protector build. 2018-08-09 12:45:15 +00:00
msaitoh dcdcd796aa Add simple test case for if_nametoindex(3). 2018-08-06 04:50:11 +00:00
kamil 928317f5a5 Register micro-UBSan ATF tests in the distribution
Populate distrib files, mtree lists and add the entry in Makefile to
include the new code.
2018-08-03 04:24:41 +00:00
kamil 4b149a2e55 Import micro-UBSan ATF tests
These tests are used only when a distribution is built without MKSANITIZER
and without MKLIBCSANITIZER. They build the ubsan.c micro-implementation
in userland as a standalone library (a .c file linked into tests).

The code generation part emits symbols that are handled by uUBSan.

Tested with Clang amd64 + i386 and GCC amd64 + i386.

There are two sets of tests: C code generation and C++ code generation.

There are various little differences that are handled with proper ifdefs.

Clang 7svn has significantly more checks for Undefined Behavior than GCC
5.x. Some of the tests are or might be amd64 and/or i386 specific and are
marked with proper ifdefs and comments according to the compiler
documentation.
2018-08-03 04:18:40 +00:00
maya 5d240897e9 Don't require size to be a multiple of alignment. This is no longer a
requirement as of C18.
2018-07-29 01:45:25 +00:00
ryo 7f48821abb aarch64 support per page execute protection 2018-07-27 07:09:15 +00:00
kamil 95a05eda65 Avoid undefined behavior in an ATF test: t_bitops
Do not change the signedness bit with a left shift operation.
Switch to unsigned integer to prevent this.

t_bitops.c:189:9, left shift of 1 by 31 places cannot be represented in type 'int'

Detected with micro-UBSan in the user mode.
2018-07-25 22:00:32 +00:00
kamil d61d73f803 Avoid undefined behavior in an ATF test: t_types
Replace UB with implementation defined logic to check whether ssize_t can
wrap to a negative number.

t_types.c:63:7, signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long int'

Detected with micro-UBSan in the user mode.
2018-07-25 21:51:32 +00:00
kre fd9099727e Several improvements to this test...
In the filename expansion test, don't insist on testing cases
of [^a] anything not an a) (etc) - while almost all shells allow
^ there (as in regular expressions) this is not standard sh/glob syntax
(! is used for that, not ^).  Use of ^ as first char after '[' in a []
match has unspecified behaviour.   So, check if the shell being
tested supports ^ used this way before running the tests of ^ in [].
This makes no difference at all when testing the NetBSD sh which
does allow ^ for that use case.

Fix an obvious (in hindsight) stupidity in the case pattern tests
(a cut/paste/forget-to-fix type error).

Many cleanups, including some additional sub-tests, for the var
substring matching (just a couple of actual fixes to the tests).
(This was the last added, and least polished part - still is.)

This makes no difference to the filename expansion tests (11 of 167
still fail), the fix reduces the failing case match tests from
14 of 261 to 13 of 261.   For var substring tests, the failure
has changed from 6 of 87 to 8 of 99.   (Some) Fixes to sh will appear
soon.

For comparison, using this version of the test, dash passes all case
and var substring tests, and (aside from the [^...] tests which it
does not implement) fails 4 of the filename tests.   bash fails one
case test (a bash oddity in interpretation of the spec, which is unique
to bash amongst shells I have tested)  and one filename expansion (all
var substring tests pass).  Other shells are much worse (though the
freebsd shell results were coloured by the version of their shell I
tested still having the [[:xxx:]] always matches '[' bug, which is
fixed in later versions of their shell)
2018-07-20 18:25:56 +00:00
martin f04088b904 Comment out two tests that regularily hang on SMP machines (with unkillable
helper/child processes, so ATF timeout does not help).
Kamil knows about the SMP race in traced exit path and said he'll handle
it.
I would have skipped them on SMP machines only, but got lost in the
macro labyrinth - kamil, please feel free to improve ;-)
2018-07-17 06:13:08 +00:00
kamil b4d61ce68e Disable profile and compat 32-bit c++ sanitizer tests
These tests are known to be faulty. These fatures aren't ready.
They tend to break to unrelated changes to the codebase.

Base Clang and GCC are in general dated to use with sanitizers as these
features are being fixed on HEAD versions of both compilers (mostly Clang).
2018-07-16 07:27:26 +00:00
kamil e77b94561b Disable profile and compat 32-bit tests cc sanitizer tests
These tests are known to be faulty. These fatures aren't ready.
They tend to break to unrelated changes to the codebase and require.

Base Clang and GCC are in general dated to use with sanitizers as these
features are being fixed on HEAD versions of both compilers (mostly Clang).
2018-07-16 07:25:58 +00:00
kre bdc738b8a8 Add tests for pattern matching (filename expansion (glob), case statement
patterns, and variable expansion substring matching)

Currently (2018-07-10) all 3 sub-tests fail (sh bugs...)
Expect to see 14 (of 261) case matching sub-tests fail, 11 (of 167) filename
expansion (glob) sub-tests fail, and 6 (of 87) var substring sub-tests fail.

Also expect those numbers to reduce as sh bugs are fixed.
2018-07-10 06:49:29 +00:00
kamil b18b4f6eea Add 3 more expr(1) ATF tests detecting overflow
Verify 0 * INT.
2018-06-27 17:39:30 +00:00
kamil c97a37eb9c Add a couple of new ATF expr(1) tests
Some of the newly covered test-cases contained regressions.

All tests pass.
2018-06-27 17:14:47 +00:00
maya 216c3542f7 Add test case for PR lib/50646.
Make sure that cabsl (aka __c99_cabsl) is usable from C++.
2018-06-20 03:51:27 +00:00
gson 036399b6f4 No semicolon after macro do ... while (0) wrapper. 2018-06-19 09:20:46 +00:00
maya 40b0fdad11 for consistency, print the statement that is true in the error case.
also add missing closing paren
2018-06-14 21:57:25 +00:00
maya b4dd0f8b48 Test for FE_INVALID in a way that works for powerpc too.
powerpc seems to return FE_INVALID | FE_VXSOFT rather than just FE_INVALID.
XXX need extra careful reading of standards
2018-06-14 21:11:08 +00:00
yamaguchi c9cc6dd9e6 Update the error message in t_vlan (ENXIO => EINVAL)
ok ozaki-r@
2018-06-14 08:38:24 +00:00
yamaguchi 9de5f4c04e Add test cases for multicast address handling of vlan(4)
ok ozaki-r@
2018-06-14 08:22:52 +00:00
kamil 00a8c5e713 Add 2 new expr(1) ATF tests
Assert that -9223372036854775808 % -1 and -9223372036854775808 / -1 return
message about overflow / underflow detected.

These tests pass correctly.

Sponsored by <The NetBSD Foundation>
2018-06-12 18:54:39 +00:00
ozaki-r 9da465c4ef Add tests of vlan with bridge
The tests trigger a panic reported in PR kern/53357.
2018-06-12 04:21:22 +00:00
kamil 082a177931 Fix previous
The failing tests are for vfork(2), not fork(2).
2018-06-06 13:18:44 +00:00
kamil 396963258b Mark sigbus ATF tests in t_ptrace_wait as expected failure
They are breaking right now on all ports.

lib/53343
2018-06-06 13:16:32 +00:00
maya 3ca192b76c Blindly add __TEST_FENV in the hope of fixing the vax build.
(So we can include fenv.h, and then not use it - we ifdef vax out
for OS-portability reasons.)
2018-06-04 09:13:47 +00:00
maya 0161d86987 use ATF_CHECK instead of ATF_REQUIRE
(continue on failure, to see the rest of the failures)

From Ngie Cooper in PR bin/51834
2018-06-03 08:48:37 +00:00
maya 2b3568b36a Test and clear exception around scalbn calls.
Second part of PR bin/51834.

ifdef out vax to avoid netbsd-specific macros.
2018-06-03 08:39:00 +00:00
kre 8c02aa5477 80 column police. Some KNF and whitespace corrections (until I got bored...)
NFCI.
2018-06-01 05:48:29 +00:00
mrg 5d873ca56c make 'clean' and/or 'cleandir' actually clean all the things. 2018-05-31 09:08:25 +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
kre 64d884c8fc The bytes_transfer_piod_read_auxv test uses 4096 for the size param
to bytes_transfer() which asserted that the size is < the size of 512 AuxInfo
structs.   On a 32 bit system, an AuxInfo is 8 bytes, and 512 AuxInfo
structs is thus 4096 bytes, and 4096 is not < 4096, so the assertion
failed.   It would probably work as a <= assert, but I am not confident
enough with this test case to make that call, so instead increase the
array size to be 513 instead, 4096 is < 513*8 so happiness should return
and all should be right with the world.   At least for this one test.
(There was no problem on 64 bit systems as AuxInfo is bigger there.)
2018-05-30 05:09:11 +00:00
kamil fa04ee6693 Add new ATF ptrace(2) tests verifying crash signal handling
Add new tests:
 - traceme_crash_trap
 - traceme_crash_segv
 - traceme_crash_ill (temporarily disabled)
 - traceme_crash_fpe
 - traceme_crash_bus
 - unrelated_tracer_sees_crash_trap
 - unrelated_tracer_sees_crash_segv
 - unrelated_tracer_sees_crash_ill (temporarily disabled)
 - unrelated_tracer_sees_crash_fpe
 - unrelated_tracer_sees_crash_bus

These tests verify two subtle kernel paths that differ internally:
 - for a tracer that is a parent of a traced program (and not vforked)
   real parent == tracer
 - for a tracer that is an unrelated process of a traced program
   real parent != tracer

Regressions in the signal code can cause to break one of the scenarios, and
keep working the other one. It might be propagated to a scenario like:
 - attaching to a process with a debugger (over pid)
 - starting a process inside a debugger

We can assert on the ATF level that both will be functional.

While there, cover all the crash signals as testing is done practically
for free. While the Machine Independent signal routing code for crash
signals is mostly the same in the kernel, we can verify whether Machine
Dependent parts works as expected emitting the proper signal number and
signal code (si_code).

There have been already caught an unexpected behavior on Alpha, that
instead of SIGBUS we receive SIGSEGV.

Another benefit is that it's easier to catch races, as they pop up more
frequently. (This already helped to catch bugs more quickly)

These tests will help assert correctness of future kernel changes in the
signal routines.

All tests pass.

Sponsored by <The NetBSD Foundation>
2018-05-29 10:40:54 +00:00
kamil 52922ac661 Correct the t_ptrace_wait*:signal5 ATF test case
This functionality now works.
Correct the code path in this test.
Add additional sanity check with PT_GET_SIGINFO and validating si_code.

Sponsored by <The NetBSD Foundation>
2018-05-28 11:35:50 +00:00
kamil ccd167ce5f Drop trailing white space 2018-05-28 11:15:48 +00:00
martin 6ad8477b8b PR port-amd64/53316: two int don't make a long (when passed to
a C variadic function)
2018-05-28 07:55:56 +00:00
kamil d93c7a0a6b Try to fool $CC harder in ATF ptrace(2) tests in trigger_fpe()
A function that returns a value that is not used, can be optimized out by
a compiler. Try to fool the compiler with calling libc functions that shall
trigger a division by zero crash.

Sponsored by <The NetBSD Foundation>
2018-05-27 17:16:39 +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 223c019e6d Fix ATF ptrace(2) bytes_transfer_piod_read_auxv test
Make the initial buffer larger to stop triggering the runtime assert about
its size.

Its size is probably larger than all real use cases, but it's good enough
for the purpose of ATF tests and immune of potential AUXV size.

Sponsored by <The NetBSD Foundation>
2018-05-27 08:08:24 +00:00
christos d25ad815ca alloca, bad; stack protector, good. 2018-05-27 00:36:56 +00:00
kamil 4ee7ae6051 Port the CVE 2018-8897 mitigation to i386 ATF ptrace(2) tests
On i386 there is no need to switch execution mode.
Use 0x23 SS selector for i386, amd64 used 0x4f.

Based on pointers from <maxv>.

Sponsored by <The NetBSD Foundation>
2018-05-26 20:27:48 +00:00
kamil 1aca04ce92 Refactor the PT_WRITE*/PT_READ* and PIOD_* ATF ptrace(2) tests
Merge all the PT_WRITE*/PT_READ* and PIOD_* the test cases into the common
body.

Changes:
 - treat D and I variations exactly the same
 - stop testing 2-3-4 attempts to perform the same read/write operation
 - stop testing interlocked (handshake) read/write operations
 - rename the tests
 - test write to .text section (with D and I type of operations)

New tests:
 - bytes_transfer_piod_read_d_8
 - bytes_transfer_piod_read_d_16
 - bytes_transfer_piod_read_d_32
 - bytes_transfer_piod_read_d_64
 - bytes_transfer_piod_read_i_8
 - bytes_transfer_piod_read_i_16
 - bytes_transfer_piod_read_i_32
 - bytes_transfer_piod_read_i_64
 - bytes_transfer_piod_write_d_8
 - bytes_transfer_piod_write_d_16
 - bytes_transfer_piod_write_d_32
 - bytes_transfer_piod_write_d_64
 - bytes_transfer_piod_write_i_8
 - bytes_transfer_piod_write_i_16
 - bytes_transfer_piod_write_i_32
 - bytes_transfer_piod_write_i_64
 - bytes_transfer_read_d
 - bytes_transfer_read_i
 - bytes_transfer_write_d
 - bytes_transfer_write_i
 - bytes_transfer_piod_read_d_8_text
 - bytes_transfer_piod_read_d_16_text
 - bytes_transfer_piod_read_d_32_text
 - bytes_transfer_piod_read_d_64_text
 - bytes_transfer_piod_read_i_8_text
 - bytes_transfer_piod_read_i_16_text
 - bytes_transfer_piod_read_i_32_text
 - bytes_transfer_piod_read_i_64_text
 - bytes_transfer_piod_write_d_8_text
 - bytes_transfer_piod_write_d_16_text
 - bytes_transfer_piod_write_d_32_text
 - bytes_transfer_piod_write_d_64_text
 - bytes_transfer_piod_write_i_8_text
 - bytes_transfer_piod_write_i_16_text
 - bytes_transfer_piod_write_i_32_text
 - bytes_transfer_piod_write_i_64_text
 - bytes_transfer_read_d_text
 - bytes_transfer_read_i_text
 - bytes_transfer_write_d_text
 - bytes_transfer_write_i_text
 - bytes_transfer_piod_read_auxv

These tests are now covering all usual code paths.

All tests pass.
The PaX MPROTECT violating ones automatically detect whether to be skipped.

Eliminated 4x more code than removed.

Sponsored by <The NetBSD Foundation>
2018-05-26 15:32:31 +00:00
kamil 49ea5747bf Introduce can_we_write_to_text() to ATF ptrace(2) tests
The purpose of this function is to detect whether a tracer can write to the
.text section of its tracee.

Sponsored by <The NetBSD Foundation>
2018-05-26 15:15:17 +00:00
martin 14167a96a3 Fix typo in local macro name, pointed out by uwe 2018-05-25 16:30:03 +00:00
martin b11873986d Add a test to verify syscall() and/or __syscall() are working.
This used to trigger a panic (see PR kern/53261) on arm.
2018-05-25 15:42:30 +00:00
kamil 5b4f05b5be Try to fix 32-bit build
Cast pointer to uintptr_t rather than uintmax_t.
2018-05-24 08:28:40 +00:00
kamil e73d44d16d Merge the eventmask[1-6] ATF ptrace(2) tests into a shared function body
While there, rename the tests to:
 - eventmask_preserved_empty
 - eventmask_preserved_fork
 - eventmask_preserved_lwp_create
 - eventmask_preserved_lwp_exit
 - eventmask_preserved_vfork
 - eventmask_preserved_vfork_done

Sponsored by <The NetBSD Foundation>
2018-05-23 23:56:07 +00:00
kamil 7060760a3a Extend traceme_vfork_breakpoint in ATF ptrace(2) tests for more scenarios
traceme_vfork_breakpoint used to test SIGTRAP event. Reuse its code for:
SIGSEGV, SIGILL, SIGFPE and SIGBUS.

The SIGILL case is disabled as of now as it required addition of
PTRACE_ILLEGAL_ASM in MD ptrace(2) headers.

Added tests:
 - traceme_vfork_crash_trap
 - traceme_vfork_crash_segv (renamed from traceme_vfork_breakpoint)
 - traceme_vfork_crash_ill (disabled)
 - traceme_vfork_crash_fpe
 - traceme_vfork_crash_bus

All enabled tests pass.

Sponsored by <The NetBSD Foundation>
2018-05-23 13:51:27 +00:00
kamil 20c82f105a Add new auxiliary functions in ATF ptrace(2) tests
Introduce:
 - trigger_trap()
 - trigger_segv()
 - trigger_ill()
 - trigger_fpe()
 - trigger_bus()

These functions generate appropriate signals caused by crashes.

A debugger is required to collect the crashes regardless of signal masking,
catching or ignoring rules.

While there, append __used argument to can_we_set_dbregs().

Sponsored by <The NetBSD Foundation>
2018-05-23 13:18:09 +00:00
kamil 9b1435470a Refactor the attach[1-8] and race1 ATF t_ptrace_wait* tests
Share code in: attach1, attach2 and race1 in the same function body.
Rename thsee tests to more verbose names:
 - tracer_sees_terminaton_before_the_parent
 - tracer_sysctl_lookup_without_duplicates
 - unrelated_tracer_sees_terminaton_before_the_parent

Rename attach3 to parent_attach_to_its_child.

Rename attach4 to child_attach_to_its_parent.

Share code in attach5, attach6 and attach7 in the same function body and
reanem the tests to:
 - tracee_sees_its_original_parent_getppid
 - tracee_sees_its_original_parent_sysctl_kinfo_proc2
 - tracee_sees_its_original_parent_procfs_status

Reduce the code by around 50%.

No functional change intended. All tests pass.

Sponsored by <The NetBSD Foundation>
2018-05-23 01:29:43 +00:00