2 * Copyright (c) 2008 Peter Holm <pho@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 /* Call random system calls with random arguments */
35 #include <sys/syscall.h>
36 #include <sys/resource.h>
41 static char path[128];
43 static int starting_dir = 0;
45 static int ignore[] = {
49 11, /* 11 is obsolete execv */
53 109, /* 109 is old sigblock */
54 111, /* 111 is old sigsuspend */
71 sprintf(path,"%s.%05d", getprogname(), getpid());
72 (void)mkdir(path, 0770);
73 if (chdir(path) == -1)
74 err(1, "chdir(%s), %s:%d", path, __FILE__, __LINE__);
75 if ((starting_dir = open(".", 0)) < 0)
79 num = atoi(op->argv[0]);
80 for (i = 0; i < sizeof(ignore) / sizeof(ignore[0]); i++)
81 if (num == ignore[i]) {
82 printf("syscall %d is marked a no test!\n", num);
88 num = random_int(0, SYS_MAXSYSCALL);
89 for (i = 0; i < sizeof(ignore) / sizeof(ignore[0]); i++)
90 if (num == ignore[i]) {
97 printf("Testing syscall #%d, pid %d\n", num, getpid());
99 /* Multiple parallel core dump may panic the kernel with:
100 panic: kmem_malloc(184320): kmem_map too small: 84426752 total allocated
102 rl.rlim_max = rl.rlim_cur = 0;
103 if (setrlimit(RLIMIT_CORE, &rl) == -1)
106 setproctitle("#%d", num);
114 if (starting_dir != 0) {
115 if (fchdir(starting_dir) == -1)
117 (void)system("find . -type d -exec chmod 777 {} \\;");
118 (void)system("find . -type f -exec chmod 666 {} \\;");
119 (void)system("find . -delete");
121 if (chdir("..") == -1)
123 if (rmdir(path) == -1)
124 err(1, "rmdir(%s), %s:%d", path, __FILE__, __LINE__);
133 unsigned int arg1, arg2, arg3, arg4, arg5, arg6, arg7;
135 for (i = 0; i < 128; i++) {
145 printf("%2d : syscall(%3d, %x, %x, %x, %x, %x, %x, %x)\n",
146 i, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
147 syscall(num, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
150 while (done_testing == 0)