1 #!/bin/bash 2 # SPDX-License-Identifier: GPL-2.0+ or MIT 3 4 NR_CPUS=`grep '^processor' /proc/cpuinfo | wc -l` 5 6 EXTRA_ARGS=${@} 7 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" 19 ) 20 21 TEST_NAME=( 22 "spinlock" 23 "list" 24 "buffer" 25 "buffer with barrier" 26 "memcpy" 27 "memcpy with barrier" 28 "increment" 29 "membarrier" 30 ) 31 IFS="$OLDIFS" 32 33 REPS=1000 34 SLOW_REPS=100 35 NR_THREADS=$((6*${NR_CPUS})) 36 37 function do_tests() 38 { 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 46 echo "Running mm_cid test ${TEST_NAME[$i]}" 47 ./param_test_mm_cid ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1 48 echo "Running mm_cid compare-twice test ${TEST_NAME[$i]}" 49 ./param_test_mm_cid_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1 50 let "i++" 51 done 52 } 53 54 echo "Default parameters" 55 do_tests 56 57 echo "Loop injection: 10000 loops" 58 59 OLDIFS="$IFS" 60 IFS=$'\n' 61 INJECT_LIST=( 62 "1" 63 "2" 64 "3" 65 "4" 66 "5" 67 "6" 68 "7" 69 "8" 70 "9" 71 ) 72 IFS="$OLDIFS" 73 74 NR_LOOPS=10000 75 76 i=0 77 while [ "$i" -lt "${#INJECT_LIST[@]}" ]; do 78 echo "Injecting at <${INJECT_LIST[$i]}>" 79 do_tests -${INJECT_LIST[i]} ${NR_LOOPS} 80 let "i++" 81 done 82 NR_LOOPS= 83 84 function inject_blocking() 85 { 86 OLDIFS="$IFS" 87 IFS=$'\n' 88 INJECT_LIST=( 89 "7" 90 "8" 91 "9" 92 ) 93 IFS="$OLDIFS" 94 95 NR_LOOPS=-1 96 97 i=0 98 while [ "$i" -lt "${#INJECT_LIST[@]}" ]; do 99 echo "Injecting at <${INJECT_LIST[$i]}>" 100 do_tests -${INJECT_LIST[i]} -1 ${@} 101 let "i++" 102 done 103 NR_LOOPS= 104 } 105 106 echo "Yield injection (25%)" 107 inject_blocking -m 4 -y 108 109 echo "Yield injection (50%)" 110 inject_blocking -m 2 -y 111 112 echo "Yield injection (100%)" 113 inject_blocking -m 1 -y 114 115 echo "Kill injection (25%)" 116 inject_blocking -m 4 -k 117 118 echo "Kill injection (50%)" 119 inject_blocking -m 2 -k 120 121 echo "Kill injection (100%)" 122 inject_blocking -m 1 -k 123 124 echo "Sleep injection (1ms, 25%)" 125 inject_blocking -m 4 -s 1 126 127 echo "Sleep injection (1ms, 50%)" 128 inject_blocking -m 2 -s 1 129 130 echo "Sleep injection (1ms, 100%)" 131 inject_blocking -m 1 -s 1
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.