Commit Graph

2828 Commits

Author SHA1 Message Date
ozaki-r 9ca7228bde Skip dumping if no bus is used 2016-11-26 03:20:42 +00:00
ozaki-r 6d9a9bf113 Add basic tests for vlan(4) 2016-11-26 03:19:48 +00:00
kamil 83cbb4a834 Print integers as hex with %#x rather than with plain %x
# if used with o, x or X specifiers the value is preceeded with 0, 0x or 0X
respectively for values different than zero.

Noted by <christos>

Sponsored by <The NetBSD Foundation>
2016-11-26 02:34:49 +00:00
kamil af6e917d6c Fix several printf(3)-like functions usage with printing integers
Integers as hex shall no be printed with PRIx8, but with plain "x".

Pointed by <christos>

Sponsored by <The NetBSD Foundation>
2016-11-25 20:01:05 +00:00
ozaki-r 5a83ceea44 Share rump_server start/stop and interface creation/destruction functions
The common functions store socks of rump_servers, interfaces of rump_servers
and buses that intefaces connect and allow to destroy them with common
functions without specifying which socks, interfaces and buses we should
destroy.

This change reduces lots of similar setup/cleanup codes.
2016-11-25 08:51:16 +00:00
ozaki-r 731c5c346e Add $DEBUG and remove a unused function 2016-11-25 08:10:50 +00:00
ozaki-r 732b7eb4c4 Add missing head functions 2016-11-25 08:10:12 +00:00
kamil fb0931daa7 Add fpregs[12] in t_ptrace_wait{,3,4,6,id,pid}
fpregs1:
    Verify plain PT_GETFPREGS call without further steps

fpregs2:
    Verify PT_GETFPREGS and PT_SETFPREGS calls without changing regs

Sponsored by <The NetBSD Foundation>
2016-11-24 22:52:03 +00:00
alnsn e771598c7d Switch to CHECK_LIBC for writing. 2016-11-24 22:42:16 +00:00
joerg 4269461d42 Fix format strings. 2016-11-24 19:26:32 +00:00
ozaki-r 713e0a32de Share httpd start/stop code 2016-11-24 11:54:57 +00:00
ozaki-r 58be5ec9a6 Add missing bus argument for extract_new_packets 2016-11-24 11:34:51 +00:00
ozaki-r 554c6ec338 Move get_macaddr to net_common.sh 2016-11-24 09:07:09 +00:00
ozaki-r a97a8a65f3 Move get_lladdr to net_common.sh 2016-11-24 09:06:09 +00:00
ozaki-r 927b18c962 Move route check functions to net_common.sh 2016-11-24 09:05:16 +00:00
ozaki-r 5a2201ed49 Move HIJACKING definition to net_common.sh 2016-11-24 09:03:53 +00:00
ozaki-r d64bc47ffa Reduce duplicate codes
Introduce net_common.sh that is to share common functions used in tests
for networking. This commit commonizes extract_new_packets. Other duplicate
codes will be moved to the file in further commits.
2016-11-24 08:52:19 +00:00
ozaki-r 17ee12d2df Make tests strict
Connected routes have 'C' flag.
2016-11-24 07:32:19 +00:00
ozaki-r 39b7e5ca2e Add missing $NetBSD$ tag 2016-11-24 07:31:14 +00:00
kamil 3bd0170534 Drop unwanted printf(3) call in regs5 in t_ptrace
This call is reserved for other test.

Sponsored by <The NetBSD Foundation>
2016-11-24 04:11:16 +00:00
kamil 07f3b8e854 Add regs[12345] in t_ptrace_wait{,3,4,6,id,pid}
Add new ATF tests for the general purpose register calls.

These tests require platforms to export all of the following macros:
 - PT_GETREGS
 - PT_SETREGS
 - PTRACE_REG_PC
 - PTRACE_REG_SET_PC
 - PTRACE_REG_SP
 - PTRACE_REG_INTRV

This has been done for the sake of C preprocessor magic simplicity.
There are ports without covering all of the above symbols -- skip them.

Added tests
===========

regs1:
    Verify plain PT_GETREGS call without further steps

regs2:
    Verify plain PT_GETREGS call and retrieve PC

regs3:
    Verify plain PT_GETREGS call and retrieve SP

regs4:
    Verify plain PT_GETREGS call and retrieve INTRV

regs5:
    Verify PT_GETREGS and PT_SETREGS calls without changing regs

