svn commit: r269804 - user/pho/stress2/misc
Peter Holm
pho at FreeBSD.org
Mon Aug 11 07:04:09 UTC 2014
Author: pho
Date: Mon Aug 11 07:04:08 2014
New Revision: 269804
URL: http://svnweb.freebsd.org/changeset/base/269804
Log:
Let procfs.sh be less verbose and added two procfs scenarios.
Sponsored by: EMC / Isilon storage division
Added:
user/pho/stress2/misc/procfs3.sh (contents, props changed)
user/pho/stress2/misc/procfs4.sh (contents, props changed)
Modified:
user/pho/stress2/misc/procfs.sh
Modified: user/pho/stress2/misc/procfs.sh
==============================================================================
--- user/pho/stress2/misc/procfs.sh Mon Aug 11 07:01:29 2014 (r269803)
+++ user/pho/stress2/misc/procfs.sh Mon Aug 11 07:04:08 2014 (r269804)
@@ -47,7 +47,7 @@ if [ $# -eq 0 ]; then
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
Added: user/pho/stress2/misc/procfs3.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/pho/stress2/misc/procfs3.sh Mon Aug 11 07:04:08 2014 (r269804)
@@ -0,0 +1,152 @@
+#!/bin/sh
+
+#
+# Copyright (c) 2012 Peter Holm <pho at FreeBSD.org>
+# 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 <sys/param.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <fts.h>
+#include <libutil.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#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);
+}
Added: user/pho/stress2/misc/procfs4.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/pho/stress2/misc/procfs4.sh Mon Aug 11 07:04:08 2014 (r269804)
@@ -0,0 +1,146 @@
+#!/bin/sh
+
+#
+# Copyright (c) 2012 Peter Holm <pho at FreeBSD.org>
+# 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 <sys/param.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#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);
+}
More information about the svn-src-user
mailing list