aboutsummaryrefslogtreecommitdiff
path: root/contrib/random-incorrect-layout.sh
blob: d6b250fb4548e8af78bfa41218fdebc907029ea0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# Randomized Layout for debug purposes. This version randomly makes some errors
# see how river handles incorrect output of layout executables.

CLIENTS="$1"
OUTPUT_WIDTH="$4"
OUTPUT_HEIGHT="$5"

for _ in $(seq 1 "$CLIENTS")
do
	WIDTH="$(( ( OUTPUT_WIDTH  / 5 ) ))"
	HEIGHT="$(( ( OUTPUT_HEIGHT  / 5 ) ))"
	X="$(( ( RANDOM % ( OUTPUT_WIDTH  - WIDTH  ) )  + 1 ))"
	Y="$(( ( RANDOM % ( OUTPUT_HEIGHT - HEIGHT ) )  + 1 ))"

	# Mix in some errors
	case "$(( ( RANDOM % 10 ) ))" in
		0) # Too few layout rows
			;;

		1) # Too many layout rows
			echo "$X $Y $WIDTH $HEIGHT"
			echo "$X $Y $WIDTH $HEIGHT"
			;;

		2) # Too few layout columns
			echo "$X $Y $WIDTH"
			;;

		3) # Too many layout columns
			echo "$X $Y $WIDTH $HEIGHT $X"
			;;


		4) # Negative view size
			echo "$X $Y -$WIDTH $HEIGHT $X"
			;;

		*) # Expected behaviour
			echo "$X $Y $WIDTH $HEIGHT"
			;;
	esac
done