xref: /linux/tools/testing/selftests/rseq/run_param_test.sh (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
1ccba8b64SMathieu Desnoyers#!/bin/bash
2ccba8b64SMathieu Desnoyers# SPDX-License-Identifier: GPL-2.0+ or MIT
3ccba8b64SMathieu Desnoyers
40a7dc82eSMathieu DesnoyersNR_CPUS=`grep '^processor' /proc/cpuinfo | wc -l`
50a7dc82eSMathieu Desnoyers
6ccba8b64SMathieu DesnoyersEXTRA_ARGS=${@}
7ccba8b64SMathieu Desnoyers
8ccba8b64SMathieu DesnoyersOLDIFS="$IFS"
9ccba8b64SMathieu DesnoyersIFS=$'\n'
10ccba8b64SMathieu DesnoyersTEST_LIST=(
11ccba8b64SMathieu Desnoyers	"-T s"
12ccba8b64SMathieu Desnoyers	"-T l"
13ccba8b64SMathieu Desnoyers	"-T b"
14ccba8b64SMathieu Desnoyers	"-T b -M"
15ccba8b64SMathieu Desnoyers	"-T m"
16ccba8b64SMathieu Desnoyers	"-T m -M"
17ccba8b64SMathieu Desnoyers	"-T i"
18f166b111SPeter Oskolkov	"-T r"
19ccba8b64SMathieu Desnoyers)
20ccba8b64SMathieu Desnoyers
21ccba8b64SMathieu DesnoyersTEST_NAME=(
22ccba8b64SMathieu Desnoyers	"spinlock"
23ccba8b64SMathieu Desnoyers	"list"
24ccba8b64SMathieu Desnoyers	"buffer"
25ccba8b64SMathieu Desnoyers	"buffer with barrier"
26ccba8b64SMathieu Desnoyers	"memcpy"
27ccba8b64SMathieu Desnoyers	"memcpy with barrier"
28ccba8b64SMathieu Desnoyers	"increment"
29f166b111SPeter Oskolkov	"membarrier"
30ccba8b64SMathieu Desnoyers)
31ccba8b64SMathieu DesnoyersIFS="$OLDIFS"
32ccba8b64SMathieu Desnoyers
33ccba8b64SMathieu DesnoyersREPS=1000
34ccba8b64SMathieu DesnoyersSLOW_REPS=100
350a7dc82eSMathieu DesnoyersNR_THREADS=$((6*${NR_CPUS}))
36ccba8b64SMathieu Desnoyers
37ccba8b64SMathieu Desnoyersfunction do_tests()
38ccba8b64SMathieu Desnoyers{
39ccba8b64SMathieu Desnoyers	local i=0
40ccba8b64SMathieu Desnoyers	while [ "$i" -lt "${#TEST_LIST[@]}" ]; do
41ccba8b64SMathieu Desnoyers		echo "Running test ${TEST_NAME[$i]}"
420a7dc82eSMathieu Desnoyers		./param_test ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1
43ccba8b64SMathieu Desnoyers		echo "Running compare-twice test ${TEST_NAME[$i]}"
440a7dc82eSMathieu Desnoyers		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1
45*ee31fff0SMathieu Desnoyers
46*ee31fff0SMathieu Desnoyers		echo "Running mm_cid test ${TEST_NAME[$i]}"
47*ee31fff0SMathieu Desnoyers		./param_test_mm_cid ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1
48*ee31fff0SMathieu Desnoyers		echo "Running mm_cid compare-twice test ${TEST_NAME[$i]}"
49*ee31fff0SMathieu Desnoyers		./param_test_mm_cid_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1
50ccba8b64SMathieu Desnoyers		let "i++"
51ccba8b64SMathieu Desnoyers	done
52ccba8b64SMathieu Desnoyers}
53ccba8b64SMathieu Desnoyers
54ccba8b64SMathieu Desnoyersecho "Default parameters"
55ccba8b64SMathieu Desnoyersdo_tests
56ccba8b64SMathieu Desnoyers
57ccba8b64SMathieu Desnoyersecho "Loop injection: 10000 loops"
58ccba8b64SMathieu Desnoyers
59ccba8b64SMathieu DesnoyersOLDIFS="$IFS"
60ccba8b64SMathieu DesnoyersIFS=$'\n'
61ccba8b64SMathieu DesnoyersINJECT_LIST=(
62ccba8b64SMathieu Desnoyers	"1"
63ccba8b64SMathieu Desnoyers	"2"
64ccba8b64SMathieu Desnoyers	"3"
65ccba8b64SMathieu Desnoyers	"4"
66ccba8b64SMathieu Desnoyers	"5"
67ccba8b64SMathieu Desnoyers	"6"
68ccba8b64SMathieu Desnoyers	"7"
69ccba8b64SMathieu Desnoyers	"8"
70ccba8b64SMathieu Desnoyers	"9"
71ccba8b64SMathieu Desnoyers)
72ccba8b64SMathieu DesnoyersIFS="$OLDIFS"
73ccba8b64SMathieu Desnoyers
74ccba8b64SMathieu DesnoyersNR_LOOPS=10000
75ccba8b64SMathieu Desnoyers
76ccba8b64SMathieu Desnoyersi=0
77ccba8b64SMathieu Desnoyerswhile [ "$i" -lt "${#INJECT_LIST[@]}" ]; do
78ccba8b64SMathieu Desnoyers	echo "Injecting at <${INJECT_LIST[$i]}>"
79ccba8b64SMathieu Desnoyers	do_tests -${INJECT_LIST[i]} ${NR_LOOPS}
80ccba8b64SMathieu Desnoyers	let "i++"
81ccba8b64SMathieu Desnoyersdone
82ccba8b64SMathieu DesnoyersNR_LOOPS=
83ccba8b64SMathieu Desnoyers
84ccba8b64SMathieu Desnoyersfunction inject_blocking()
85ccba8b64SMathieu Desnoyers{
86ccba8b64SMathieu Desnoyers	OLDIFS="$IFS"
87ccba8b64SMathieu Desnoyers	IFS=$'\n'
88ccba8b64SMathieu Desnoyers	INJECT_LIST=(
89ccba8b64SMathieu Desnoyers		"7"
90ccba8b64SMathieu Desnoyers		"8"
91ccba8b64SMathieu Desnoyers		"9"
92ccba8b64SMathieu Desnoyers	)
93ccba8b64SMathieu Desnoyers	IFS="$OLDIFS"
94ccba8b64SMathieu Desnoyers
95ccba8b64SMathieu Desnoyers	NR_LOOPS=-1
96ccba8b64SMathieu Desnoyers
97ccba8b64SMathieu Desnoyers	i=0
98ccba8b64SMathieu Desnoyers	while [ "$i" -lt "${#INJECT_LIST[@]}" ]; do
99ccba8b64SMathieu Desnoyers		echo "Injecting at <${INJECT_LIST[$i]}>"
100ccba8b64SMathieu Desnoyers		do_tests -${INJECT_LIST[i]} -1 ${@}
101ccba8b64SMathieu Desnoyers		let "i++"
102ccba8b64SMathieu Desnoyers	done
103ccba8b64SMathieu Desnoyers	NR_LOOPS=
104ccba8b64SMathieu Desnoyers}
105ccba8b64SMathieu Desnoyers
106ccba8b64SMathieu Desnoyersecho "Yield injection (25%)"
107ccba8b64SMathieu Desnoyersinject_blocking -m 4 -y
108ccba8b64SMathieu Desnoyers
109ccba8b64SMathieu Desnoyersecho "Yield injection (50%)"
110ccba8b64SMathieu Desnoyersinject_blocking -m 2 -y
111ccba8b64SMathieu Desnoyers
112ccba8b64SMathieu Desnoyersecho "Yield injection (100%)"
113ccba8b64SMathieu Desnoyersinject_blocking -m 1 -y
114ccba8b64SMathieu Desnoyers
115ccba8b64SMathieu Desnoyersecho "Kill injection (25%)"
116ccba8b64SMathieu Desnoyersinject_blocking -m 4 -k
117ccba8b64SMathieu Desnoyers
118ccba8b64SMathieu Desnoyersecho "Kill injection (50%)"
119ccba8b64SMathieu Desnoyersinject_blocking -m 2 -k
120ccba8b64SMathieu Desnoyers
121ccba8b64SMathieu Desnoyersecho "Kill injection (100%)"
122ccba8b64SMathieu Desnoyersinject_blocking -m 1 -k
123ccba8b64SMathieu Desnoyers
124ccba8b64SMathieu Desnoyersecho "Sleep injection (1ms, 25%)"
125ccba8b64SMathieu Desnoyersinject_blocking -m 4 -s 1
126ccba8b64SMathieu Desnoyers
127ccba8b64SMathieu Desnoyersecho "Sleep injection (1ms, 50%)"
128ccba8b64SMathieu Desnoyersinject_blocking -m 2 -s 1
129ccba8b64SMathieu Desnoyers
130ccba8b64SMathieu Desnoyersecho "Sleep injection (1ms, 100%)"
131ccba8b64SMathieu Desnoyersinject_blocking -m 1 -s 1
132