Sponsored by <The NetBSD Foundation>
2016-11-24 04:08:37 +00:00
dholland c0590f9e77 Turn off the PR 49140 logging, because it itself makes the test fail.
As usual, ATF is actively interfering with test debugging. Almost all
runs in the past few days have failed this test with "stdout not
empty". In one run it timed out:
http://releng.netbsd.org/b5reports/i386/build/2016.11.22.06.51.14/test.html
but in this case ATF helpfully suppressed the log data.

Maybe if someone can figure out how to make the test hang reliably
then they can turn the logging on again and run it outside of ATF to
see what's happening.

In the meantime this problem is not likely to get fixed until we have
a less obstructive testing framework.
2016-11-24 00:37:29 +00:00
kamil 6f188f1097 Add {,io_}read_i[1234] in t_ptrace_wait{,3,4,6,id,pid}
New tests are direct counterparts to the existing ones {,io_}read_d[1234].

PT_READ_D and PIOD_READ_D (from PT_IO) are traditionally used to transfer
data segment. New tests make use of PT_READ_I and PIOD_READ_I (from PT_IO)
in order to copy text segment from traced process.

    Traditionally, ptrace() has
    allowed for machines with distinct address spaces for
    instruction and data, which is why there are two requests:
    conceptually, PT_READ_I reads from the instruction space
    and PT_READ_D reads from the data space.  In the current
    NetBSD implementation, these two requests are completely
    identical.

    --- ptrace(2)

New tests follow the traditional convention and copy only instructions from
dummy functions.

There are no new tests copying data to .text regions from the traced
process, as this is violating mprotect restrictions. This limitation may be
addressed in future, as there are dedicated sysctl(7) handlers for
debuggers (currently mainly gdb(1)).

Tests verifying identical behavior of PT_READ_I and PT_READ_D are not
planned.

Sponsored by <The NetBSD Foundation>
2016-11-23 23:30:50 +00:00
kamil d1ca0f5b0b Add new tests read_d_write_d_handshake[12] in t_ptrace_wait{,3,4,6,id,pid}
read_d_write_d_handshake1:
    Verify PT_READ_D with PT_WRITE_D handshake

read_d_write_d_handshake2:
    Verify PT_WRITE_D with PT_READ_D handshake

Sponsored by <The NetBSD Foundation>
2016-11-23 21:14:23 +00:00
kamil 81f61f06eb Rename read* and write* tests to read_d* and write_d*
The purpose of renaming is to make room for PT_READ_I and PT_WRITE_I type
ptrace(2) tests.

Sponsored by <The NetBSD Foundation>
2016-11-23 20:56:47 +00:00
kamil 9e97be1540 Add new test io_read_d_write_d_handshake2 in tests/kernel/t_ptrace_wait.c
Rename io_read_write_handshake to io_read_d_write_d_handshake1.

io_read_d_write_d_handshake2:
    Verify PT_IO with PIOD_WRITE_D and PIOD_READ_D handshake

This new test first writes and later reads data.
io_read_d_write_d_handshake1 first reads and later writes.

Sponsored by <The NetBSD Foundation>
2016-11-23 19:46:51 +00:00
kamil 618a4d33b4 Add io_read_write_handshake to t_ptrace_wait{,3,4,6,id,pid}
Verify PT_IO with PIOD_READ_D and PIOD_WRITE_D handshake

Sponsored by <The NetBSD Foundation>
2016-11-23 05:00:20 +00:00
kamil 36b77035bc Add new tests read[1234] in t_ptrace_wait{,3,4,6,id,pid}
read1:
    Verify PT_READ_D called once

read2:
    Verify PT_READ_D called twice

read3:
    Verify PT_READ_D called three times

read4:
    Verify PT_READ_D called four times

Sponsored by <The NetBSD Foundation>
2016-11-23 03:02:56 +00:00
kamil 79f7742f7e Add new tests io_write_d[1234] in t_ptrace_wait{,3,4,6,id,pid}
write1:
    Verify PT_WRITE_D called once

write2:
    Verify PT_WRITE_D called twice

write3:
    Verify PT_WRITE_D called three times

write4:
    Verify PT_WRITE_D called four times

Sponsored by <The NetBSD Foundation>
2016-11-23 01:49:05 +00:00
kamil c255d6a0af Add new tests io_write_d[1234] in t_ptrace_wait{,3,4,6,id,pid}
io_write_d1:
    Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint8_t)

io_write_d2:
    Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint16_t)

io_write_d3:
    Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint32_t)

io_write_d4:
    Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint64_t)

