Index: user/pho/stress2/misc/procfs.sh =================================================================== --- user/pho/stress2/misc/procfs.sh (revision 269803) +++ user/pho/stress2/misc/procfs.sh (revision 269804) @@ -1,76 +1,76 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mounts=15 # Number of parallel scripts mdstart=$mdstart # Use md unit numbers from this point if [ $# -eq 0 ]; then for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) [ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m mount | grep "$mntpoint" | grep -q md$m && umount ${mntpoint}$m done # start the parallel tests touch /tmp/$0 for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) ./$0 $m & - ./$0 find $m & + ./$0 find $m > /dev/null 2>&1 & done for i in `jot $mounts`; do wait; wait done else if [ $1 = find ]; then while [ -r /tmp/$0 ]; do ls -lR ${mntpoint}* done echo "Done 1 @ `date '+%T'`" else # The test: Parallel mount and unmounts for i in `jot 1024`; do m=$1 mount -t procfs proc ${mntpoint}$m while mount | grep -qw $mntpoint$m; do opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f") umount $opt ${mntpoint}$m > /dev/null 2>&1 done done rm -f /tmp/$0 echo "Done 2 @ `date '+%T'`" fi fi Index: user/pho/stress2/misc/procfs3.sh =================================================================== --- user/pho/stress2/misc/procfs3.sh (nonexistent) +++ user/pho/stress2/misc/procfs3.sh (revision 269804) @@ -0,0 +1,152 @@ +#!/bin/sh + +# +# Copyright (c) 2012 Peter Holm +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# procfs(5) test scenario. +# "panic: wchan 0xc10a4f68 has no wmesg" seen + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > procfs3.c +cc -o procfs3 -Wall -Wextra -O2 procfs3.c || exit 1 +rm -f procfs3.c +cd $here + +su $testuser -c /tmp/procfs3 + +rm -f /tmp/procfs3 +exit 0 +EOF +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PARALLEL 10 + +void +handler(int i __unused) +{ +} + +int +test(void) +{ + + FTS *fts; + FTSENT *p; + int ftsoptions; + char *args[2]; + int fd, i; + char buf[1629]; + + ftsoptions = FTS_PHYSICAL; + args[0] = "/proc"; + args[1] = 0; + + if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) + err(1, "fts_open"); + + while ((p = fts_read(fts)) != NULL) { + switch (p->fts_info) { + case FTS_F: /* Ignore. */ + break; + case FTS_D: /* Ignore. */ + continue; + case FTS_DP: + continue; + case FTS_DC: /* Ignore. */ + continue; + case FTS_SL: /* Ignore. */ + continue; + case FTS_DNR: /* Warn, continue. */ + case FTS_ERR: + case FTS_NS: + case FTS_DEFAULT: + warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); + break; + default: + printf("%s: default, %d\n", getprogname(), p->fts_info); + break; + } + + if ((fd = open(p->fts_path, O_RDONLY)) == -1) + continue; + signal(SIGALRM, handler); + alarm(1); + + for (i = 0; i < 2; i++) { + read(fd, buf, 1629); + } + close(fd); + } + + if (errno != 0 && errno != ENOENT) + err(1, "fts_read"); + if (fts_close(fts) == -1) + err(1, "fts_close()"); + + return (0); +} + +int +main(void) +{ + int i, j; + + for (i = 0; i < PARALLEL; i++) { + if (fork() == 0) { + for (j = 0; j < 50; j++) { + test(); + } + _exit(0); + } + } + + for (i = 0; i < PARALLEL; i++) + wait(NULL); + + return (0); +} Property changes on: user/pho/stress2/misc/procfs3.sh ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: user/pho/stress2/misc/procfs4.sh =================================================================== --- user/pho/stress2/misc/procfs4.sh (nonexistent) +++ user/pho/stress2/misc/procfs4.sh (revision 269804) @@ -0,0 +1,146 @@ +#!/bin/sh + +# +# Copyright (c) 2012 Peter Holm +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# Test scenario idea by kib@ + +# "panic: double fault" seen due to recurtion + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +mount | grep -q procfs || mount -t procfs procfs /proc +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > procfs4.c +cc -o procfs4 -Wall -Wextra -O2 procfs4.c +rm -f procfs4.c +cd $here + +su $testuser -c /tmp/procfs4 + +rm -f /tmp/procfs4 +exit 0 +EOF +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PARALLEL 10 +#define LOOPS 1000 + +char *files[] = { + "cmdline", + "ctl", + "dbregs", + "etype", + "file", + "fpregs", + "map", + "mem", + "note", + "notepg", + "osrel", + "regs", + "rlimit", + "status" +}; + +void +test(void) +{ + pid_t p; + int fd, i, j, n, opens; + char path[128]; + + for (i = 0; i < 64; i++) { + if ((p = fork()) == 0) { + setproctitle("Sleeper"); + usleep(20000); + usleep(arc4random() % 200); + for (j = 0; j < 10000; j++) + getpid(); + _exit(0); + } + opens = 0; + setproctitle("load"); + for (j = 0; j < 14; j++) { + snprintf(path, sizeof(path), "/proc/%d/%s", p, files[j]); + if ((fd = open(path, O_RDWR)) == -1) + if ((fd = open(path, O_RDONLY)) == -1) + continue; + + ioctl(fd, FIONREAD, &n); + if (ioctl(fd, FIONBIO, &n) != -1) + opens++; + + close(fd); + } + kill(p, SIGHUP); +#if 0 + if (opens < 1) + fprintf(stderr, "Warn %d open(s) for pid %d\n", opens, getpid()); +#endif + } + + for (i = 0; i < 64; i++) + wait(NULL); + + _exit(0); +} + +int +main(void) +{ + int i, j; + + for (i = 0; i < LOOPS; i++) { + for (j = 0; j < PARALLEL; j++) { + if (fork() == 0) + test(); + } + + for (j = 0; j < PARALLEL; j++) + wait(NULL); + usleep(10000); + } + + return (0); +} Property changes on: user/pho/stress2/misc/procfs4.sh ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property