Commit Graph

3565 Commits

Author SHA1 Message Date
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