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