Sponsored by <The NetBSD Foundation>
2016-11-22 21:59:32 +00:00
kamil e6698e30f0 Add new tests io_read_d[1234] in t_ptrace_wait{,3,4,6,id,pid}
io_read_d1:
    Verify PT_IO with PIOD_READ_D and len = sizeof(uint8_t)

io_read_d2:
    Verify PT_IO with PIOD_READ_D and len = sizeof(uint16_t)

io_read_d3:
    Verify PT_IO with PIOD_READ_D and len = sizeof(uint32_t)

io_read_d4:
    Verify PT_IO with PIOD_READ_D and len = sizeof(uint64_t)

Sponsored by <The NetBSD Foundation>
2016-11-22 19:46:26 +00:00
kamil a5466eb716 Add new tests in lib/libpthread_dbg/t_threads: threads[6789]
These tests verifies the td_map_pth2thr().

It's rather difficult to test all aspects of pthreads_dbg(3) functions out of
context of a real application, this is the reason why these tests are
extensions of the previous ones and they test four (out of unlimited) valid
code-paths.

This function (the same as others in this class) is doing only single thing,
but its result depends on unlimited variations of the context.

The purpose of these checks is basic validation that the pthread_dbg(3) library
is still usable, but not that it's out of bugs.

threads6:
    Asserts that pthread_t can be translated with td_map_pth2thr()
    to td_thread_t -- and assert earlier that td_thr_iter() call is
    valid.

threads7:
    Asserts that pthread_t can be translated with td_map_pth2thr()
    to td_thread_t -- and assert later that td_thr_iter() call is
    valid.

threads8:
    Asserts that pthread_t can be translated with td_map_pth2thr()
    to td_thread_t -- compare thread's name of pthread_t and
    td_thread_t.

threads9:
    Asserts that pthread_t can be translated with td_map_pth2thr()
    to td_thread_t -- assert that thread is in the TD_STATE_RUNNING
    state.

All tests are passing.

Sponsored by <The NetBSD Foundation>
2016-11-22 03:21:46 +00:00
christos a0a2e8676d use <sys/types.h> 2016-11-21 16:26:16 +00:00
dholland 30d509368c As a debugging measure for PR 49141, log what this is doing as it runs
to stdout. Hopefully this will get reported when the test fails in the
testbed rather than just causing ATF to report that it printed
unexpected output.
2016-11-21 06:38:18 +00:00
dholland 44f5979097 More of previous. 2016-11-21 06:19:26 +00:00
dholland 5e5fae2d0d If pthread_create fails, report the error instead of discarding it. 2016-11-21 06:17:20 +00:00
kamil 0689e7f73f Add threads5 in tests/lib/libpthread_dbg/t_threads
Asserts that td_thr_getname() handles shorter buffer parameter and the
result is properly truncated.

Currently this test fails due to bug in pthread_dbg.

Sponsored by <The NetBSD Foundation>
2016-11-20 18:02:46 +00:00
kamil 34d01260b7 Add threads4 in tests/lib/libpthread_dbg/t_threads.c
This test asserts that for each td_thr_iter() call td_thr_getname() is
valid.

Sponsored by <The NetBSD Foundation>.
2016-11-20 17:42:56 +00:00
kamil c7b8b4ee8e Add threads2 and threads3 in tests/lib/libpthread_dbg/t_threads.c
threads2:
Asserts that td_thr_iter() call is executed for each thread once

threads3:
Asserts that for each td_thr_iter() call td_thr_info() is valid

These tests pass correctly.

Sponsored by <The NetBSD Foundation>
2016-11-20 16:13:03 +00:00
kamil e8b564dc88 Remove atf_tx_expect_fail from lib/libpthread_dbg/ tests
The following PR are now resolved and are reported to be properly fixed:
PR lib/51635 td_thr_iter in <pthread_dbg.h> seems broken
PR lib/51633 tests/lib/libpthread_dbg/t_dummy unreliable

Sponsored by <The NetBSD Foundation>
2016-11-19 15:13:46 +00:00
kamil 535c2378f3 Fix basic_proc_read in pthread_dbg functions
Source and destination were swapped. The source of this confusion was that
running these tests under gdb(1) will generate false positives as it will
initialize pthread__dbg to PID of the debugger. This means that it is
currently not possible to debug pthread_dbg code under a full-stack
debugger using NetBSD debugging library for threads.

This should address:
PR lib/51633 tests/lib/libpthread_dbg/t_dummy unreliable
PR lib/51635: td_thr_iter in <pthread_dbg.h> seems broken

After applying the fix I'm able to run all pthread_dbg tests without
indeterminism. The indeterminism was caused by overwritting source of data
with trash.

