Add new tests:
- waitpid_options
- waitid_options
- wait3_options
- wait4_options
- wait6_options
These tests are included in t_wait_noproc and t_wait_noproc_wnohang.
waitpid_options, wait3_options, wait4_options test combinations of options
of: bit for WALLSIG, WALTSIG, __WALL, __WCLONE and later a full combination
mask of WNOWAIT, WEXITED, WUNTRACED, WSTOPPED, WTRAPPED and WCONTINUED.
waitid and wait6 test full combination mask of WNOWAIT, WEXITED, WUNTRACED,
WSTOPPED, WTRAPPED and WCONTINUED -- excluded empty value and singular
WNOWAIT.
For compatibility reasons alter waitid and wait6 to test against options
WEXITED | WTRAPPED, as it's equivalent to waitpid, wait3, wait4.
The intention for these tests it to catch any possible issues with slighty
changed behavior of wait(2)-like functions in terms of valid options
values.
All tests pass successfully.
Sponsored by <The NetBSD Foundation>
Assert that a debugger cannot trace another process unless the process's
root directory is at or below the tracing process's root.
Sponsored by <The NetBSD Foundation>.
Assert that a debugger cannot attach to self (as it's nonsense).
NetBSD returs here EINVAL.
Clean up unused header includes.
Sponsored by <The NetBSD Foundation>.
Move out wait(2) specific tests from t_ptrace and put them to t_ptrace_wait
Add generic code fragments to reuse the same source-code for every member
of the wait(2) family, namely:
- wait(2)
- waitpid(2)
- waitid(2)
- wait3(2)
- wait4(2)
- wait6(2)
Currently in the new test-suite there are the following tests:
- traceme1
- traceme2
- traceme3
- traceme4
- attach1
Not all tests are possible to be executed against every wait(2)-like
interface, therefore they will be disabled in such case. Currently this
limits attach1 to waitpid(2), waitid(2), wait4(2), wait6(2), while the
other tests (traceme 1-4) run with all of the interfaces.
The construct of this file is dedicated for addition of new tests in the
close future.
As of now all of the tests pass correctly.
Thanks for Robert Elz for suggestions on improving the code (earlier draft
of this new form).
Sponsored by <The NetBSD Foundation>.
Note that ping6 with the argument can send packets with routing headers
but the kernel doesn't support receiving the packets so that ping6 fails.
Nevertheless, we can test whether sent packets are correct or not.
This test has set expected failure like other functions in the wait(2)
family and is linked with PR standards/51606.
The PR is labeled as:
wait4() (and friends) with WNOHANG and no children does not error
Originally, this test was accidently disabled in the WNOHANG checks. This
was noted by Robert Elz.
Sponsored by <The NetBSD Foundation>.
Add in ATF_TC_HEAD() of attach_pid1 the following code to run it as
non-root: atf_tc_set_md_var(tc, "require.user", "unprivileged");
Solution pointed out by Nicolas Joly.
Sponsored by <The NetBSD Foundation>.
attach_pid0 asserts that it is not valid to attach PID 0 as it is a special
kernel process.
assert_pid1 asserts that non-root user cannot attach to PID 1 as it is the
/dev/init process. This tests is skipped if run as root.
Sponsored by <The NetBSD Foundation>.
The t_wait_noproc test checks whether wait(2)-family of functions return
error and set ECHILD for lack of childs.
The t_wait_noproc_wnohang adds to options (except wait(2), wait3(2)) new
parameter WNOHANG and verifies that error is still signaled and errno set
to ECHILD.
Currently t_wait_noproc_wnohang reports failures, these have been marked as
expected and referenced to PR standards/51606.
The problem report is authored by Robert Elz, and the initial regression
has been notified by Nicolas Joly.
Remove redundant test in tests/lib/libc/sys/t_wait for wait6(2) with no
WNOHANG specified.
Sponsored by <The NetBSD Foundation>.
This test verifies that it is possible to emit multiple times SIGSTOP and
SIGCONT for a child.
Add checks that status does not return more than one valid state from the
following list: STOPPED, CONTINUED, EXITED and SIGNALED. This check fails
for WIFCONTINUED()==true as it currently and wrongly returns true for
WIFSTOPPED().
This verification is added to wait6_stopgo_loop and wait6_stop_and_go and
marked as expected failure and linked with PR standards/51603.
Remove trailing whitespace.
Sponsored by <The NetBSD Foundation>
Christos Zoulas fixed the issue that a parent sees termination of its child
before a tracer observing it for its tracee.
Many thanks to Christs for his help, he makes progress with tests so quick.
Closes PR kern/51600
Sponsored by <The NetBSD Foundation>.
This test asserts that tracer sees process termination before the parent
Currently this is not true for NetBSD.
The problem has been reported in gnats as kern/51600.
Originally an early version of this test triggered kernel panic, that
was fixed by Christos Zoulas -- thanks! Appropriate fixes are as follows:
http://mail-index.netbsd.org/source-changes/2016/11/04/msg078868.htmlhttp://mail-index.netbsd.org/source-changes/2016/11/04/msg078869.html
Mark this test as expected failure and linked with proper PR.
As an interesting note, this test uses pipe(2) to perform IPC. Use for
messages uint8_t message to be sure that it will never by transmitted
partially from a caller to a callee, this assumption simplifies the code.
Add local function await_zombie() that takes process identifier (pid).
This function uses the sysctl(7) interface to probe p_stat of a requested
process and compares it with LSZOMB.
Try to keep closing all unneeded file descriptors for pipes in order to not
run out of fds later.
Sponsored by <The NetBSD Foundation>.
A child process cannot call atf functions and expect them to magically
work like in the parent.
The printf(3) messaging from a child will not work out of the box as well
without estabilishing a communication protocol with its parent. To not
overcomplicate the tests - do not log from a child and use err(3)/errx(3)
wrapped with FORKEE_ASSERT()/FORKEE_ASSERTX() as that is guaranteed to work.
Simplify and cleanup code of the tests.
Sponsored by <The NetBSD Foundation>.
Raising SIGCONT from a ptrace(2)d child should be catched with waidpid(2)
as WIFCONTINUED() false and WIFSTOPPED() true; not both true as it does not
make much sense.
PR kern/51596
Change requested by <kre>
Checked by <christos>
Sponsored by <The NetBSD Foundation>
This test verifies calling raise(2) with the SIGCONT argument in the child.
The parent is notified with it and asserts that WIFCONTINUED() and
WIFSTOPPED() are both set.
XXX: This behavior is surprising. Linux for the same code-path returns false
for WIFCONTINUED() and true for WIFSTOPPED().
Include <stdlib.h> for EXIT_FAILURE.
This code covers (uncovers issues?) WIFCONTINUED() and is the last planned
test in the ptraceme category.
Sponsored by <The NetBSD Foundation>.
For future reference and convenience, an out-of-ATF test is as follows:
#include <sys/param.h>
#include <sys/types.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
#include <assert.h>
#include <err.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#define ATF_REQUIRE(a) assert(a)
#if defined(linux)
#define WALLSIG __WALL
#define sys_signame sys_siglist
#endif
int main(int argc, char **argv)
{
int status;
const int exitval = 5;
const int sigval = SIGSTOP, sigsent = SIGCONT;
pid_t child, wpid;
printf("1: Before forking process PID=%d\n", getpid());
ATF_REQUIRE((child = fork()) != -1);
if (child == 0) {
/* printf(3) messages from a child aren't intercepted by ATF */
/* "2: Child process PID=%d\n", getpid() */
/* "2: Before calling ptrace(PT_TRACE_ME, ...)\n" */
if (ptrace(PT_TRACE_ME, 0, NULL, 0) == -1) {
/* XXX: Is it safe to use ATF functions in a child? */
err(EXIT_FAILURE, "2: ptrace(2) call failed with "
"status %s", sys_errlist[errno]);
}
/* "2: Before raising SIGSTOP\n" */
raise(sigval);
/* "2: Before raising SIGCONT\n" */
raise(sigsent);
/* "2: Before calling _exit(%d)\n", exitval */
_exit(exitval);
} else {
printf("1: Parent process PID=%d, child's PID=%d\n", getpid(),
child);
printf("1: Before calling waitpid() for the child\n");
wpid = waitpid(child, &status, 0);
printf("1: Validating child's PID (expected %d, got %d)\n",
child, wpid);
ATF_REQUIRE(child == wpid);
printf("1: Ensuring that the child has not been exited\n");
ATF_REQUIRE(!WIFEXITED(status));
printf("1: Ensuring that the child has not been continued\n");
ATF_REQUIRE(!WIFCONTINUED(status));
printf("1: Ensuring that the child has not been terminated "
"with a signal\n");
ATF_REQUIRE(!WIFSIGNALED(status));
printf("1: Ensuring that the child has been stopped\n");
ATF_REQUIRE(WIFSTOPPED(status));
printf("1: Verifying that he child has been stopped with the"
" %s signal (received %s)\n", sys_signame[sigval],
sys_signame[WSTOPSIG(status)]);
ATF_REQUIRE(WSTOPSIG(status) == sigval);
printf("1: Before resuming the child process where it left "
"off and without signal to be sent\n");
ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0)
!= -1);
printf("1: Before calling waitpid() for the child\n");
wpid = waitpid(child, &status, WALLSIG);
printf("1: Validating that child's PID is still there\n");
ATF_REQUIRE(wpid == child);
printf("1: Ensuring that the child has not been exited\n");
ATF_REQUIRE(!WIFEXITED(status));
printf("1: Ensuring that the child has been continued\n");
ATF_REQUIRE(WIFCONTINUED(status));
printf("1: Ensuring that the child has not been terminated "
"with a signal\n");
ATF_REQUIRE(!WIFSIGNALED(status));
printf("1: Ensuring that the child has not been stopped\n");
ATF_REQUIRE(WIFSTOPPED(status));
printf("1: Before resuming the child process where it left "
"off and without signal to be sent\n");
ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
printf("1: Before calling waitpid() for the child\n");
wpid = waitpid(child, &status, 0);
printf("1: Validating that child's PID is still there\n");
ATF_REQUIRE(wpid == child);
printf("1: Ensuring that the child has been exited\n");
ATF_REQUIRE(WIFEXITED(status));
printf("1: Ensuring that the child has not been continued\n");
ATF_REQUIRE(!WIFCONTINUED(status));
printf("1: Ensuring that the child has not been terminated "
"with a signal\n");
ATF_REQUIRE(!WIFSIGNALED(status));
printf("1: Ensuring that the child has not been stopped\n");
ATF_REQUIRE(!WIFSTOPPED(status));
printf("1: Verifying that he child has exited with the "
"%d status (received %d)\n", exitval, WEXITSTATUS(status));
ATF_REQUIRE(WEXITSTATUS(status) == exitval);
printf("1: Before calling waitpid() for the exited child\n");
wpid = waitpid(child, &status, 0);
printf("1: Validating that child's PID no longer exists\n");
ATF_REQUIRE(wpid == -1);
printf("1: Validating that errno is set to %s (got %s)\n",
sys_errlist[ECHILD], sys_errlist[errno]);
ATF_REQUIRE(errno == ECHILD);
}
}
This test is modeled after traceme1 and traceme2 with the goal to test if
the child was terminated with a received signal passed with PT_CONTINUE.
Currently the three traceme tests verifies three possible status values from
waitpid(2) called by the parent:
- WIFEXITED(status),
- WIFSIGNALED(status),
- WIFSTOPPED(status)
with associated macros:
- WEXITSTATUS(status),
- WTERMSIG(status),
- WCOREDUMP(status),
- WSTOPSIG(status).
In traceme3 has been assumed that Ctrl-C (SIGINT) does not emit core(5).
Sponsored by <The NetBSD Foundation>.
This test is a clone of traceme2 with ptrace(2) calling PT_CONTINUE
with signal to be passed to the child: SIGINT. traceme1 sends no signals.
Sponsored by <The NetBSD Foundation>.
This test is a placeholder for further checks of the native ptrace(2)
function calls.
XXX: Is it safe to call ATF functions from a child? FreeBSD seems to
construct dedicated asserts for them.
XXX: printf(3) calls from a child are not intercepted by atf-run(1)
Sponsored by <The NetBSD Foundation>.
This test is a clone on t_mutex with additional two tests for timed-mutex
specific block.
All simple-mutex (not with the timed property according to the C11 wording)
specific tests are covered by pthread_mutex_timedlock(3) with parameter
ts_lengthy of sufficiently large tv_sec value (right now UINT16_MAX). If,
a test will hang, it won't wait UINT16_MAX seconds, but will be terminated
within the default timeout for ATF tests (right now 300 [sec] in my
NetBSD/amd64 setup).
This test was inspired by a classic selflock test failure of
pthread_mutex_timedlock(3) of the following form:
#include <assert.h>
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <time.h>
int main(int argc, char **argv)
{
pthread_mutex_t mtx;
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 1000;
printf("ts{.tv_sec = %d, .tv_nsec=%ld}\n", ts.tv_sec, ts.tv_nsec);
fflush(stdout);
printf("mtx_init\n");
assert(pthread_mutex_init(&mtx, NULL) == 0);
printf("mtx_lock\n");
assert(pthread_mutex_lock(&mtx) == 0);
printf("mtx_timedlock\n");
assert(pthread_mutex_timedlock(&mtx, &ts) == ETIMEDOUT);
printf("mtx_unlock\n");
assert(pthread_mutex_unlock(&mtx) == 0);
printf("mtx_destroy\n");
assert(pthread_mutex_destroy(&mtx) == 0);
return 0;
}
Current NetBSD implementation wrongly hangs on this test.
The issue was detected during development of the C11 portable threads.
My local tests in chroot presents that the are further issues:
t_timedmutex (21/25): 10 test cases
mutex1: [0.001142s] Failed: /usr/src/tests/lib/libpthread/t_timedmutex.c:75: *param != 20
mutex2: [0.261499s] Passed.
mutex3: [0.261496s] Passed.
mutex4: [0.001204s] Failed: /usr/src/tests/lib/libpthread/t_timedmutex.c:265: pthread_mutex_timedlock(&mutex, &ts_lengthy): Connection timed out
mutex5: [0.001235s] Failed: /usr/src/tests/lib/libpthread/t_timedmutex.c:337: pthread_mutex_timedlock(&mutex5, &ts_lengthy): Connection timed out
mutex6: [21.218497s] Failed: /usr/src/tests/lib/libpthread/t_timedmutex.c:512: start != 1
mutexattr1: [0.001328s] Passed.
mutexattr2: [0.001175s] Passed.
timedmutex1: [301.119397s] Failed: Test case timed out after 300 seconds
timedmutex2: [301.123081s] Failed: Test case timed out after 300 seconds
[623.990659s]
I'm also receiveing the same failure in the mutex6 test in t_mutex, so
there might be a false positives due to local chroot(8) issues.
Commit approved by <christos>.
sometimes times out under qemu under Linux, where the timing is more
accurate than under qemu under NetBSD where the the 60 second timeout
typically takes more than 60 seconds to trigger.
timing problems) fails when run under qemu. Attempt to compensate
for that (by skipping the problematic test case) when running in qemu.
This should be reverted when the PR gets fixed (either in qemu or in
the NetBSD kernel).
When a process attempts to read from an empty file originating from
psshfs mount, it waits indefinitely. Until the hanged process is
interrupted, the mounted filesystem appears to work as expected,
except for the directory containing the empty file. Processes trying
to list that directory also hang, and cause misbehaviour of the
containing directory. It is possible to create a chain of hanged
processes trying to read directories up to the mount point. At the
same time, psshfs generates some network traffic (around 5KB/s, in
my case). Interrupting the first hanged process causes emission of
an error message by all other hanged processes, and psshfs ceases
to generate network traffic. Subsequent trials to list any affected
directory or if one of the affected directories is the mount point
to unmount the filesystem, fail with the same error.
POSIX allows for the atime (or technically, any of the times) to be
updated as a side effect of searching a directory (allows, not requires).
The NetBSD UDF implementation apparently works that way, treating a
directory search as a read of the directory, and hence updating the
access time. Compensate for that in the test (rather than just
expecting failure) by verifying that the atime after the directory
search is within a small margin of the atime before the search
(currently, "small" is 1 second). We could fetch the time before
the mkdir and both stat() calls, do all of that, fetch the time after,
subtract, and require the after stat() atime to be bounded by the atime
set by the original mkdir and returned in the first stat() and that time
+ the difference in elapsed time - that would be more accurate, but is
a lot more work for little real benefit.
Should anyone be interested in doing that extra work, remember to use
monotonic time (clock_gettime(CLOCK_MOMNOTONIC, ...)) not the time of day
clock for measuring the elapsed time.
Along with this, remove the "if (udf) failure expected" and the
if (udf && we haven't failed yet) fail("random failure failed to happen")
stuff... (the "random" would have been that sometimes the mkdir and
two lookups (stat() calls) would all occur within the same clock tick,
meaning that the atimes would all be the same. Other times the clock
would tick somewhere between the mkdir() and the 2nd stat().)
This test still fails (as does another using tap interfaces) ...
tc-se:rump.ifconfig: clone_command: Device not configured
tc-se:rump.ifconfig: exec_matches: Device not configured
Something is wrong with rumpnet_tap ...
it actually (used to) behave when it was incorrect... Aside from
a possible EPERM (which is not tested) the only error possible from
mlock() is ENOMEM. POSIX also allows EINVAL if the address is not
page aligned and the implementation does not round down to the previous
page boundary, but NetBSD does.
The kernel was recently fixed to return the correct errors for mlock()
so now we really need the test to be checking them, and not expecting
the incorrect errno values that the kernel used to return.
Same for munlock() - there ENOMEM is the only possible error, again,
EINVAL cannot happen as the kernel rounds to page boundaries.
For munlock() the kernel has not yet been corrected (that is coming
real soon...) and one of the munlock() tests will currently fail
(as of the time this commit is made, hopefully not for much longer)
as it should - it is indicating a kernel bug.
Note that NetBSD mlock(2) talks about EINVAL for cases where the length
parameter is negative ... but that is a size_t - good luck having that
ever occur (the man page will soon be corrected as well.)
XXX For now, we just create required files (including mount-points)
XXX in the test's working directory. Eventually someone with more
XXX rump-foo than I should create a fss rump-component and then update
XXX the test to run under rump.
by Andy Doran. Also document the get/set pshared thread calls as not
implemented, and add a skeleton implementation that is disabled.
XXX: document _sched_protect(2).
do-the-test code rather than in a test's head() code. This way, if we
ever add more tests, we simply need to invoke the common do-the-test code
with an appropriate flag argument rather than duplicating the test.
For test case loop2, where there are multiple prime factors greater
than 65535, skip the test if the program was not built with crypto
support. We need crypto/openssl for large factors.
Should address PR bin/23663
"expire" value of route get output is unexpectedly a negative value
on rump kernel for some reasons and the tests almost always fail
on babylon5. So just ignore it to make tests work for now. Should
fix it in the future.
negative value. So, if the value gets written into a sysctl variable,
and then is read back, the twos-complement value is displayed.
So, when checking for the value having been written, make sure we check
for the correct value!
size of the previous one (using on-the-fly gzip compression), and includes
more cases (including a gpg-signed file for cross-testing purposes).
Add the appropriate Testspec file.
redirection works correctly (including that the bugs reported in those PRs
are fixed.) Note that the tests for 48875 are slow, so one of the new
test cases ends up running > 25 seconds (just doing sleeps) - each individual
test is just a few seconds, but there are several of them.
OK christos@
behaviour (and failed with the NetBSD shell, and was marked as expected to
fail.) Other shells do different things. The test was worthless, and is
now gone.
OK christos@
file descriptors outside the 0..9 range, and complex fd
reassignments. Also test that the shell can cope with the
value of ulimit -n changing (downwards, up is harmless)
(Freom kre@)
various dates over a span of a few decades, instead of just once
relative to the current date. This makes the test fail consistently
instead of sometimes failing and sometimes not depending on when
it is run. Makes PR lib/50574 consistently reproducible.