From owner-svn-src-projects@FreeBSD.ORG Mon Nov 28 20:03:34 2011 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D078106566B; Mon, 28 Nov 2011 20:03:34 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 223448FC15; Mon, 28 Nov 2011 20:03:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pASK3YiN006853; Mon, 28 Nov 2011 20:03:34 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pASK3YPX006852; Mon, 28 Nov 2011 20:03:34 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201111282003.pASK3YPX006852@svn.freebsd.org> From: Peter Holm Date: Mon, 28 Nov 2011 20:03:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228096 - projects/stress2/misc X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Nov 2011 20:03:34 -0000 Author: pho Date: Mon Nov 28 20:03:33 2011 New Revision: 228096 URL: http://svn.freebsd.org/changeset/base/228096 Log: Added regression test. Added: projects/stress2/misc/syscall3.sh (contents, props changed) Added: projects/stress2/misc/syscall3.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/stress2/misc/syscall3.sh Mon Nov 28 20:03:33 2011 (r228096) @@ -0,0 +1,133 @@ +#!/bin/sh + +# +# Copyright (c) 2011 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 random syscalls with random arguments. +# Regression test of r209697 + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +odir=`pwd` +cd /tmp +sed '1,/^EOF/d' < $odir/$0 > syscall3.c +cc -o syscall3 -Wall syscall3.c +rm -f syscall3.c + +kldstat -v | grep -q sysvmsg || kldload sysvmsg +kldstat -v | grep -q sysvsem || kldload sysvsem +kldstat -v | grep -q sysvshm || kldload sysvshm + +kldstat -v | grep -q aio || kldload aio +kldstat -v | grep -q mqueuefs || kldload mqueuefs + +mkdir -p $RUNDIR/syscall3 +cd $RUNDIR/syscall3 + +for i in `jot 4`; do + su $testuser -c /tmp/syscall3 & +done +for i in `jot 4`; do + wait +done + +chflags -R 0 $RUNDIR/syscall3 +rm -rf /tmp/syscall3 $RUNDIR/syscall3 +exit +EOF +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static unsigned int ignore[] = { + SYS_syscall, + SYS_exit, + SYS_fork, + 11, /* 11 is obsolete execv */ + SYS_unmount, + SYS_reboot, + SYS_vfork, + 109, /* 109 is old sigblock */ + 111, /* 111 is old sigsuspend */ + SYS_shutdown, + SYS___syscall, + SYS_rfork, + SYS_sigsuspend, + SYS_mac_syscall, + SYS_sigtimedwait, + SYS_sigwaitinfo, +}; + +void +handler(int i) { + _exit(0); +} + +int +main(int argc, char **argv) +{ + unsigned int i; + unsigned int arg1, arg2, arg3, arg4, arg5, arg6, arg7, num; + + signal(SIGSYS, SIG_IGN); + signal(SIGALRM, handler); + alarm(600); + for (;;) { + num = 0; + while (num == 0) { + num = arc4random(); + for (i = 0; i < sizeof(ignore) / sizeof(ignore[0]); i++) + if (num == ignore[i]) { + num = 0; + break; + } + } + arg1 = arc4random(); + arg2 = arc4random(); + arg3 = arc4random(); + arg4 = arc4random(); + arg5 = arc4random(); + arg6 = arc4random(); + arg7 = arc4random(); + + if (argc > 1) + printf("%2d : syscall(%3d, %x, %x, %x, %x, %x, %x, %x)\n", + i, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + syscall(num, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + } + + return (0); +}