summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/rseq/run_param_test.sh
blob: e426304fd4a02bab10fdf7e841e92e9f8160cadd (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0+ or MIT

NR_CPUS=`grep '^processor' /proc/cpuinfo | wc -l`

EXTRA_ARGS=${@}

OLDIFS="$IFS"
IFS=$'\n'
TEST_LIST=(
	"-T s"
	"-T l"
	"-T b"
	"-T b -M"
	"-T m"
	"-T m -M"
	"-T i"
)

TEST_NAME=(
	"spinlock"
	"list"
	"buffer"
	"buffer with barrier"
	"memcpy"
	"memcpy with barrier"
	"increment"
)
IFS="$OLDIFS"

REPS=1000
SLOW_REPS=100
NR_THREADS=$((6*${NR_CPUS}))

function do_tests()
{
	local i=0
	while [ "$i" -lt "${#TEST_LIST[@]}" ]; do
		echo "Running test ${TEST_NAME[$i]}"
		./param_test ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1
		echo "Running compare-twice test ${TEST_NAME[$i]}"
		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1
		let "i++"
	done
}

echo "Default parameters"
do_tests

echo "Loop injection: 10000 loops"

OLDIFS="$IFS"
IFS=$'\n'
INJECT_LIST=(
	"1"
	"2"
	"3"
	"4"
	"5"
	"6"
	"7"
	"8"
	"9"
)
IFS="$OLDIFS"

NR_LOOPS=10000

i=0
while [ "$i" -lt "${#INJECT_LIST[@]}" ]; do
	echo "Injecting at <${INJECT_LIST[$i]}>"
	do_tests -${INJECT_LIST[i]} ${NR_LOOPS}
	let "i++"
done
NR_LOOPS=

function inject_blocking()
{
	OLDIFS="$IFS"
	IFS=$'\n'
	INJECT_LIST=(
		"7"
		"8"
		"9"
	)
	IFS="$OLDIFS"

	NR_LOOPS=-1

	i=0
	while [ "$i" -lt "${#INJECT_LIST[@]}" ]; do
		echo "Injecting at <${INJECT_LIST[$i]}>"
		do_tests -${INJECT_LIST[i]} -1 ${@}
		let "i++"
	done
	NR_LOOPS=
}

echo "Yield injection (25%)"
inject_blocking -m 4 -y

echo "Yield injection (50%)"
inject_blocking -m 2 -y

echo "Yield injection (100%)"
inject_blocking -m 1 -y

echo "Kill injection (25%)"
inject_blocking -m 4 -k

echo "Kill injection (50%)"
inject_blocking -m 2 -k

echo "Kill injection (100%)"
inject_blocking -m 1 -k

echo "Sleep injection (1ms, 25%)"
inject_blocking -m 4 -s 1

echo "Sleep injection (1ms, 50%)"
inject_blocking -m 2 -s 1

echo "Sleep injection (1ms, 100%)"
inject_blocking -m 1 -s 1