1#!/bin/sh 2 3# 4# Copyright (c) 2013 Peter Holm <pho@FreeBSD.org> 5# All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 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. 15# 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 26# SUCH DAMAGE. 27# 28 29[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 30 31# Run with marcus.cfg on a 1g swap backed MD 32# "panic: vm_radix_remove: invalid key found" seen. 33 34. ../default.cfg 35 36here=`pwd` 37cd /tmp 38sed '1,/^EOF/d' < $here/$0 > fts1.c 39mycc -o fts1 -Wall -Wextra fts1.c || exit 1 40rm -f fts1.c 41cd $here 42 43mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint 44mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart 45 46mdconfig -a -t swap -s 1g -u $mdstart || exit 1 47bsdlabel -w md$mdstart auto 48 49newfs $newfs_flags md${mdstart}$part > /dev/null 50 51mount /dev/md${mdstart}$part $mntpoint 52chmod 777 $mntpoint 53 54export runRUNTIME=20m 55export RUNDIR=$mntpoint/stressX 56 57su $testuser -c 'cd ..; ./run.sh marcus.cfg' > /dev/null & 58pid=$! 59while kill -0 $pid 2> /dev/null; do 60 /tmp/fts1 $mntpoint 61 sleep 1 62done 63wait 64 65s=0 66for i in `jot 6`; do 67 umount $mntpoint && break || sleep 10 68done 69[ $i -eq 6 ] && s=1 70mdconfig -d -u $mdstart 71rm -f /tmp/fts1 72exit $s 73EOF 74#include <sys/param.h> 75#include <err.h> 76#include <errno.h> 77#include <fts.h> 78#include <libutil.h> 79#include <stdint.h> 80#include <stdio.h> 81#include <stdlib.h> 82#include <string.h> 83#include <unistd.h> 84 85int 86test(char *path) 87{ 88 89 FTS *fts; 90 FTSENT *p; 91 int ftsoptions; 92 char *args[2]; 93 94 ftsoptions = FTS_PHYSICAL; 95 args[0] = path; 96 args[1] = 0; 97 98 if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) 99 err(1, "fts_open"); 100 101 while ((p = fts_read(fts)) != NULL) { 102 switch (p->fts_info) { 103 case FTS_F: /* Ignore. */ 104 break; 105 case FTS_D: /* Ignore. */ 106 break; 107 case FTS_DP: 108 break; 109 case FTS_DC: /* Ignore. */ 110 break; 111 case FTS_SL: /* Ignore. */ 112 break; 113 case FTS_DNR: /* Warn, continue. */ 114 case FTS_ERR: 115 case FTS_NS: 116 case FTS_DEFAULT: 117 break; 118 default: 119 printf("%s: default, %d\n", getprogname(), p->fts_info); 120 break; 121 } 122 } 123 124 if (errno != 0 && errno != ENOENT) 125 err(1, "fts_read"); 126 if (fts_close(fts) == -1) 127 err(1, "fts_close()"); 128 129 return (0); 130} 131 132int 133main(int argc, char **argv) 134{ 135 int i; 136 137 if (argc != 2) 138 errx(1, "Usage: %s <path>", argv[0]); 139 alarm(600); 140 for (i = 0; i < 100; i++) 141 test(argv[1]); 142 143 return (0); 144} 145