4 # Copyright (c) 2016 EMC Corp.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 # Test parallel access to /dev. A non-root version.
31 # "panic: Bad link elm 0xfffff8000b07ed00 prev->next != elm" seen.
32 # https://people.freebsd.org/~pho/stress/log/dev2.txt
36 # "panic: Assertion !tty_gone(tp) failed at ../sys/ttydevsw.h:165" seen:
37 # https://people.freebsd.org/~pho/stress/log/dev2-2.txt
39 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
43 kldstat -v | grep -q pty || { kldload pty || exit 0; }
46 sed '1,/^EOF/d' < $here/$0 > dev2.c
47 mycc -o dev2 -Wall -Wextra -O2 dev2.c || exit 1
51 "(cd $here/../testcases/swap; ./swap -t 6m -i 20 -k -l 100)" > \
54 su $testuser -c /tmp/dev2
56 while pkill -9 swap; do
63 #include <sys/types.h>
84 handler(int i __unused) {
97 ftsoptions = FTS_PHYSICAL;
102 while (time(NULL) - start < RUNTIME) {
103 if ((fts = fts_open(args, ftsoptions, NULL)) == NULL)
108 while ((p = fts_read(fts)) != NULL) {
109 if (p->fts_info == FTS_D ||
110 p->fts_info == FTS_DP)
113 if ((fd = open(p->fts_path, arc4random() % (O_CLOEXEC << 2))) == -1)
116 usleep(arc4random() % 1000);
121 if (errno != 0 && errno != ENOENT)
123 if (fts_close(fts) == -1)
124 err(1, "fts_close()");
135 signal(SIGALRM, handler);
136 for (i = 0; i < PARALLEL; i++)
140 for (i = 0; i < PARALLEL; i++)