WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / rseq / run_param_test.sh
blobf51bc83c9e41fff1fd3d4fb9d76b3305438826c4
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0+ or MIT
4 NR_CPUS=`grep '^processor' /proc/cpuinfo | wc -l`
6 EXTRA_ARGS=${@}
8 OLDIFS="$IFS"
9 IFS=$'\n'
10 TEST_LIST=(
11 "-T s"
12 "-T l"
13 "-T b"
14 "-T b -M"
15 "-T m"
16 "-T m -M"
17 "-T i"
18 "-T r"
21 TEST_NAME=(
22 "spinlock"
23 "list"
24 "buffer"
25 "buffer with barrier"
26 "memcpy"
27 "memcpy with barrier"
28 "increment"
29 "membarrier"
31 IFS="$OLDIFS"
33 REPS=1000
34 SLOW_REPS=100
35 NR_THREADS=$((6*${NR_CPUS}))
37 function do_tests()
39 local i=0
40 while [ "$i" -lt "${#TEST_LIST[@]}" ]; do
41 echo "Running test ${TEST_NAME[$i]}"
42 ./param_test ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1
43 echo "Running compare-twice test ${TEST_NAME[$i]}"
44 ./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1
45 let "i++"
46 done
49 echo "Default parameters"
50 do_tests
52 echo "Loop injection: 10000 loops"
54 OLDIFS="$IFS"
55 IFS=$'\n'
56 INJECT_LIST=(
57 "1"
58 "2"
59 "3"
60 "4"
61 "5"
62 "6"
63 "7"
64 "8"
65 "9"
67 IFS="$OLDIFS"
69 NR_LOOPS=10000
71 i=0
72 while [ "$i" -lt "${#INJECT_LIST[@]}" ]; do
73 echo "Injecting at <${INJECT_LIST[$i]}>"
74 do_tests -${INJECT_LIST[i]} ${NR_LOOPS}
75 let "i++"
76 done
77 NR_LOOPS=
79 function inject_blocking()
81 OLDIFS="$IFS"
82 IFS=$'\n'
83 INJECT_LIST=(
84 "7"
85 "8"
86 "9"
88 IFS="$OLDIFS"
90 NR_LOOPS=-1
92 i=0
93 while [ "$i" -lt "${#INJECT_LIST[@]}" ]; do
94 echo "Injecting at <${INJECT_LIST[$i]}>"
95 do_tests -${INJECT_LIST[i]} -1 ${@}
96 let "i++"
97 done
98 NR_LOOPS=
101 echo "Yield injection (25%)"
102 inject_blocking -m 4 -y
104 echo "Yield injection (50%)"
105 inject_blocking -m 2 -y
107 echo "Yield injection (100%)"
108 inject_blocking -m 1 -y
110 echo "Kill injection (25%)"
111 inject_blocking -m 4 -k
113 echo "Kill injection (50%)"
114 inject_blocking -m 2 -k
116 echo "Kill injection (100%)"
117 inject_blocking -m 1 -k
119 echo "Sleep injection (1ms, 25%)"
120 inject_blocking -m 4 -s 1
122 echo "Sleep injection (1ms, 50%)"
123 inject_blocking -m 2 -s 1
125 echo "Sleep injection (1ms, 100%)"
126 inject_blocking -m 1 -s 1