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