Sponsored by <The NetBSD Foundation>
2016-11-19 02:30:54 +00:00
kamil 0a225098cc Add new test file lib/libpthread_dbg/t_threads
This test contains threads1 test that:
    Asserts that td_thr_iter() call without extra logic works

This tests fails and is linked with gnats:
PR lib/51635: td_thr_iter in <pthread_dbg.h> seems broken

Sponsored by <The NetBSD Foundation>
2016-11-18 22:50:19 +00:00
kamil 452c3956fa Mark dummy2 and dummy3 in lib/libpthread_dbg/t_dummy with expected fail
The dummy2 test reports failures on i386 releng machines.

The same with dummy3, but it's also reproducible sometimes on my amd64
setup. It's not always broken, neither always functional - once a while it
reports failure. So far I have not reproduced failure in dummy2.

PR lib/51633 tests/lib/libpthread_dbg/t_dummy unreliable

Sponsored by <The NetBSD Foundation>
2016-11-17 17:30:22 +00:00
kamil a364537544 Add dummy3 in lib/libpthread_dbg/t_dummy
This test verifies that it's not possible to attach twice to the same
process with td_open() -- it asserts failure with status TD_ERR_INUSE.

This test does nothing besides initializing and deinitializing pthread_dbg
debugging instance.

Refactor code to be more reusable.

Set proper description of dummy2.

Sponsored by <The NetBSD Foundation>.
2016-11-17 04:13:52 +00:00
kamil f8d64fb128 Add new test dummy2 in lib/libpthread_dbg/t_dummy
This tests implements:
 - .proc_read with memcpy(3)
 - .proc_write with memcpy(3)
 - .proc_lookup with dlopen(3) and dlsym(3) combination

td_open() is verified to return with success (TD_ERR_OK), followed by a
call to td_close().

This test does nothing else than initializing and deinitializing td_proc_t
structure, with appropriately implemented functions.

Sponsored by <The NetBSD Foundation>
2016-11-17 03:37:23 +00:00
kamil 8fce8aab12 Add new test-suite t_dummy for libpthread_dbg
At the moment this test does nothing except reports failure from td_open()
for overloaded (implemented) dummy1_proc_lookup() (.proc_lookup from
td_proc_callbacks_t) of the following form:

static int
dummy1_proc_lookup(void *arg, const char *sym, caddr_t *addr)
{
        return TD_ERR_ERR;
}

This file and directory with tests is placeholder for new ones, without
further need to alter mtree and distribution sets.

The libpthread_dbg interface and library is used by gdb(1) to handle
threads in applications.

Sponsored by <The NetBSD Foundation>
2016-11-16 21:36:22 +00:00
pho fd86259521 Major rework of fuse_opt_parse(3) so that it supports all the functionality of the original function 2016-11-16 16:11:42 +00:00
kamil 7fa7b9b171 Add vfork1 test in t_ptrace_wait* and vfork2 in t_ptrace_wait{4,6,id,pid}
These tests are exact clones for fork1 and fork2, however testing vfork(2).

vfork1:
    Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK set to
    PTRACE_VFORK.

vfork2:
    Verify that vfork(2) is not intercepted by ptrace(2) with empty
    EVENT_MASK.

vfork1 is supposed to test currently unimplemented PTRACE_VFORK option in
EVENT_MASK, marked as failure and linked with PR kern/51630.

Sponsored by <The NetBSD Foundation>
2016-11-15 21:50:38 +00:00
kamil 4179cd8d9b Add new test fork2 in t_ptrace_wait*
Verify that fork(2) is not intercepted by ptrace(2) with empty EVENT_MASK.

This test works with all wait(2)-like functions.

Debugger receives only SIGCHLD from tracee, when its the child of tracee
exits. Tracer notes nothing about fork(2) events.

Sponsored by <The NetBSD Foundation>
2016-11-15 20:59:11 +00:00
kamil c7db20ac6f Add new test fork1 in t_ptrace_wait{4,6,id,pid}
Verify that fork(2) is intercepted by ptrace(2) with EVENT_MASK set to
PTRACE_FORK.

In this test tracee calls fork(2) and this event is noted by tracer, both
for forker and forkee with PT_GET_PROCESS_STATE reporting pe_report_event
equal to PTRACE_FORK and pe_other_pid as forkee for forker and forker for
forkee.

The fork(2) event in the current implementation stops forker and forkee
with the SIGTRAP signal.

Exited forkee stops forker with the SIGCHLD signal.

Sponsored by <The NetBSD Foundation>.
2016-11-15 19:30:28 +00:00