xref: /freebsd/tools/test/stress2/misc/watchman.sh (revision 8a272653d9fbd9fc37691c9aad6a05089b4ecb4d)
1*8a272653SPeter Holm#!/bin/sh
2*8a272653SPeter Holm
3*8a272653SPeter Holm# Bug 214923 - kqueue hangs with busy loop
4*8a272653SPeter Holm# Test scenario by: Jihyun Yu <yjh0502@gmail.com>
5*8a272653SPeter Holm
6*8a272653SPeter Holm# https://people.freebsd.org/~pho/stress/log/watchman.txt
7*8a272653SPeter Holm# Fixed by: r310302
8*8a272653SPeter Holm
9*8a272653SPeter Holm. ../default.cfg
10*8a272653SPeter Holm
11*8a272653SPeter Holm[ -z `which watchman` ] && { echo "watchman is not installed"; exit 0; }
12*8a272653SPeter Holm
13*8a272653SPeter Holmdaemon sh -c "(cd ../testcases/swap; ./swap -t 5m -i 20 -h -l 100)" > \
14*8a272653SPeter Holm    /dev/null
15*8a272653SPeter Holm
16*8a272653SPeter Holmdir=/tmp/watchman
17*8a272653SPeter Holmrm -rf $dir
18*8a272653SPeter Holmmkdir -p $dir
19*8a272653SPeter Holmcd $dir
20*8a272653SPeter Holm
21*8a272653SPeter Holmmkdir -p foo bar
22*8a272653SPeter Holmseq -w 0 100 | xargs -n1 -I{} touch foo/{}.c
23*8a272653SPeter Holm
24*8a272653SPeter Holmecho '["subscribe","./","mysub",{"fields":["name"],"expression":["allof",'\
25*8a272653SPeter Holm    '["type","f"],["not","empty"],["suffix","c"]]}]' | \
26*8a272653SPeter Holm    watchman -p -j --server-encoding=json > /dev/null &
27*8a272653SPeter Holmpids=$!
28*8a272653SPeter Holmwhile true; do find bar/ -type f | xargs -n1 -P5 -I'{}' mv '{}' foo; done &
29*8a272653SPeter Holmpids="$pids $!"
30*8a272653SPeter Holmwhile true; do find foo/ -type f | xargs -n1 -P5 -I'{}' mv '{}' bar; done &
31*8a272653SPeter Holmpids="$pids $!"
32*8a272653SPeter Holm
33*8a272653SPeter Holmsleep 180
34*8a272653SPeter Holmwhile pgrep -q swap; do
35*8a272653SPeter Holm	pkill -9 swap
36*8a272653SPeter Holmdone
37*8a272653SPeter Holmkill -9 $pids
38*8a272653SPeter Holmpkill watchman
39*8a272653SPeter Holmwait
40*8a272653SPeter Holmcd /
41*8a272653SPeter Holmsleep 1
42*8a272653SPeter Holmrm -rf $dir
43*8a272653SPeter Holmexit 0
44